INET Framework for OMNeT++/OMNEST
INETMath.h File Reference
#include <cmath>
#include <limits>
#include "inet/common/INETDefs.h"

Namespaces

 inet
 Copyright (c) 2005 Jan Ringo�, www.ringos.cz.
 
 inet::math
 Support functions for mathematical operations.
 

Macros

#define M_E   2.7182818284590452354
 
#define M_LOG2E   1.4426950408889634074
 
#define M_LOG10E   0.43429448190325182765
 
#define M_LN2   0.69314718055994530942
 
#define M_LN10   2.30258509299404568402
 
#define M_PI   3.14159265358979323846
 
#define M_PI_2   1.57079632679489661923
 
#define M_PI_4   0.78539816339744830962
 
#define M_1_PI   0.31830988618379067154
 
#define M_2_PI   0.63661977236758134308
 
#define M_2_SQRTPI   1.12837916709551257390
 
#define M_SQRT2   1.41421356237309504880
 
#define M_SQRT1_2   0.70710678118654752440
 
#define EPSILON   0.001
 
#define qNaN   std::numeric_limits<double>::quiet_NaN()
 
#define sNaN   std::numeric_limits<double>::signaling_NaN()
 
#define NaN   qNaN
 

Functions

double inet::math::mod (double dividend, double divisor)
 Returns the rest of a whole-numbered division. More...
 
double inet::math::div (double dividend, double divisor)
 Returns the result of a whole-numbered division. More...
 
double inet::math::modulo (double a, double n)
 Returns the remainder r on division of dividend a by divisor n, using floored division. More...
 
bool inet::math::close (double one, double two)
 Tests whether two doubles are close enough to be declared equal. More...
 
int inet::math::stepfunction (double i)
 Returns 0 if i is close to 0, 1 if i is positive and greater than epsilon, or -1 if it is negative and less than epsilon. More...
 
double inet::math::step (double a, double b)
 
double inet::math::clamp (double v, double l, double u)
 
int inet::math::sign (double v)
 Returns 1 if the parameter is greater than zero, -1 if less than zero, 0 otherwise. More...
 
int inet::math::round (double d)
 Returns an integer that corresponds to rounded double parameter. More...
 
double inet::math::floorToZero (double d)
 Discards the fractional part of the parameter, e.g. More...
 
double inet::math::dB2fraction (double dB)
 Converts a dB value to fraction. More...
 
double inet::math::fraction2dB (double fraction)
 Convert a fraction value to dB. More...
 
double inet::math::dBmW2mW (double dBm)
 Converts a dBmW value to mW. More...
 
double inet::math::mW2dBmW (double mW)
 Convert a mW value to dBmW. More...
 
double inet::math::dBmWpMHz2WpHz (double dBmWpMHz)
 Converts a dBmW/MHz value into W/Hz. More...
 
double inet::math::wpHz2dBmWpMHz (double wpHz)
 Convert a W/Hz value to dBmW/MHz. More...
 
double inet::math::deg2rad (double deg)
 Convert a degree value to radian. More...
 
double inet::math::rad2deg (double rad)
 Convert a radian value to degree. More...
 
double inet::math::n_choose_k (int n, int k)
 Implementation of the n choose k (binomial coefficient) function, from the MiXiM Framework Author Karl Wessel. More...
 
template<typename T >
const T inet::math::minnan (const T &a, const T &b)
 This function properly and symmetrically handles NaNs in contrast with std::min and std::fmin. More...
 
template<typename T >
const T inet::math::maxnan (const T &a, const T &b)
 This function properly and symmetrically handles NaNs in contrast with std::max and std::fmax. More...
 

Macro Definition Documentation

◆ EPSILON

#define EPSILON   0.001

◆ M_1_PI

#define M_1_PI   0.31830988618379067154

◆ M_2_PI

#define M_2_PI   0.63661977236758134308

◆ M_2_SQRTPI

#define M_2_SQRTPI   1.12837916709551257390

◆ M_E

#define M_E   2.7182818284590452354

◆ M_LN10

#define M_LN10   2.30258509299404568402

◆ M_LN2

#define M_LN2   0.69314718055994530942

◆ M_LOG10E

#define M_LOG10E   0.43429448190325182765

◆ M_LOG2E

#define M_LOG2E   1.4426950408889634074

◆ M_PI

#define M_PI   3.14159265358979323846

◆ M_PI_2

#define M_PI_2   1.57079632679489661923

◆ M_PI_4

#define M_PI_4   0.78539816339744830962

◆ M_SQRT1_2

#define M_SQRT1_2   0.70710678118654752440

◆ M_SQRT2

#define M_SQRT2   1.41421356237309504880

◆ NaN

#define NaN   qNaN

◆ qNaN

#define qNaN   std::numeric_limits<double>::quiet_NaN()

◆ sNaN

#define sNaN   std::numeric_limits<double>::signaling_NaN()