Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qlibs::ffmath Namespace Reference

Namespace for the Fast floating-point math library. More...

Classes

struct  numbers
 Provides several mathematical constants as single-precision floating-point numbers. More...
 

Enumerations

enum class  classification {
  classification::FFP_ZERO , classification::FFP_SUBNORMAL , classification::FFP_NORMAL , classification::FFP_INFINITE ,
  classification::FFP_NAN
}
 Enum with the possible categorizations of a 32-bit floating-point number. More...
 

Functions

bool isEqual (const float a, const float b, const float tol=1.175494351e-38F) noexcept
 Determines if the parameters given as floating-point values are approximately equal.
 
float getInf (void)
 Returns positive infinity inf as a 32-bit floating point number.
 
float getNan (void)
 Returns Not a Number ( NaN ) nan as a 32-bit floating point number.
 
classification classify (const float f)
 Categorizes the floating-point number x. This function determines whether its argument is a normal floating-point number, or one of several special categories of values, including NaN (not a number), infinity, subnormal floating-point values or zero. To determine what category the argument belongs to, compare the return value with the any of the following number classification macros:
 
template<typename T , typename... Args>
Max (const T &first, const Args &... args)
 Finds the maximum value among the provided arguments.
 
template<typename T , typename... Args>
Min (const T &first, const Args &... args)
 Finds the minimum value among the provided arguments.
 
bool isNan (const float x)
 Determine if x is Not-A-Number NaN.
 
bool isInf (const float x)
 Determine if x is Infinity.
 
bool isFinite (const float x)
 Determines if the given floating point number x has finite value i.e. it is normal, subnormal or zero, but not infinite or NaN.
 
bool isNormal (const float x)
 Determines if the given floating point number x is normal, i.e. is neither zero, subnormal, infinite, or NaN.
 
float copysign (float mag, float sgn)
 Composes a floating point value with the magnitude of mag and the sign of sgn.
 
float sign (float x)
 Computes the sign function ( signum function).
 
float absf (float x)
 Computes the absolute value of a floating point value x.
 
float recip (float x)
 Computes the multiplicative inverse or reciprocal for the value x, denoted by 1/x or x^(−1)
 
float sqrt (float x)
 Computes the square-root of x.
 
float rSqrt (float x)
 Computes the reciprocal square-root of x denoted as 1/sqrt(x)
 
float cbrt (float x)
 Computes the cubic-root of x.
 
float rCbrt (float x)
 Computes the reciprocal cubic-root of x denoted as 1/cbrt(x)
 
float rounding (float x)
 Computes the nearest integer value to x (in floating-point format), rounding halfway cases away from zero.
 
float floor (float x)
 Computes the largest integer value not greater than x.
 
float ceil (float x)
 Computes the smallest integer value not less than x.
 
float trunc (float x)
 Computes the nearest integer not greater in magnitude than x.
 
float frac (float x)
 Obtain the fractional part of x.
 
float rem (float x, float y)
 Computes the floating point remainder after division of x by y, where x is the dividend and y is the divisor. This function is often called the remainder operation, which can be expressed as r=a-(b*trunc(a/b)) . This function follows the convention that rem(x,0) is nan.
 
float mod (float x, float y)
 Computes the floating point remainder after division of x by y, where x is the dividend and y is the divisor. This function is often called the modulo operation, which can be expressed as b=a-m*floor(a/m) . This function follows the convention that mod(x,0) returns x.
 
float sin (float x)
 Computes the sine of x (measured in radians).
 
float cos (float x)
 Computes the cosine of x (measured in radians).
 
float tan (float x)
 Computes the tangent of x (measured in radians).
 
float asin (float x)
 Computes the principal value of the arc sine of x.
 
float acos (float x)
 Computes the principal value of the arc cosine of x.
 
float atan (float x)
 Computes the principal value of the arc tangent of x.
 
float atan2 (float y, float x)
 Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant.
 
float exp2 (float x)
 Computes 2 raised to the given power x.
 
float log2 (float x)
 Computes the base 2 logarithm of x.
 
float exp (float x)
 Computes the e ( Euler's number, 2.7182818 ) raised to the given power x.
 
float expm1 (float x)
 Returns e raised to the given power minus one e^x-1 power x.
 
float exp10 (float x)
 Computes the value of 10 raised to the power of x.
 
float log (float x)
 Computes the natural (base e) logarithm of x.
 
float log1p (float x)
 Computes the natural (base e) logarithm of 1 plus the given number x ln(1+x) .
 
float log10 (float x)
 Computes the common (base-10) logarithm of x.
 
float pow (float b, float e)
 Computes the value of b raised to the power e.
 
float sinh (float x)
 Computes hyperbolic sine of x.
 
float cosh (float x)
 Computes hyperbolic cosine of x.
 
float tanh (float x)
 Computes hyperbolic tangent of x.
 
float asinh (float x)
 Computes the inverse hyperbolic sine of x.
 
float acosh (float x)
 Computes the inverse hyperbolic cosine of x.
 
float atanh (float x)
 Computes the inverse hyperbolic tangent of x.
 
float wrapToPi (float x)
 Wraps angle x, in radians, to the interval [−pi, pi] such that pi maps to pi and −pi maps to −pi. In general, odd, positive multiples of pi map to pi and odd, negative multiples of pi map to −pi.
 
float wrapTo2Pi (float x)
 Wraps angle x, in radians, to the interval [0, 2*pi] such that 0 maps to 0 and 2*pi and 2*pi maps to 2*pi. In general, positive multiples of 2*pi map to 2*pi and negative multiples of 2*pi map to 0.
 
float wrapTo180 (float x)
 Wraps angle x, in degrees, to the interval [–180, 180] such that 180 maps to 180 and –180 maps to –180. In general, odd, positive multiples of 180 map to 180 and odd, negative multiples of 180 map to –180.
 
float wrapTo360 (float x)
 Wraps angle x, in degrees, to the interval [0, 360] such that 0 maps to 0 and 360 maps to 360. In general, positive multiples of 360 map to 360 and negative multiples of 360 map to zero.
 
float midpoint (float a, float b)
 Computes the midpoint of the floating-points a and b.
 
float lerp (float a, float b, float t)
 Computes the linear interpolation between a and b, if the parameter t is inside [0, 1] (the linear extrapolation otherwise), i.e. the result of a+t*(b-a) with accounting for floating-point calculation imprecision.
 
float map (const float x, const float xMin, const float xMax, const float yMin, const float yMax) noexcept
 Scales the given input x in value range given by xMin and xMax to value range specified by the yMin and yMax.
 
real_t normalize (const float x, const float xMin, const float xMax) noexcept
 Normalize the given input x in value range given by xMin and xMax to value range between 0 and 1.
 
bool inRangeCoerce (float &x, const float lowerL, const float upperL) noexcept
 Determines if the value pointed by x falls within a range specified by the upper limit and lower limit inputs and coerces the value to fall within the range.
 
bool inPolygon (const float x, const float y, const float *const px, const float *const py, const size_t p) noexcept
 Determines if the point at ( x, y ) is inside the polygon given by the set of points on px and py.
 
bool inCircle (const float x, const float y, const float cx, const float cy, const float r) noexcept
 Determines if the point at ( x, y) is inside the circle with radius r located at cx and cy.
 
float erf (float x)
 Computes the error function of x.
 
float erfc (float x)
 Computes the complementary error function of x.
 
float rexp (float x, int32_t *pw2)
 Decomposes given floating point value x into a normalized fraction and an integral power of two.
 
float ldexp (float x, int32_t pw2)
 Multiplies a floating point value x by the number 2 raised to the pw2 power.
 
float hypot (float x, float y)
 Computes the square root of the sum of the squares of x and y, without undue overflow or underflow at intermediate stages of the computation.
 
float nextAfter (float x, float y)
 Returns the next representable value of x in the direction of y. If x equals to y, y is returned.
 
float tgamma (float x)
 Computes the gamma function of x.
 
float lgamma (float x)
 Computes the natural logarithm of the absolute value of the gamma function of x.
 
float factorial (float x)
 Return the factorial of the integer part of x.
 
float assoc_laguerre (size_t n, size_t m, float x)
 Computes the associated Laguerre polynomials of the degree n, order m, and argument x.
 
float assoc_legendre (size_t n, size_t m, float x)
 Computes the associated Legendre polynomials of the degree n, order m, and argument x.
 
float beta (float x, float y)
 Computes the Beta function of x and y.
 
float comp_ellint_1 (float k)
 Computes the complete elliptic integral of the first kind of k.
 
float comp_ellint_2 (float k)
 Computes the complete elliptic integral of the second kind of k.
 
float comp_ellint_3 (float k, float nu)
 Computes the complete elliptic integral of the third kind of k and nu.
 
float ellint_1 (float k, float phi)
 Computes the incomplete elliptic integral of the first kind of k and phi.
 
float ellint_2 (float k, float phi)
 Computes the incomplete elliptic integral of the second kind of k and phi.
 
float ellint_3 (float k, float nu, float phi)
 Computes the incomplete elliptic integral of the third kind of k, nu and phi.
 
float expint (float num)
 Computes the Exponential integral of num.
 
float hermite (size_t n, float x)
 Computes the (physicist's) Hermite polynomials of the degree n and argument x.
 
float laguerre (size_t n, float x)
 Computes the non-associated Laguerre polynomials of the degree n, and argument x.
 
float legendre (size_t n, float x)
 Computes the unassociated Legendre polynomials of the degree n, and argument x.
 
float riemann_zeta (float s)
 Computes the Riemann zeta function of s.
 
float sph_bessel (size_t n, float x)
 Computes the spherical Bessel function of the first kind n, and x.
 
float sph_neumann (size_t n, float x)
 Computes the spherical Bessel function of the second kind also known as the spherical Neumann function of n and x.
 
float cyl_bessel_i (float nu, float x)
 Computes the regular modified cylindrical Bessel function of nu and x.
 
float cyl_bessel_j (float nu, float x)
 Computes the cylindrical Bessel function of the first kind of nu and x.
 
float cyl_bessel_k (float nu, float x)
 Computes the irregular modified cylindrical Bessel function (also known as modified Bessel function of the second kind) of nu and x.
 
float cyl_neumann (float nu, float x)
 Computes the cylindrical Neumann function ( also known as Bessel function of the second kind or Weber function) of nu and x.
 
float sph_legendre (size_t l, size_t m, float theta)
 1-3) Computes the spherical associated Legendre function of degree l, order m, and polar angle theta
 

Variables

constexpr float FFP_E
 The base of natural logarithms ( e ) given as a single-precision floating-point number.
 
constexpr float FFP_LOG2E
 The base 2 logarithm of e ( log_2 e ) given as a single-precision floating-point number.
 
constexpr float FFP_LOG10E
 The base 10 logarithm of e ( log_10 e ) given as a single-precision floating-point number.
 
constexpr float FFP_LN2
 The natural logarithm of 2 ( ln 2 ) given as a single-precision floating-point number.
 
constexpr float FFP_LN10
 The natural logarithm of 10 ( ln 10 ) given as a single-precision floating-point number.
 
constexpr float FFP_PI
 The circumference of a circle with diameter 1, ( π ) given as a single-precision floating-point number.
 
constexpr float FFP_2PI
 Twice circumference of a circle with diameter 1, ( 2π ) given as a single-precision floating-point number.
 
constexpr float FFP_PI_2
 Half of π ( π/2 ) given as a single-precision floating-point number.
 
constexpr float FFP_PI_4
 A quarter of π ( π/4 ) given as a single-precision floating-point number.
 
constexpr float FFP_1_PI
 The inverse of π ( 1/π ) given as a single-precision floating-point number.
 
constexpr float FFP_2_PI
 Twice the inverse of π ( 2/π ) given as a single-precision floating-point number.
 
constexpr float FFP_1_SQRTPI
 The inverse of the square root of π ( 1/√π ) given as a single-precision floating-point number.
 
constexpr float FFP_2_SQRTPI
 Twice the inverse of the square root of π ( 1/√π ) given as a single-precision floating-point number.
 
constexpr float FFP_SQRT2
 The square root of 2 ( √2 ) given as a single-precision floating-point number.
 
constexpr float FFP_SQRT3
 The square root of 3 ( √3 ) given as a single-precision floating-point number.
 
constexpr float FFP_SQRT1_2
 The inverse of square root of 2 ( 1/√2 ) given as a single-precision floating-point number.
 
constexpr float FFP_SQRT1_3
 The inverse of square root of 3 ( 1/√3 ) given as a single-precision floating-point number.
 
constexpr float FFP_LN_SQRT_2PI
 The natural logarithm of the square root of 2π given as a single-precision floating-point number.
 
constexpr float FFP_GAMMA_E
 Constant Euler-Mascheroni given as a single-precision floating-point number.
 
constexpr float FFP_PHI
 The golden ratio, (1+√5)/2 given as a single-precision floating-point number.
 
constexpr float FFP_RADIAN
 Radian, value of ( 180/π ) given as a single-precision floating-point number.
 
constexpr float FFP_LOG10_2
 The base 10 logarithm of 2 ( log_10 2 ) given as a single-precision floating-point number.
 
constexpr float FFP_LN_PI
 The natural logarithm of π ( ln(π) ) given as a single-precision floating-point number.
 

Detailed Description

Namespace for the Fast floating-point math library.