MercuryDPM
Beta
|
Namespace for some extra maths function that are often needed. More...
Functions | |
Mdouble | gamma (Mdouble gamma_in) |
This is the gamma function returns the true value for the half integer value. More... | |
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. More... | |
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. More... | |
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. More... | |
template<typename T > | |
int | sign (T val) |
This is a sign function, it returns -1 for negative numbers, 1 for positive numbers and 0 for 0. More... | |
template<typename T > | |
T | square (T val) |
squares a number More... | |
template<typename T > | |
T | cubic (T val) |
calculates the cube of a number More... | |
bool | isEqual (Mdouble v1, Mdouble v2, double absError) |
Compares the difference of two Mdouble with an absolute error, useful in UnitTests. More... | |
bool | isEqual (Vec3D v1, Vec3D v2, double absError) |
Compares the difference of two Vec3D with an absolute error, useful in UnitTests. More... | |
template<typename T > | |
constexpr T | factorial (const T t) |
factorial function More... | |
Namespace for some extra maths function that are often needed.
This is a chi_squared function return the value x and degrees of freedom k.
Definition at line 70 of file ExtendedMath.cc.
References gamma().
Referenced by chi_squared_prob().
This is the function which actually gives the probability back using a chi squared test.
This calulates the probabity based on a chi squared test First we calculated the cummelative chi_squared function.
This is the function which actually gives the probability back It is calculated by calling the normal chi_squated function and using the trapezoidal rule. The final results is 1-the cummulative chi_squared function
Definition at line 86 of file ExtendedMath.cc.
References chi_squared().
Referenced by RNG::test().
T mathsFunc::cubic | ( | T | val | ) |
calculates the cube of a number
Definition at line 99 of file ExtendedMath.h.
Referenced by ChuteBottom::setupInitialConditions().
constexpr T mathsFunc::factorial | ( | const T | t | ) |
factorial function
Definition at line 124 of file ExtendedMath.h.
Referenced by HGridOptimiser::histNumberParticlesPerCell().
This is the gamma function returns the true value for the half integer value.
This is the gamma function, gives 'exact' answers for the half integer values This is done using the recussion relation and the known values for 1 and 0.5 Note, return NaN for non-half integer values.
Definition at line 47 of file ExtendedMath.cc.
References constants::sqrt_pi.
Referenced by chi_squared(), and HopperInsertionBoundary::generateParticle().
Mdouble mathsFunc::goldenSectionSearch | ( | double(*)(const double) | function, |
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.
[in] | function | A function pointer to the function of which you want to calculate the location of its minimum. |
[in] | min | The minimum location |
[in] | cur | The current location |
[in] | max | The maximum location |
[in] | endCondition | The algorithm terminates when abs(max - min) < endCondition |
[in] | curVal | The value of the function at the current location (on default this value is calculated internally) |
Definition at line 104 of file ExtendedMath.cc.
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
[in] | v1 | The first Mdouble |
[in] | v2 | The second Mdouble |
[in] | absError | The allowed maximum absolute error |
Definition at line 148 of file ExtendedMath.cc.
Referenced by ChuteInsertionBoundary::generateParticle(), isEqual(), and MercuryBase::setHGridCellOverSizeRatio().
Compares the difference of two Vec3D with an absolute error, useful in UnitTests.
[in] | v1 | The first Vec3D |
[in] | v2 | The second Vec3D |
[in] | absError | The allowed maximum absolute error |
Definition at line 154 of file ExtendedMath.cc.
References isEqual(), Vec3D::X, Vec3D::Y, and Vec3D::Z.
int mathsFunc::sign | ( | T | val | ) |
This is a sign function, it returns -1 for negative numbers, 1 for positive numbers and 0 for 0.
Definition at line 83 of file ExtendedMath.h.
Referenced by Screw::getDistanceAndNormal().
T mathsFunc::square | ( | T | val | ) |
squares a number
Definition at line 91 of file ExtendedMath.h.
Referenced by DPMBase::areInContact(), DPMBase::checkParticleForInteraction(), helpers::computeCollisionTimeFromKAndDispAndEffectiveMass(), helpers::computeCollisionTimeFromKAndRestitutionCoefficientAndEffectiveMass(), helpers::computeDispFromKAndCollisionTimeAndEffectiveMass(), helpers::computeDispFromKAndRestitutionCoefficientAndEffectiveMass(), helpers::computeDisptFromCollisionTimeAndRestitutionCoefficientAndTangentialRestitutionCoefficientAndEffectiveMass(), SlidingFrictionInteraction::computeFrictionForce(), FrictionInteraction::computeFrictionForce(), helpers::computeKFromCollisionTimeAndDispAndEffectiveMass(), helpers::computeKFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(), helpers::computeKFromDispAndRestitutionCoefficientAndEffectiveMass(), ParticleSpecies::computeMass(), helpers::computeRestitutionCoefficientFromKAndCollisionTimeAndEffectiveMass(), helpers::computeRestitutionCoefficientFromKAndDispAndEffectiveMass(), LinearPlasticViscoelasticNormalSpecies::computeTimeStep(), LinearViscoelasticNormalSpecies::getCollisionTime(), StatisticsVector< T >::getCutoff2(), HertzianViscoelasticInteraction::getElasticEnergy(), LinearPlasticViscoelasticInteraction::getElasticEnergy(), LinearViscoelasticInteraction::getElasticEnergy(), IrreversibleAdhesiveInteraction::getElasticEnergy(), helpers::getMaximumVelocity(), StatisticsVector< T >::setCGWidth(), SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(), SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficientNoDispt(), LinearPlasticViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), LinearViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), LinearViscoelasticNormalSpecies::setStiffnessAndRestitutionCoefficient(), Matrix3D::square(), and MatrixSymmetric3D::square().