Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
|
#include <cfloat>
#include <cstddef>
Go to the source code of this file.
Classes | |
class | CompareDoubles |
Functions | |
double | SmallPow (double x, unsigned exponent) |
unsigned | SmallPow (unsigned x, unsigned exponent) |
bool | Divides (double smallerNumber, double largerNumber) |
unsigned | CeilDivide (unsigned numerator, unsigned denominator) |
double | Signum (double value) |
double | SafeDivide (double numerator, double divisor) |
unsigned | AdvanceMod (unsigned index, int increment, std::size_t range) noexcept |
unsigned | SmallDifferenceMod (unsigned idxA, unsigned idxB, std::size_t range) noexcept |
This file contains some utility functions and a small class for dealing with floating point numbers.
Definition in file MathsCustomFunctions.hpp.
Advance index by increment and return the result modulo range taking into account negative decrements. It is assumed that index + range does not overflow the int type, and that 0 < range < INT_MAX.
Note that this function is designed to avoid integer division and is very efficient when (index + increment) is in [-range, 2*range).
index | the current index to increment |
increment | the amount to increment the index by |
range | the top of the range; [0, range) |
Definition at line 172 of file MathsCustomFunctions.cpp.
numerator | the numerator |
denominator | the denominator |
Definition at line 132 of file MathsCustomFunctions.cpp.
smallerNumber | the smaller |
largerNumber | the larger |
Definition at line 109 of file MathsCustomFunctions.cpp.
numerator | the number to be divided |
divisor | the number to divide by |
Definition at line 155 of file MathsCustomFunctions.cpp.
Referenced by CompareDoubles::Difference(), and CompareDoubles::WithinRelativeTolerance().
value | the argument value |
Definition at line 145 of file MathsCustomFunctions.cpp.
Calculate the smaller of the two differences between two indices, modulo N. I.e. the smallest number of increments from idxA required to get to idxB, modulo range.
idxA | first index, in [0, range) |
idxB | second index, in [0, range) |
range | the top of the range; [0, range) |
Definition at line 188 of file MathsCustomFunctions.cpp.
Replacement "pow" function.
x | number to be raised to a small power |
exponent | small integer exponent |
Definition at line 42 of file MathsCustomFunctions.cpp.
Replacement "pow" function for unsigned integer values
x | number to be raised to a small power |
exponent | small integer exponent |
Definition at line 72 of file MathsCustomFunctions.cpp.