35 #ifndef OPENMS_MATH_MISC_MATHFUNCTIONS_H
36 #define OPENMS_MATH_MISC_MATHFUNCTIONS_H
66 return (ceil(x / pow(10.0, decPow))) * pow(10.0, decPow);
82 return (floor(0.5 + x / pow(10.0, decPow))) * pow(10.0, decPow);
84 return -((floor(0.5 + fabs(x) / pow(10.0, decPow))) * pow(10.0, decPow));
94 return left2 + (x - left1) * (right2 - left2) / (right1 - left1);
118 return pow(10, x) - 1;
136 template <
typename T>
141 return T(floor(x + T(0.5)));
145 return T(ceil(x - T(0.5)));
156 return std::fabs(a - b) <= tol;
167 template <
typename T>
192 template <
typename T>
193 T
gcd(T a, T b, T & u1, T & u2)
225 #endif // OPENMS_MATH_MISC_MATHFUNCTIONS_H
bool isOdd(UInt x)
Returns true if the given integer is odd.
Definition: MathFunctions.h:126
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
static double intervalTransformation(double x, double left1, double right1, double left2, double right2)
transforms point x of interval [left1,right1] into interval [left2,right2]
Definition: MathFunctions.h:92
T round(T x)
Rounds the value.
Definition: MathFunctions.h:137
static double ceilDecimal(double x, int decPow)
rounds x up to the next decimal power 10 ^ decPow
Definition: MathFunctions.h:64
T gcd(T a, T b)
Returns the greatest common divisor (gcd) of two numbers by applying the Euclidean algorithm...
Definition: MathFunctions.h:168
static bool approximatelyEqual(double a, double b, double tol)
Returns if a is approximately equal b , allowing a tolerance of tol.
Definition: MathFunctions.h:154
double log2linear(double x)
Transforms a number from log10 to to linear scale. Subtracts the 1 added by linear2log(double) ...
Definition: MathFunctions.h:116
static double roundDecimal(double x, int decPow)
rounds x to the next decimal power 10 ^ decPow
Definition: MathFunctions.h:79
double linear2log(double x)
Transforms a number from linear to log10 scale. Avoids negative logarithms by adding 1...
Definition: MathFunctions.h:104