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)
231 template <
typename T>
234 return (mz_obs - mz_ref) / mz_ref * 1e6;
246 template <
typename T>
249 return std::fabs(
getPPM(mz_obs, mz_ref));
261 template <
typename T>
264 return (ppm / 1e6) * mz_ref;
276 template <
typename T>
279 return std::fabs(
ppmToMass(ppm, mz_ref));
295 inline static std::pair<double, double>
getTolWindow(
double val,
double tol,
bool ppm)
301 left = val - val * tol * 1e-6;
302 right = val / (1.0 - tol * 1e-6);
310 return std::make_pair(left, right);
bool isOdd(UInt x)
Returns true if the given integer is odd.
Definition: MathFunctions.h:126
static std::pair< double, double > getTolWindow(double val, double tol, bool ppm)
Return tolerance window around val given tolerance tol.
Definition: MathFunctions.h:295
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
T getPPM(T mz_obs, T mz_ref)
Compute parts-per-million of two m/z values.
Definition: MathFunctions.h:232
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
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 ppmToMassAbs(T ppm, T mz_ref)
Definition: MathFunctions.h:277
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
T getPPMAbs(T mz_obs, T mz_ref)
Compute absolute parts-per-million of two m/z values.
Definition: MathFunctions.h:247
T ppmToMass(T ppm, T mz_ref)
Compute the mass diff in [Th], given a ppm value and a reference point.
Definition: MathFunctions.h:262