27 #ifndef EXTENDEDMATH_H
28 #define EXTENDEDMATH_H
36 #define sqr(a) ((a)*(a))
37 #define cubic(a) ((a)*(a)*(a))
38 #define UNUSED __attribute__ ((__unused__))
54 const Mdouble pi =3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068;
55 const Mdouble sqrt_pi =1.772453850905516027298167483341145182797549456122387128213807789852911284591032181374950656738544665;
56 const Mdouble sqr_pi =9.869604401089358618834490999876151135313699407240790626413349376220044822419205243001773403718552232;
57 const Mdouble sqrt_2 =1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573;
58 const Mdouble sqrt_3 =1.732050807568877293527446341505872366942805253810380628055806979451933016908800037081146186757248576;
75 template <
typename T>
int sign(T val)
77 return (T(0) < val) - (val < T(0));
Mdouble chebyshev(Mdouble x, const Mdouble coef[], int N)
KAndDisp computeKAndDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass)
Set disp and k such that is matches a given collision time tc and restitution coefficient r for a col...
Mdouble getMaximumVelocity(Mdouble k, Mdouble disp, Mdouble radius, Mdouble mass)
Calculates the maximum relative velocity allowed for a normal collision of two particles of radius r ...
return type specifically for fuctions returning k and disp at once
Mdouble I0_exp(Mdouble x)
int sign(T val)
This is a sign function, it returns -1 for negative numbers, 1 for positive numbers and 0 for 0...
return type specifically for fuctions returning k, disp, kt, dispt at once
Mdouble getRestitutionCoefficient(Mdouble k, Mdouble disp, Mdouble mass)
Calculates restitution coefficient for two copies of given disp, k, effective mass.
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Mdouble gamma(Mdouble gamma_in)
This is the gamma function returns the true value for the half integer value.
KAndDispAndKtAndDispt computeDisptFromCollisionTimeAndRestitutionCoefficientAndTangentialRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble beta, Mdouble mass)
Set disp, k, dispt and kt such that is matches a given collision time tc and a normal andtangential r...
Mdouble chi_squared_prob(Mdouble x, int k)
This is the function which actually gives the probability back using a chi squared test...
Mdouble getCollisionTime(Mdouble k, Mdouble disp, Mdouble mass)
Calculates collision time for two copies of a particle of given disp, k, effective mass...
Mdouble chi_squared(Mdouble x, int k)
This is a chi_squared function return the value x and degrees of freedom k.