Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qFFMath

Fast floating-point math library for applications where speed is more important than accuracy. More...

Macros

#define QFFM_E
 The base of natural logarithms ( e ) given as a single-precision floating-point number.
 
#define QFFM_LOG2E
 The base 2 logarithm of e ( log_2 e ) given as a single-precision floating-point number.
 
#define QFFM_LOG10E
 The base 10 logarithm of e ( log_10 e ) given as a single-precision floating-point number.
 
#define QFFM_LN2
 The natural logarithm of 2 ( ln 2 ) given as a single-precision floating-point number.
 
#define QFFM_LN10
 The natural logarithm of 10 ( ln 10 ) given as a single-precision floating-point number.
 
#define QFFM_PI
 The circumference of a circle with diameter 1, ( π ) given as a single-precision floating-point number.
 
#define QFFM_PI_2
 Half of π ( π/2 ) given as a single-precision floating-point number.
 
#define QFFM_PI_4
 A quarter of π ( π/4 ) given as a single-precision floating-point number.
 
#define QFFM_1_PI
 The inverse of π ( 1/π ) given as a single-precision floating-point number.
 
#define QFFM_2_PI
 Twice the inverse of π ( 2/π ) given as a single-precision floating-point number.
 
#define QFFM_2_SQRTPI
 The inverse of the square root of π ( 2/√π ) given as a single-precision floating-point number.
 
#define QFFM_SQRT2
 The square root of 2 ( √2 ) given as a single-precision floating-point number.
 
#define QFFM_SQRT1_2
 The inverse of square root of 2 ( 1/√2 ) given as a single-precision floating-point number.
 
#define QFFM_LN_SQRT_2PI
 The natural logarithm of the square root of 2π given as a single-precision floating-point number.
 
#define QFFM_GAMMA_E
 Constant Euler-Mascheroni given as a single-precision floating-point number.
 
#define QFFM_2PI
 Twice circumference of a circle with diameter 1, ( 2π ) given as a single-precision floating-point number.
 
#define QFFM_LN_PI
 The natural logarithm of π ( ln(π) ) given as a single-precision floating-point number.
 
#define QFFM_MAXFLOAT
 The maximum value of a non-infinite single-precision floating-point number.
 
#define QFFM_INFINITY
 Positive infinity given as a single-precision floating-point number.
 
#define QFFM_NAN
 Not a Number (NaN) given as a single-precision floating-point number.
 
#define QFFM_FP_ZERO
 Indicates that the value is positive or negative zero.
 
#define QFFM_FP_SUBNORMAL
 Indicates that the value is subnormal.
 
#define QFFM_FP_NORMAL
 Indicates that the value is normal, i.e. not an infinity, subnormal, not-a-number or zero.
 
#define QFFM_FP_INFINITE
 Indicates that the value is not representable by the underlying type, positive or negative infinity.
 
#define QFFM_FP_NAN
 Indicates that the value is not-a-number NaN.
 

Functions

int qFFMath_FPClassify (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:
 
bool qFFMath_IsNaN (const float x)
 Determine if x is Not-A-Number (NaN) aka QFFM_NAN.
 
bool qFFMath_IsInf (const float x)
 Determine if x is Infinity.
 
bool qFFMath_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 qFFMath_IsNormal (const float x)
 Determines if the given floating point number x is normal, i.e. is neither zero, subnormal, infinite, or NaN.
 
float qFFMath_Abs (float x)
 Computes the absolute value of a floating point value x.
 
float qFFMath_Recip (float x)
 Computes the multiplicative inverse or reciprocal for the value x, denoted by 1/x or x^(−1)
 
float qFFMath_Sqrt (float x)
 Computes the square-root of x.
 
float qFFMath_RSqrt (float x)
 Computes the reciprocal square-root of x denoted as 1/sqrt(x)
 
float qFFMath_Cbrt (float x)
 Computes the cubic-root of x.
 
float qFFMath_RCbrt (float x)
 Computes the reciprocal cubic-root of x denoted as 1/cbrt(x)
 
float qFFMath_Round (float x)
 Computes the nearest integer value to x (in floating-point format), rounding halfway cases away from zero.
 
float qFFMath_Floor (float x)
 Computes the largest integer value not greater than x.
 
float qFFMath_Ceil (float x)
 Computes the smallest integer value not less than x.
 
float qFFMath_Trunc (float x)
 Computes the nearest integer not greater in magnitude than x.
 
float qFFMath_Frac (float x)
 Obtain the fractional part of x.
 
float qFFMath_Remainder (float x, float y)
 Computes the IEEE remainder of the floating point division operation x/y.
 
float qFFMath_Mod (float x, float y)
 Computes the floating-point remainder of the division operation x/y.
 
float qFFMath_Sin (float x)
 Computes the sine of x (measured in radians).
 
float qFFMath_Cos (float x)
 Computes the cosine of x (measured in radians).
 
float qFFMath_Tan (float x)
 Computes the tangent of x (measured in radians).
 
float qFFMath_ASin (float x)
 Computes the principal value of the arc sine of x.
 
float qFFMath_ACos (float x)
 Computes the principal value of the arc cosine of x.
 
float qFFMath_ATan (float x)
 Computes the principal value of the arc tangent of x.
 
float qFFMath_ATan2 (float y, float x)
 Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant.
 
float qFFMath_Exp2 (float x)
 Computes 2 raised to the given power x.
 
float qFFMath_Log2 (float x)
 Computes the base 2 logarithm of x.
 
float qFFMath_Exp (float x)
 Computes the e (Euler's number, 2.7182818) raised to the given power x.
 
float qFFMath_Exp10 (float x)
 Computes the value of 10 raised to the power of x.
 
float qFFMath_Log (float x)
 Computes the natural (base e) logarithm of x.
 
float qFFMath_Log10 (float x)
 Computes the common (base-10) logarithm of x.
 
float qFFMath_Pow (float b, float e)
 Computes the value of b raised to the power e.
 
float qFFMath_Sinh (float x)
 Computes hyperbolic sine of x.
 
float qFFMath_Cosh (float x)
 Computes hyperbolic cosine of x.
 
float qFFMath_Tanh (float x)
 Computes hyperbolic tangent of x.
 
float qFFMath_ASinh (float x)
 Computes the inverse hyperbolic sine of x.
 
float qFFMath_ACosh (float x)
 Computes the inverse hyperbolic cosine of x.
 
float qFFMath_ATanh (float x)
 Computes the inverse hyperbolic tangent of x.
 
float qFFMath_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 qFFMath_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 qFFMath_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 qFFMath_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 qFFMath_Erf (float x)
 Computes the error function of x.
 
float qFFMath_Erfc (float x)
 Computes the complementary error function of x.
 
float qFFMath_Max (float x, float y)
 Returns the larger of two floating point arguments.
 
float qFFMath_Min (float x, float y)
 Returns the smaller of two floating point arguments.
 
float qFFMath_RExp (float x, int32_t *pw2)
 Decomposes given floating point value x into a normalized fraction and an integral power of two.
 
float qFFMath_LDExp (float x, int32_t pw2)
 Multiplies a floating point value x by the number 2 raised to the pw2 power.
 
float qFFMath_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 qFFMath_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 qFFMath_Midpoint (float a, float b)
 Computes the midpoint of the floating-points a and b.
 
float qFFMath_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 qFFMath_Normalize (const float x, const float xMin, const float xMax)
 Normalize the given input x in value range given by xMin and xMax to value range between 0 and 1.
 
float qFFMath_Map (const float x, const float xMin, const float xMax, const float yMin, const float yMax)
 Scales the given input x in value range given by xMin and xMax to value range specified by the yMin and yMax.
 
bool qFFMath_InRangeCoerce (float *const x, const float lowerL, const float upperL)
 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 qFFMath_InPolygon (const float x, const float y, const float *const px, const float *const py, const size_t p)
 Determines if the point at ( x, y ) is inside the polygon given by the set of points on px and py.
 
bool qFFMath_InCircle (const float x, const float y, const float cx, const float cy, const float r)
 Determines if the point at ( x, y) is inside the circle with radius r located at cx and cy.
 
float qFFMath_TGamma (float x)
 Computes the gamma function of x.
 
float qFFMath_LGamma (float x)
 Computes the natural logarithm of the absolute value of the gamma function of x.
 
float qFFMath_Factorial (float x)
 Return the factorial of the integer part of x.
 
float qFFMath_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 qFFMath_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 qFFMath_Beta (float x, float y)
 Computes the Beta function of x and y.
 
float qFFMath_Comp_ellint_1 (float k)
 Computes the complete elliptic integral of the first kind of k.
 
float qFFMath_Comp_ellint_2 (float k)
 Computes the complete elliptic integral of the second kind of k.
 
float qFFMath_Comp_ellint_3 (float k, float nu)
 Computes the complete elliptic integral of the third kind of k and nu.
 
float qFFMath_Ellint_1 (float k, float phi)
 Computes the incomplete elliptic integral of the first kind of k and phi.
 
float qFFMath_Ellint_2 (float k, float phi)
 Computes the incomplete elliptic integral of the second kind of k and phi.
 
float qFFMath_Ellint_3 (float k, float nu, float phi)
 Computes the incomplete elliptic integral of the third kind of k, nu and phi.
 
float qFFMath_Expint (float num)
 Computes the Exponential integral of num.
 
float qFFMath_Hermite (size_t n, float x)
 Computes the (physicist's) Hermite polynomials of the degree n and argument x.
 
float qFFMath_Laguerre (size_t n, float x)
 Computes the non-associated Laguerre polynomials of the degree n, and argument x.
 
float qFFMath_Legendre (size_t n, float x)
 Computes the unassociated Legendre polynomials of the degree n, and argument x.
 
float qFFMath_Riemann_zeta (float s)
 Computes the Riemann zeta function of s.
 
float qFFMath_Sph_bessel (size_t n, float x)
 Computes the spherical Bessel function of the first kind n, and x.
 
float qFFMath_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 qFFMath_Cyl_bessel_i (float nu, float x)
 Computes the regular modified cylindrical Bessel function of nu and x.
 
float qFFMath_Cyl_bessel_j (float nu, float x)
 Computes the cylindrical Bessel function of the first kind of nu and x.
 
float qFFMath_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 qFFMath_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 qFFMath_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
 

Detailed Description

Fast floating-point math library for applications where speed is more important than accuracy.

Function Documentation

◆ qFFMath_Abs()

float qFFMath_Abs ( float x)

Computes the absolute value of a floating point value x.

Parameters
[in]xThe floating point value
Returns
The absolute value of x

◆ qFFMath_ACos()

float qFFMath_ACos ( float x)

Computes the principal value of the arc cosine of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the arc cosine of x arccos(x) in the range [0 ; pi]. is returned.If a domain error occurs, a QFFM_NAN value is returned.

◆ qFFMath_ACosh()

float qFFMath_ACosh ( float x)

Computes the inverse hyperbolic cosine of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the inverse hyperbolic cosine of x cosh^-1(x) is returned.

◆ qFFMath_ASin()

float qFFMath_ASin ( float x)

Computes the principal value of the arc sine of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the arc sine of x arcsin(x) in the range [-pi/2 ; pi/2]. is returned.If a domain error occurs, a QFFM_NAN value is returned.

◆ qFFMath_ASinh()

float qFFMath_ASinh ( float x)

Computes the inverse hyperbolic sine of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the inverse hyperbolic sine of x sinh^-1(x) is returned.

◆ qFFMath_Assoc_laguerre()

float qFFMath_Assoc_laguerre ( size_t n,
size_t m,
float x )

Computes the associated Laguerre polynomials of the degree n, order m, and argument x.

Parameters
[in]nThe degree of the polynomial, an unsigned integer value
[in]mThe order of the polynomial, an unsigned integer value
[in]xThe argument, a floating-point or integer value
Returns
Upon successful completion, the value of the associated Laguerre polynomial of x shall be returned. If the argument is nan, a nan is returned. If x is negative, nan is returned. If n or m is greater or equal to 128, the behavior is implementation-defined.

◆ qFFMath_Assoc_legendre()

float qFFMath_Assoc_legendre ( size_t n,
size_t m,
float x )

Computes the associated Legendre polynomials of the degree n, order m, and argument x.

Parameters
[in]nThe degree of the polynomial, an unsigned integer value
[in]mThe order of the polynomial, an unsigned integer value
[in]xThe argument, a floating-point or integer value
Returns
Upon successful completion, the value of the associated Legendre polynomial of x shall be returned. If the argument is nan, a nan is returned. If |x| > 1, nan is returned due the domain error. If n is greater or equal to 128, the behavior is implementation-defined.

◆ qFFMath_ATan()

float qFFMath_ATan ( float x)

Computes the principal value of the arc tangent of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the arc sine of x arctan(x) in the range [-pi/2 ; pi/2]. is returned.If a domain error occurs, a QFFM_NAN value is returned.

◆ qFFMath_ATan2()

float qFFMath_ATan2 ( float y,
float x )

Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant.

Parameters
[in]yThe floating point value
[in]xThe floating point value
Returns
If no errors occur, the arc tangent of y/x arctan(y/x) in the range [-pi ; +pi] radians, is returned. If a domain error occurs, a QFFM_NAN value is returned.

◆ qFFMath_ATanh()

float qFFMath_ATanh ( float x)

Computes the inverse hyperbolic tangent of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the inverse hyperbolic tangent of x tanh^-1(x) is returned. If a domain error occurs, a QFFM_NAN value is returned. If a pole error occurs, ± QFFM_INFINITY is returned.

◆ qFFMath_Beta()

float qFFMath_Beta ( float x,
float y )

Computes the Beta function of x and y.

Parameters
[in]xThe argument, a floating-point or integer value
[in]yThe argument, a floating-point or integer value
Returns
Upon successful completion, the value of the Beta function of x and y. If the argument is nan, nan is returned. The function is only required to be defined where both x and y are greater than zero, and is allowed to return nan otherwise.

◆ qFFMath_Cbrt()

float qFFMath_Cbrt ( float x)

Computes the cubic-root of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, cubic root of x, is returned. If a domain error occurs QFFM_NAN is returned

◆ qFFMath_Ceil()

float qFFMath_Ceil ( float x)

Computes the smallest integer value not less than x.

Parameters
[in]xThe floating point value
Returns
The smallest integer value not less than x

◆ qFFMath_Comp_ellint_1()

float qFFMath_Comp_ellint_1 ( float k)

Computes the complete elliptic integral of the first kind of k.

Parameters
[in]kElliptic modulus or eccentricity as a floating-point value
Returns
Upon successful completion, the value of the complete elliptic integral of the first kind of k. If the argument is nan, nan is returned. If |k| > 1, NaN is returned due the domain error

◆ qFFMath_Comp_ellint_2()

float qFFMath_Comp_ellint_2 ( float k)

Computes the complete elliptic integral of the second kind of k.

Parameters
[in]kElliptic modulus or eccentricity as a floating-point value
Returns
Upon successful completion, the value of the complete elliptic integral of the second kind of k. If the argument is nan, nan is returned. If |k| > 1, nan is returned due the domain error

◆ qFFMath_Comp_ellint_3()

float qFFMath_Comp_ellint_3 ( float k,
float nu )

Computes the complete elliptic integral of the third kind of k and nu.

Parameters
[in]kElliptic modulus or eccentricity as a floating-point value
[in]nuElliptic characteristic as a floating-point value
Returns
Upon successful completion, the value of the complete elliptic integral of the third kind of k and nu. If the argument is nan, nan is returned. If |k| > 1, nan is returned due the domain error

◆ qFFMath_Cos()

float qFFMath_Cos ( float x)

Computes the cosine of x (measured in radians).

Parameters
[in]xThe floating point value
Returns
If no errors occur, the cosine of x cos(x) in the range [-1 ; +1], is returned. If a domain error occurs, a QFFM_NAN value is returned.

◆ qFFMath_Cosh()

float qFFMath_Cosh ( float x)

Computes hyperbolic cosine of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the hyperbolic cosine of x cosh(x) is returned. If a range error occurs, a QFFM_INFINITY value is returned.

◆ qFFMath_Cyl_bessel_i()

float qFFMath_Cyl_bessel_i ( float nu,
float x )

Computes the regular modified cylindrical Bessel function of nu and x.

Parameters
[in]nuThe order of the function
[in]xThe argument to the function, a floating-point or integer value
Returns
Upon successful completion, the value of the regular modified cylindrical Bessel function of nu and x. If the argument is nan, a nan is returned. If nu is greater or equal than 128, the behavior is implementation-defined.

◆ qFFMath_Cyl_bessel_j()

float qFFMath_Cyl_bessel_j ( float nu,
float x )

Computes the cylindrical Bessel function of the first kind of nu and x.

Parameters
[in]nuThe order of the function
[in]xThe argument to the function, a floating-point or integer value
Returns
Upon successful completion, the value of the irregular modified cylindrical Bessel function (also known as modified Bessel function of the second kind) of nu and x. If the argument is nan, a nan is returned. If nu is greater or equal than 128, the behavior is implementation-defined.

◆ qFFMath_Cyl_bessel_k()

float qFFMath_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.

Parameters
[in]nuThe order of the function
[in]xThe argument to the function, a floating-point or integer value
Returns
Upon successful completion, the value of the irregular modified cylindrical Bessel function (also known as modified Bessel function of the second kind) of nu and x. If the argument is nan, a nan is returned. If nu is greater or equal than 128, the behavior is implementation-defined.

◆ qFFMath_Cyl_neumann()

float qFFMath_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.

Parameters
[in]nuThe order of the function
[in]xThe argument to the function, a floating-point or integer value
Returns
Upon successful completion, the value of the cylindrical Neumann function ( Bessel function of the second kind) of nu and x. If the argument is nan, a nan is returned. If nu is greater or equal than 128, the behavior is implementation-defined.

◆ qFFMath_Ellint_1()

float qFFMath_Ellint_1 ( float k,
float phi )

Computes the incomplete elliptic integral of the first kind of k and phi.

Parameters
[in]kElliptic modulus or eccentricity as a floating-point value
[in]phiJacobi amplitude as a floating-point value given in radians
Returns
Upon successful completion, the value of the incomplete elliptic integral of the first kind of k and phi. If the argument is nan, nan is returned. If |k| > 1, nan is returned due the domain error

◆ qFFMath_Ellint_2()

float qFFMath_Ellint_2 ( float k,
float phi )

Computes the incomplete elliptic integral of the second kind of k and phi.

Parameters
[in]kElliptic modulus or eccentricity as a floating-point value
[in]phiJacobi amplitude as a floating-point value given in radians
Returns
Upon successful completion, the value of the incomplete elliptic integral of the second kind of k and phi. If the argument is nan, nan is returned. If |k| > 1, nan is returned due the domain error

◆ qFFMath_Ellint_3()

float qFFMath_Ellint_3 ( float k,
float nu,
float phi )

Computes the incomplete elliptic integral of the third kind of k, nu and phi.

Parameters
[in]kElliptic modulus or eccentricity as a floating-point value
[in]nuElliptic characteristic as a floating-point value
[in]phiJacobi amplitude as a floating-point value given in radians
Returns
Upon successful completion, the value of the incomplete elliptic integral of the third kind of k, nu and phi. If the argument is nan, nan is returned. If |k| > 1, nan is returned due the domain error

◆ qFFMath_Erf()

float qFFMath_Erf ( float x)

Computes the error function of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, value the error function is returned.

◆ qFFMath_Erfc()

float qFFMath_Erfc ( float x)

Computes the complementary error function of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, value the complementary error function is returned.

◆ qFFMath_Exp()

float qFFMath_Exp ( float x)

Computes the e (Euler's number, 2.7182818) raised to the given power x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the base-e exponential of x e^(x) is returned. If a range error due to overflow occurs, +QFFM_INFINITY is returned.

◆ qFFMath_Exp10()

float qFFMath_Exp10 ( float x)

Computes the value of 10 raised to the power of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the base-e exponential of x 10^(x) is returned. If a range error due to overflow occurs, ± QFFM_INFINITY or NAN is returned.

◆ qFFMath_Exp2()

float qFFMath_Exp2 ( float x)

Computes 2 raised to the given power x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the base-2 exponential of x 2^x is returned. If a range error due to overflow occurs, QFFM_INFINITY is returned.

◆ qFFMath_Expint()

float qFFMath_Expint ( float num)

Computes the Exponential integral of num.

Parameters
[in]numA floating-point value
Returns
Upon successful completion, the value of the exponential integral of num. If the argument is nan, nan is returned. If the argument is ±0, -inf is returned.

◆ qFFMath_Factorial()

float qFFMath_Factorial ( float x)

Return the factorial of the integer part of x.

Note
The argument x needs to be positive
Warning
For x values greater than 14, result is imprecise because of the limited precision of the 32-bit floating point data-type. With x values greater than 35, this function overflows.
Parameters
[in]xThe floating point value
Returns
Upon successful completion, this function shall return the factorial of the integer part of x. If x is non-positive, qFFMath_Factorial() shall return nan. If the correct value would cause overflow, qFFMath_Factorial() shall return +inf.

◆ qFFMath_Floor()

float qFFMath_Floor ( float x)

Computes the largest integer value not greater than x.

Parameters
[in]xThe floating point value
Returns
The largest integer value not greater than x

◆ qFFMath_FPClassify()

int qFFMath_FPClassify ( 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:

◆ qFFMath_Frac()

float qFFMath_Frac ( float x)

Obtain the fractional part of x.

Parameters
[in]xThe floating point value
Returns
The fractional part of x

◆ qFFMath_Hermite()

float qFFMath_Hermite ( size_t n,
float x )

Computes the (physicist's) Hermite polynomials of the degree n and argument x.

Parameters
[in]nThe degree of the polynomial
[in]xThe argument, a floating-point value
Returns
Upon successful completion, the value of order-n Hermite polynomial of x. If the argument is nan, nan is returned. If n>=128, the behavior is implementation-defined.

◆ qFFMath_Hypot()

float qFFMath_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.

Parameters
[in]xThe floating point value
[in]yThe floating point value
Returns
If no errors occur, the hypotenuse of a right-angled triangle, sqrt(x^2 + y^2), is returned. If a range error due to overflow occurs, +QFFM_INFINITY is returned. If a range error due to underflow occurs, the correct result (after rounding) is returned.

◆ qFFMath_InCircle()

bool qFFMath_InCircle ( const float x,
const float y,
const float cx,
const float cy,
const float r )

Determines if the point at ( x, y) is inside the circle with radius r located at cx and cy.

Parameters
[in]xPoint x-coordinate
[in]yPoint y-coordinate
[in]cxX-location of the circle
[in]cyY-location of the circle
[in]rRadio of the circle
Returns
true when the given point is inside the circle

◆ qFFMath_InPolygon()

bool qFFMath_InPolygon ( const float x,
const float y,
const float *const px,
const float *const py,
const size_t p )

Determines if the point at ( x, y ) is inside the polygon given by the set of points on px and py.

Parameters
[in]xPoint x-coordinate
[in]yPoint y-coordinate
[in]pxx-coordinate points of the polygon
[in]pyy-coordinate points of the polygon
[in]pNumber of points that represent the polygon
Returns
true when the given point is inside the polygon

◆ qFFMath_InRangeCoerce()

bool qFFMath_InRangeCoerce ( float *const x,
const float lowerL,
const float upperL )

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.

Parameters
[in,out]xInput
[in]lowerLLower limit.
[in]upperLUpper limit.
Returns
true when the value falls within the specified range, otherwise false

◆ qFFMath_IsFinite()

bool qFFMath_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.

Parameters
[in]xThe number you want to test.
Returns
true if x has a finite value, false otherwise

◆ qFFMath_IsInf()

bool qFFMath_IsInf ( const float x)

Determine if x is Infinity.

Parameters
[in]xThe number you want to test.
Returns
true if the value of x is ±Infinity, otherwise returns false.

◆ qFFMath_IsNaN()

bool qFFMath_IsNaN ( const float x)

Determine if x is Not-A-Number (NaN) aka QFFM_NAN.

Parameters
[in]xThe number you want to test.
Returns
true if the value of x is (NaN) aka QFFM_NAN, otherwise returns false.

◆ qFFMath_IsNormal()

bool qFFMath_IsNormal ( const float x)

Determines if the given floating point number x is normal, i.e. is neither zero, subnormal, infinite, or NaN.

Parameters
[in]xThe number you want to test.
Returns
true if x has a normal value, false otherwise

◆ qFFMath_Laguerre()

float qFFMath_Laguerre ( size_t n,
float x )

Computes the non-associated Laguerre polynomials of the degree n, and argument x.

Parameters
[in]nThe degree of the polynomial, an unsigned integer value
[in]xThe argument, a floating-point or integer value
Returns
Upon successful completion, the value of the non-associated Laguerre polynomial of x shall be returned. If the argument is nan, a nan is returned. If x is negative, nan is returned. If n is greater or equal than 128, the behavior is implementation-defined.

◆ qFFMath_LDExp()

float qFFMath_LDExp ( float x,
int32_t pw2 )

Multiplies a floating point value x by the number 2 raised to the pw2 power.

Parameters
[in]xThe floating point value
[in]pw2Integer value
Returns
If no errors occur, x multiplied by 2 to the power of pw2 x×2^pwd is returned. If a range error due to overflow occurs, ± QFFM_INFINITY is returned. If a range error due to underflow occurs, the correct result (after rounding) is returned.

◆ qFFMath_Legendre()

float qFFMath_Legendre ( size_t n,
float x )

Computes the unassociated Legendre polynomials of the degree n, and argument x.

Parameters
[in]nThe degree of the polynomial, an unsigned integer value
[in]xThe argument, a floating-point or integer value
Returns
Upon successful completion, the value of the unassociated Legendre polynomial of x shall be returned. If the argument is nan, a nan is returned. The function is not required to be defined for |x| > 1 . If n is greater or equal than 128, the behavior is implementation-defined.

◆ qFFMath_Lerp()

float qFFMath_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.

Parameters
aA floating point value
bA floating point value
tA floating point value
Returns
Return a+t*(b-a) . When both a and b are finite, the following properties are guaranteed: If t==0, the result is equal to a. If t==1, the result is equal to b. If t>=0 and t<=1, the result is finite. If t is finite and a==b, the result is equal to a. If t is finite or (a-b)!=0 with t infinity, the result is not nan. Let CMP(x,y) be 1 if x>y, -1 if x<y, and 0 otherwise. For any t1 and t2, the product of: CMP(lerp(a,b,t2), lerp(a,b,t1), CMP(t2,t1) , and CMP(b,a) is non-negative. (That is, lerp() is monotonic.).

◆ qFFMath_LGamma()

float qFFMath_LGamma ( float x)

Computes the natural logarithm of the absolute value of the gamma function of x.

Note
The argument x need not be a non-positive integer ( is defined over the reals, except the non-positive integers).
Parameters
[in]xThe floating point value
Returns
Upon successful completion, this function shall return the logarithmic gamma of x. If x is a non-positive integer, qFFMath_TGamma() shall return +inf. If the correct value would cause overflow, qFFMath_TGamma() shall return ±inf having the same sign as the correct value. If x is nan, a nan shall be returned. If x is 1 or 2, +0 shall be returned. If x is ±inf, +inf shall be returned.

◆ qFFMath_Log()

float qFFMath_Log ( float x)

Computes the natural (base e) logarithm of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the natural (base-e) logarithm of x ln(x) is returned. If a domain error occurs, a QFFM_NAN value is returned. If a pole error occurs, -QFFM_INFINITY is returned.

◆ qFFMath_Log10()

float qFFMath_Log10 ( float x)

Computes the common (base-10) logarithm of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the common (base-10) logarithm of x log_10(x) is returned. If a domain error occurs, a QFFM_NAN value is returned. If a pole error occurs, -QFFM_INFINITY is returned.

◆ qFFMath_Log2()

float qFFMath_Log2 ( float x)

Computes the base 2 logarithm of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the base-2 logarithm of x log_2(x) is returned. If a domain error occurs, a QFFM_NAN value is returned. If a pole error occurs, -QFFM_INFINITY is returned.

◆ qFFMath_Map()

float qFFMath_Map ( const float x,
const float xMin,
const float xMax,
const float yMin,
const float yMax )

Scales the given input x in value range given by xMin and xMax to value range specified by the yMin and yMax.

Parameters
[in]xInput
[in]xMinInput minimum value for range
[in]xMaxInput maximum value for range
[in]yMinOutput minimum value for range
[in]yMaxOutput maximum value for range
Returns
The scaled value in range yMin and yMax.

◆ qFFMath_Max()

float qFFMath_Max ( float x,
float y )

Returns the larger of two floating point arguments.

Parameters
[in]xThe floating point value
[in]yThe floating point value
Returns
If successful, returns the larger of two floating point values

◆ qFFMath_Midpoint()

float qFFMath_Midpoint ( float a,
float b )

Computes the midpoint of the floating-points a and b.

Parameters
aA floating point value
bA floating point value
Returns
Half the sum of a and b. No overflow occurs. A at most one inexact operation occurs.

◆ qFFMath_Min()

float qFFMath_Min ( float x,
float y )

Returns the smaller of two floating point arguments.

Parameters
[in]xThe floating point value
[in]yThe floating point value
Returns
If successful, returns the smaller of two floating point values

◆ qFFMath_Mod()

float qFFMath_Mod ( float x,
float y )

Computes the floating-point remainder of the division operation x/y.

Parameters
[in]xThe floating point value
[in]yThe floating point value
Returns
If successful, returns the floating-point remainder of the division x/y. If a domain error occurs, a QFFM_NAN value is returned.

◆ qFFMath_NextAfter()

float qFFMath_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.

Parameters
[in]xThe floating point value
[in]yThe floating point value
Returns
If no errors occur, the next representable value of x in the direction of y is returned. If x equals y, then yis returned. If a range error due to overflow occurs, ± QFFM_INFINITY is returned (with the same sign as x). If a range error occurs due to underflow, the correct result is returned.

◆ qFFMath_Normalize()

float qFFMath_Normalize ( const float x,
const float xMin,
const float xMax )

Normalize the given input x in value range given by xMin and xMax to value range between 0 and 1.

Parameters
[in]xInput
[in]xMinInput minimum value for range
[in]xMaxInput maximum value for range
Returns
The scaled value in range [0 - 1].

◆ qFFMath_Pow()

float qFFMath_Pow ( float b,
float e )

Computes the value of b raised to the power e.

Parameters
[in]bBase as floating point value
[in]eExponent as floating point value
Returns
If no errors occur, b raised to the power of e b^e is returned. If a domain error occurs, a QFFM_NAN value is returned. If a pole error or a range error due to overflow occurs, ± QFFM_INFINITY is returned.

◆ qFFMath_RCbrt()

float qFFMath_RCbrt ( float x)

Computes the reciprocal cubic-root of x denoted as 1/cbrt(x)

Parameters
[in]xThe floating point value
Returns
If no errors occur, the reciprocal cubic root of x, is returned. If a domain error occurs QFFM_NAN is returned

◆ qFFMath_Recip()

float qFFMath_Recip ( float x)

Computes the multiplicative inverse or reciprocal for the value x, denoted by 1/x or x^(−1)

Parameters
[in]xThe floating point value
Returns
The reciprocal value of x

◆ qFFMath_Remainder()

float qFFMath_Remainder ( float x,
float y )

Computes the IEEE remainder of the floating point division operation x/y.

Parameters
[in]xThe floating point value
[in]yThe floating point value
Returns
If successful, returns the IEEE floating-point remainder of the division x/y. If a domain error occurs, a QFFM_NAN value is returned.

◆ qFFMath_RExp()

float qFFMath_RExp ( float x,
int32_t * pw2 )

Decomposes given floating point value x into a normalized fraction and an integral power of two.

Parameters
[in]xThe floating point value
[in]pw2Pointer to integer value to store the exponent to
Returns
If x is zero, returns zero and stores zero in pw2. Otherwise (if x is not zero), if no errors occur, returns the value y in the range (-1;-0.5], [0.5; 1) and stores an integer value in pw2 such that y×2^(pw2) = x . If the value to be stored in pw2 is outside the range of an int, the behavior is unspecified. If x is not a floating-point number, the behavior is unspecified.

◆ qFFMath_Riemann_zeta()

float qFFMath_Riemann_zeta ( float s)

Computes the Riemann zeta function of s.

Parameters
[in]sA floating-point value
Returns
Upon successful completion, the value of the Riemann zeta function of s. If the argument is nan, nan is returned.

◆ qFFMath_Round()

float qFFMath_Round ( float x)

Computes the nearest integer value to x (in floating-point format), rounding halfway cases away from zero.

Parameters
[in]xThe floating point value
Returns
The nearest integer value to x, rounding halfway cases away from zero

◆ qFFMath_RSqrt()

float qFFMath_RSqrt ( float x)

Computes the reciprocal square-root of x denoted as 1/sqrt(x)

Parameters
[in]xThe floating point value
Returns
If no errors occur, the reciprocal square root of x, is returned. If a domain error occurs QFFM_NAN is returned

◆ qFFMath_Sin()

float qFFMath_Sin ( float x)

Computes the sine of x (measured in radians).

Parameters
[in]xThe floating point value
Returns
If no errors occur, the sine of x sin(x) in the range [-1 ; +1], is returned. If a domain error occurs, a QFFM_NAN value is returned.

◆ qFFMath_Sinh()

float qFFMath_Sinh ( float x)

Computes hyperbolic sine of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the hyperbolic sine of x sinh(x) is returned. If a range error occurs, a ± QFFM_INFINITY is value is returned.

◆ qFFMath_Sph_bessel()

float qFFMath_Sph_bessel ( size_t n,
float x )

Computes the spherical Bessel function of the first kind n, and x.

Parameters
[in]nThe order of the function
[in]xThe argument to the function, a floating-point or integer value
Returns
Upon successful completion, the value of the spherical Bessel function of the first kind of n and x. If the argument is nan, a nan is returned. If n is greater or equal than 128, the behavior is implementation-defined.

◆ qFFMath_Sph_legendre()

float qFFMath_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

Parameters
[in]lThe degree
[in]mThe order
[in]thetaPolar angle, measured in radians
Returns
Upon successful completion, the value of the spherical associated Legendre function (that is, spherical harmonic with sigma = 0) of l, m, and theta. If the argument theta is nan, a nan is returned. If l is greater or equal than 128, the behavior is implementation-defined.

◆ qFFMath_Sph_neumann()

float qFFMath_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.

Parameters
[in]nThe order of the function
[in]xThe argument to the function, a floating-point or integer value
Returns
Upon successful completion, the value of the spherical Bessel function of the second kind (spherical Neumann function) of n and x. If the argument is nan, a nan is returned. If n is greater or equal than 128, the behavior is implementation-defined.

◆ qFFMath_Sqrt()

float qFFMath_Sqrt ( float x)

Computes the square-root of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, square root of x, is returned. If a domain error occurs QFFM_NAN is returned

◆ qFFMath_Tan()

float qFFMath_Tan ( float x)

Computes the tangent of x (measured in radians).

Parameters
[in]xThe floating point value
Returns
If no errors occur, the tangent of x tan(x) is returned. If a domain error occurs, a QFFM_NAN value is returned.

◆ qFFMath_Tanh()

float qFFMath_Tanh ( float x)

Computes hyperbolic tangent of x.

Parameters
[in]xThe floating point value
Returns
If no errors occur, the hyperbolic tangent of x tanh(x) is returned.

◆ qFFMath_TGamma()

float qFFMath_TGamma ( float x)

Computes the gamma function of x.

Parameters
[in]xThe floating point value
Returns
Upon successful completion, this function shall return Gamma(x). If x is a negative integer, a inf value shall be returned. If the correct value would cause overflow, qFFMath_TGamma() shall return ±Inf, with the same sign as the correct value of the function. If x is nan, a nan shall be returned. If x is +inf, x shall be returned. If x is ±0, tgamma() shall return ±Inf. If x is -inf, a nan value shall be returned. For IEEE Std 754-1985 float, overflow happens when 0 < x < 1/FLT_MAX, and 171.7 < x.

◆ qFFMath_Trunc()

float qFFMath_Trunc ( float x)

Computes the nearest integer not greater in magnitude than x.

Parameters
[in]xThe floating point value
Returns
The nearest integer value not greater in magnitude than x (in other words, x rounded towards zero)

◆ qFFMath_WrapTo180()

float qFFMath_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.

Parameters
xThe angle in degrees
Returns
The angle x wrapped to the [-180, 180] interval

◆ qFFMath_WrapTo2Pi()

float qFFMath_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.

Parameters
xThe angle in radians
Returns
The angle x wrapped to the [0, 2*pi] interval

◆ qFFMath_WrapTo360()

float qFFMath_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.

Parameters
xThe angle in degrees
Returns
The angle x wrapped to the [0, 360] interval

◆ qFFMath_WrapToPi()

float qFFMath_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.

Parameters
xThe angle in radians
Returns
The angle x wrapped to the [-pi, pi] interval