26 #ifndef EXTENDEDMATH_H
27 #define EXTENDEDMATH_H
42 const Mdouble pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068;
43 const Mdouble sqrt_pi = 1.772453850905516027298167483341145182797549456122387128213807789852911284591032181374950656738544665;
44 const Mdouble sqr_pi = 9.869604401089358618834490999876151135313699407240790626413349376220044822419205243001773403718552232;
45 const Mdouble sqrt_2 = 1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573;
46 const Mdouble sqrt_3 = 1.732050807568877293527446341505872366942805253810380628055806979451933016908800037081146186757248576;
78 double goldenSectionSearch(
double (*
function)(
const double),
double min,
double cur,
double max,
double endCondition,
double curVal = std::numeric_limits<Mdouble>::quiet_NaN());
83 template<
typename T>
int sign(T val)
85 return (T(0) < val) - (val < T(0));
99 template<
typename T> T
cubic(T val)
101 return val * val * val;
126 return (t == 0) ? 1 : t *
factorial(t - 1);
Mdouble chebyshev(Mdouble x, const Mdouble coef[], int N)
Mdouble chi_squared_prob(const Mdouble x, const unsigned int k)
This is the function which actually gives the probability back using a chi squared test...
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...
T square(T val)
squares a number
constexpr T factorial(const T t)
factorial function
T cubic(T val)
calculates the cube of a number
bool isEqual(Mdouble v1, Mdouble v2, double absError)
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
double goldenSectionSearch(double(*function)(const double), double min, double cur, double max, double endCondition, double curVal=std::numeric_limits< Mdouble >::quiet_NaN())
This function performs a golden section search to find the location of the minimum of a function...
Mdouble gamma(Mdouble gamma_in)
This is the gamma function returns the true value for the half integer value.
Mdouble chi_squared(const Mdouble x, const unsigned int k)
This is a chi_squared function return the value x and degrees of freedom k.
Implementation of a 3D vector (by Vitaliy).