Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
CompareDoubles Class Reference

#include <MathsCustomFunctions.hpp>

+ Collaboration diagram for CompareDoubles:

Static Public Member Functions

static bool IsNearZero (double number, double tolerance)
 
static bool WithinRelativeTolerance (double number1, double number2, double tolerance)
 
static bool WithinAbsoluteTolerance (double number1, double number2, double tolerance)
 
static bool WithinTolerance (double number1, double number2, double tolerance, bool toleranceIsAbsolute)
 
static bool WithinAnyTolerance (double number1, double number2, double relTol=DBL_EPSILON, double absTol=DBL_EPSILON, bool printError=false)
 
static double Difference (double number1, double number2, bool toleranceIsAbsolute)
 

Detailed Description

Utility static methods for comparing floating point numbers, based on boost/test/floating_point_comparison.hpp.

Definition at line 130 of file MathsCustomFunctions.hpp.

Member Function Documentation

◆ Difference()

double CompareDoubles::Difference ( double  number1,
double  number2,
bool  toleranceIsAbsolute 
)
static
Returns
the relative or absolute difference between two numbers.
Parameters
number1the first number to compare
number2the second number to compare
toleranceIsAbsolutewhether the tolerance is absolute (true) or relative (false)

Definition at line 245 of file MathsCustomFunctions.cpp.

References SafeDivide().

◆ IsNearZero()

bool CompareDoubles::IsNearZero ( double  number,
double  tolerance 
)
static
Returns
true if a number is close to zero, as defined by the given tolerance. A number equal in magnitude to the tolerance is OK.
Parameters
numberthe number to compare
tolerancehow close it must be

Definition at line 150 of file MathsCustomFunctions.cpp.

Referenced by AbstractNonlinearAssemblerSolverHybrid< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::ComputeJacobianNumerically().

◆ WithinAbsoluteTolerance()

bool CompareDoubles::WithinAbsoluteTolerance ( double  number1,
double  number2,
double  tolerance 
)
static
Returns
true if two numbers are close within the given absolute tolerance. A difference of exactly the tolerance is OK.
Parameters
number1the first number to compare
number2the second number to compare
tolerancethe absolute tolerance to use

Definition at line 208 of file MathsCustomFunctions.cpp.

Referenced by WithinAnyTolerance(), and WithinTolerance().

◆ WithinAnyTolerance()

bool CompareDoubles::WithinAnyTolerance ( double  number1,
double  number2,
double  relTol = DBL_EPSILON,
double  absTol = DBL_EPSILON,
bool  printError = false 
)
static
Returns
true if two numbers are close within the given tolerances. If either the relative or absolute tolerance is satisfied, then the result is true.
Parameters
number1the first number to compare
number2the second number to compare
relTolthe relative tolerance to compare under
absTolthe absolute tolerance to compare under
printErrorwhether to print an error message to stdout

Definition at line 213 of file MathsCustomFunctions.cpp.

References WithinAbsoluteTolerance(), and WithinRelativeTolerance().

Referenced by NumericFileComparison::CompareFiles(), CvodeAdaptor::SetupCvode(), and AbstractCvodeSystem::SetupCvode().

◆ WithinRelativeTolerance()

bool CompareDoubles::WithinRelativeTolerance ( double  number1,
double  number2,
double  tolerance 
)
static
Returns
true if two numbers are close within the given relative tolerance.
Parameters
number1the first number to compare
number2the second number to compare
tolerancethe relative tolerance to use

Definition at line 199 of file MathsCustomFunctions.cpp.

References SafeDivide().

Referenced by WithinAnyTolerance(), and WithinTolerance().

◆ WithinTolerance()

bool CompareDoubles::WithinTolerance ( double  number1,
double  number2,
double  tolerance,
bool  toleranceIsAbsolute 
)
static
Returns
true if two numbers are close within the given tolerance, and print an error message to stdout if not.
Parameters
number1the first number to compare
number2the second number to compare
tolerancethe tolerance to use
toleranceIsAbsolutewhether the tolerance is absolute (true) or relative (false)

Definition at line 225 of file MathsCustomFunctions.cpp.

References WithinAbsoluteTolerance(), and WithinRelativeTolerance().


The documentation for this class was generated from the following files: