Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qffmath.h
1
10#ifndef QFFMATH_H
11#define QFFMATH_H
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17 #include <stdint.h>
18 #include <stdlib.h>
19 #include <stdbool.h>
20
21#ifdef QLIBS_USE_STD_MATH
23 #include <math.h>
24 #define QLIB_ABS fabsf
25 #define QLIB_COS cosf
26 #define QLIB_POW powf
27 #define QLIB_EXP expf
28 #define QLIB_LOG logf
29 #define QLIB_SQRT sqrtf
30 #define QLIB_ISNAN isnan
31 #define QLIB_ISINF isinf
32 #define QLIB_MAX fmaxf
33 #define QLIB_MIN fminf
34 #define QLIB_NAN NAN
35 #define QLIB_MOD fmodf
36 #define QLIB_ROUND roundf
38#else
40 #define QLIB_ABS qFFMath_Abs
41 #define QLIB_COS qFFMath_Cos
42 #define QLIB_POW qFFMath_Pow
43 #define QLIB_EXP qFFMath_Exp
44 #define QLIB_LOG qFFMath_Log
45 #define QLIB_SQRT qFFMath_Sqrt
46 #define QLIB_ISNAN qFFMath_IsNaN
47 #define QLIB_ISINF qFFMath_IsInf
48 #define QLIB_MAX qFFMath_Max
49 #define QLIB_MIN qFFMath_Min
50 #define QLIB_NAN QFFM_NAN
51 #define QLIB_FMOD qFFMath_Mod
52 #define QLIB_ROUND qFFMath_Round
62 float _qFFMath_GetAbnormal( const int i ); //skipcq: CXX-E2000
66 #define QFFM_E ( 2.7182818284590452354F )
68 #define QFFM_LOG2E ( 1.4426950408889634074F )
70 #define QFFM_LOG10E ( 0.43429448190325182765F )
72 #define QFFM_LN2 ( 0.69314718055994530942F )
74 #define QFFM_LN10 ( 2.30258509299404568402F )
76 #define QFFM_PI ( 3.14159265358979323846F )
78 #define QFFM_PI_2 ( 1.57079632679489661923F )
80 #define QFFM_PI_4 ( 0.78539816339744830962F )
82 #define QFFM_1_PI ( 0.31830988618379067154F )
84 #define QFFM_2_PI ( 0.63661977236758134308F )
86 #define QFFM_2_SQRTPI ( 1.12837916709551257390F )
88 #define QFFM_SQRT2 ( 1.41421356237309504880F )
90 #define QFFM_SQRT1_2 ( 0.70710678118654752440F )
92 #define QFFM_LN_SQRT_2PI ( 0.918938533204672669540968854562379419F )
93
95 #define QFFM_GAMMA_E ( 0.577215664901532860606512090082402431F )
97 #define QFFM_2PI ( 6.283185307179586231995926937088370323F )
99 #define QFFM_LN_PI ( 1.144729885849400163877476188645232468F )
100
102 #define QFFM_MAXFLOAT ( 3.40282347e+38F )
104 #define QFFM_INFINITY _qFFMath_GetAbnormal( 0 )
106 #define QFFM_NAN _qFFMath_GetAbnormal( 1 )
107
109 #define QFFM_FP_ZERO ( 0 )
110
112 #define QFFM_FP_SUBNORMAL ( 1 )
113
116 #define QFFM_FP_NORMAL ( 2 )
117
120 #define QFFM_FP_INFINITE ( 3 )
121
123 #define QFFM_FP_NAN ( 4 )
124
141 int qFFMath_FPClassify( const float f );
142
149 bool qFFMath_IsNaN( const float x );
150
156 bool qFFMath_IsInf( const float x );
157
164 bool qFFMath_IsFinite( const float x );
165
172 bool qFFMath_IsNormal( const float x );
173
175 bool qFFMath_IsEqual( const float a,
176 const float b );
177
178 bool qFFMath_IsAlmostEqual( const float a,
179 const float b,
180 const float tol );
188 float qFFMath_Abs( float x );
189
196 float qFFMath_Recip( float x );
197
204 float qFFMath_Sqrt( float x );
205
213 float qFFMath_RSqrt( float x );
214
221 float qFFMath_Cbrt( float x );
222
230 float qFFMath_RCbrt( float x );
231
239 float qFFMath_Round( float x );
240
246 float qFFMath_Floor( float x );
247
253 float qFFMath_Ceil( float x );
254
261 float qFFMath_Trunc( float x );
262
268 float qFFMath_Frac( float x );
269
278 float qFFMath_Remainder( float x,
279 float y );
280
289 float qFFMath_Mod( float x,
290 float y );
291
299 float qFFMath_Sin( float x );
300
308 float qFFMath_Cos( float x );
309
316 float qFFMath_Tan( float x );
317
325 float qFFMath_ASin( float x );
326
334 float qFFMath_ACos( float x );
335
343 float qFFMath_ATan( float x );
344
354 float qFFMath_ATan2( float y,
355 float x );
356
364 float qFFMath_Exp2( float x );
365
373 float qFFMath_Log2( float x );
374
383 float qFFMath_Exp( float x );
384
392 float qFFMath_Exp10( float x );
393
401 float qFFMath_Log( float x );
402
410 float qFFMath_Log10( float x );
411
421 float qFFMath_Pow( float b,
422 float e );
423
431 float qFFMath_Sinh( float x );
432
439 float qFFMath_Cosh( float x );
440
447 float qFFMath_Tanh( float x );
448
455 float qFFMath_ASinh( float x );
456
463 float qFFMath_ACosh( float x );
464
472 float qFFMath_ATanh( float x );
473
481 float qFFMath_WrapToPi( float x );
482
490 float qFFMath_WrapTo2Pi( float x );
491
499 float qFFMath_WrapTo180( float x );
500
508 float qFFMath_WrapTo360( float x );
509
515 float qFFMath_Erf( float x );
516
523 float qFFMath_Erfc( float x );
524
531 float qFFMath_Max( float x,
532 float y );
533
540 float qFFMath_Min( float x,
541 float y );
542
555 float qFFMath_RExp( float x,
556 int32_t *pw2 );
557
568 float qFFMath_LDExp( float x,
569 int32_t pw2 );
570
582 float qFFMath_Hypot( float x,
583 float y );
584
596 float qFFMath_NextAfter( float x,
597 float y );
598
606 float qFFMath_Midpoint( float a,
607 float b );
608
630 float qFFMath_Lerp( float a,
631 float b,
632 float t );
633
642 float qFFMath_Normalize( const float x,
643 const float xMin,
644 const float xMax );
645
656 float qFFMath_Map( const float x,
657 const float xMin,
658 const float xMax,
659 const float yMin,
660 const float yMax );
661
672 bool qFFMath_InRangeCoerce( float * const x,
673 const float lowerL,
674 const float upperL );
675
686 bool qFFMath_InPolygon( const float x,
687 const float y,
688 const float * const px,
689 const float * const py,
690 const size_t p );
691
702 bool qFFMath_InCircle( const float x,
703 const float y,
704 const float cx,
705 const float cy,
706 const float r );
707
722 float qFFMath_TGamma( float x );
723
738 float qFFMath_LGamma( float x );
739
752 float qFFMath_Factorial( float x );
753
765 float qFFMath_Assoc_laguerre( size_t n,
766 size_t m,
767 float x );
768
780 float qFFMath_Assoc_legendre( size_t n,
781 size_t m,
782 float x );
783
793 float qFFMath_Beta( float x,
794 float y );
795
803 float qFFMath_Comp_ellint_1( float k );
804
812 float qFFMath_Comp_ellint_2( float k );
813
823 float qFFMath_Comp_ellint_3( float k,
824 float nu );
825
835 float qFFMath_Ellint_1( float k,
836 float phi );
837
847 float qFFMath_Ellint_2( float k,
848 float phi );
849
860 float qFFMath_Ellint_3( float k,
861 float nu,
862 float phi );
863
871 float qFFMath_Expint( float num );
872
882 float qFFMath_Hermite( size_t n,
883 float x );
884
895 float qFFMath_Laguerre( size_t n,
896 float x );
897
908 float qFFMath_Legendre( size_t n,
909 float x );
910
917 float qFFMath_Riemann_zeta( float s );
918
929 float qFFMath_Sph_bessel( size_t n,
930 float x );
931
943 float qFFMath_Sph_neumann( size_t n,
944 float x );
945
956 float qFFMath_Cyl_bessel_i( float nu,
957 float x );
958
969 float qFFMath_Cyl_bessel_j( float nu,
970 float x );
971
983 float qFFMath_Cyl_bessel_k( float nu,
984 float x );
985
996 float qFFMath_Cyl_neumann( float nu,
997 float x );
998
1010 float qFFMath_Sph_legendre( size_t l,
1011 size_t m,
1012 float theta );
1013#endif /*#ifdef QLIBS_USE_STD_MATH*/
1014
1017#ifdef __cplusplus
1018}
1019#endif
1020
1021#endif
float qFFMath_Trunc(float x)
Computes the nearest integer not greater in magnitude than x.
Definition qffmath.c:382
bool qFFMath_IsNaN(const float x)
Determine if x is Not-A-Number (NaN) aka QFFM_NAN.
Definition qffmath.c:125
float qFFMath_Tanh(float x)
Computes hyperbolic tangent of x.
Definition qffmath.c:613
float qFFMath_Hermite(size_t n, float x)
Computes the (physicist's) Hermite polynomials of the degree n and argument x.
Definition qffmath.c:2074
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.
Definition qffmath.c:915
float qFFMath_Log10(float x)
Computes the common (base-10) logarithm of x.
Definition qffmath.c:588
float qFFMath_NextAfter(float x, float y)
Returns the next representable value of x in the direction of y. If x equals to y,...
Definition qffmath.c:758
float qFFMath_Ellint_1(float k, float phi)
Computes the incomplete elliptic integral of the first kind of k and phi.
Definition qffmath.c:1827
float qFFMath_Legendre(size_t n, float x)
Computes the unassociated Legendre polynomials of the degree n, and argument x.
Definition qffmath.c:2120
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.
Definition qffmath.c:1451
float qFFMath_Cyl_neumann(float nu, float x)
Computes the cylindrical Neumann function ( also known as Bessel function of the second kind or Weber...
Definition qffmath.c:2866
float qFFMath_Sinh(float x)
Computes hyperbolic sine of x.
Definition qffmath.c:599
float qFFMath_RSqrt(float x)
Computes the reciprocal square-root of x denoted as 1/sqrt(x)
Definition qffmath.c:202
float qFFMath_Cyl_bessel_i(float nu, float x)
Computes the regular modified cylindrical Bessel function of nu and x.
Definition qffmath.c:2756
float qFFMath_ATan2(float y, float x)
Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant.
Definition qffmath.c:479
float qFFMath_Cosh(float x)
Computes hyperbolic cosine of x.
Definition qffmath.c:606
float qFFMath_ACosh(float x)
Computes the inverse hyperbolic cosine of x.
Definition qffmath.c:624
float qFFMath_TGamma(float x)
Computes the gamma function of x.
Definition qffmath.c:925
float qFFMath_ASinh(float x)
Computes the inverse hyperbolic sine of x.
Definition qffmath.c:619
float qFFMath_Comp_ellint_1(float k)
Computes the complete elliptic integral of the first kind of k.
Definition qffmath.c:1770
float qFFMath_Exp10(float x)
Computes the value of 10 raised to the power of x.
Definition qffmath.c:578
float qFFMath_Mod(float x, float y)
Computes the floating-point remainder of the division operation x/y.
Definition qffmath.c:414
float qFFMath_Sph_bessel(size_t n, float x)
Computes the spherical Bessel function of the first kind n, and x.
Definition qffmath.c:2514
float qFFMath_Log(float x)
Computes the natural (base e) logarithm of x.
Definition qffmath.c:583
float qFFMath_Min(float x, float y)
Returns the smaller of two floating point arguments.
Definition qffmath.c:681
float qFFMath_Riemann_zeta(float s)
Computes the Riemann zeta function of s.
Definition qffmath.c:2240
float qFFMath_RExp(float x, int32_t *pw2)
Decomposes given floating point value x into a normalized fraction and an integral power of two.
Definition qffmath.c:687
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
Definition qffmath.c:2889
float qFFMath_Sin(float x)
Computes the sine of x (measured in radians).
Definition qffmath.c:421
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 -18...
Definition qffmath.c:645
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....
Definition qffmath.c:650
float qFFMath_Remainder(float x, float y)
Computes the IEEE remainder of the floating point division operation x/y.
Definition qffmath.c:408
int qFFMath_FPClassify(const float f)
Categorizes the floating-point number x. This function determines whether its argument is a normal fl...
Definition qffmath.c:97
float qFFMath_Recip(float x)
Computes the multiplicative inverse or reciprocal for the value x, denoted by 1/x or x^(−1)
Definition qffmath.c:163
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 limi...
Definition qffmath.c:856
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.
Definition qffmath.c:1367
float qFFMath_Tan(float x)
Computes the tangent of x (measured in radians).
Definition qffmath.c:453
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....
Definition qffmath.c:635
float qFFMath_Pow(float b, float e)
Computes the value of b raised to the power e.
Definition qffmath.c:593
float qFFMath_Ceil(float x)
Computes the smallest integer value not less than x.
Definition qffmath.c:340
float qFFMath_Frac(float x)
Obtain the fractional part of x.
Definition qffmath.c:403
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.
Definition qffmath.c:840
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...
Definition qffmath.c:727
float qFFMath_Midpoint(float a, float b)
Computes the midpoint of the floating-points a and b.
Definition qffmath.c:794
bool qFFMath_IsNormal(const float x)
Determines if the given floating point number x is normal, i.e. is neither zero, subnormal,...
Definition qffmath.c:140
float qFFMath_Log2(float x)
Computes the base 2 logarithm of x.
Definition qffmath.c:524
float qFFMath_Ellint_3(float k, float nu, float phi)
Computes the incomplete elliptic integral of the third kind of k, nu and phi.
Definition qffmath.c:1885
float qFFMath_ACos(float x)
Computes the principal value of the arc cosine of x.
Definition qffmath.c:464
float qFFMath_Beta(float x, float y)
Computes the Beta function of x and y.
Definition qffmath.c:1509
float qFFMath_Exp2(float x)
Computes 2 raised to the given power x.
Definition qffmath.c:490
float qFFMath_RCbrt(float x)
Computes the reciprocal cubic-root of x denoted as 1/cbrt(x)
Definition qffmath.c:257
float qFFMath_Sph_neumann(size_t n, float x)
Computes the spherical Bessel function of the second kind also known as the spherical Neumann functio...
Definition qffmath.c:2535
float qFFMath_Cyl_bessel_j(float nu, float x)
Computes the cylindrical Bessel function of the first kind of nu and x.
Definition qffmath.c:2821
float qFFMath_Factorial(float x)
Return the factorial of the integer part of x.
Definition qffmath.c:1230
float qFFMath_Comp_ellint_2(float k)
Computes the complete elliptic integral of the second kind of k.
Definition qffmath.c:1784
float qFFMath_ATan(float x)
Computes the principal value of the arc tangent of x.
Definition qffmath.c:469
float qFFMath_Erfc(float x)
Computes the complementary error function of x.
Definition qffmath.c:670
float qFFMath_Expint(float num)
Computes the Exponential integral of num.
Definition qffmath.c:2069
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.
Definition qffmath.c:880
float qFFMath_Cyl_bessel_k(float nu, float x)
Computes the irregular modified cylindrical Bessel function (also known as modified Bessel function o...
Definition qffmath.c:2848
float qFFMath_Abs(float x)
Computes the absolute value of a floating point value x.
Definition qffmath.c:158
float qFFMath_LDExp(float x, int32_t pw2)
Multiplies a floating point value x by the number 2 raised to the pw2 power.
Definition qffmath.c:707
float qFFMath_Cos(float x)
Computes the cosine of x (measured in radians).
Definition qffmath.c:438
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 ...
Definition qffmath.c:640
bool qFFMath_IsInf(const float x)
Determine if x is Infinity.
Definition qffmath.c:130
float qFFMath_ATanh(float x)
Computes the inverse hyperbolic tangent of x.
Definition qffmath.c:630
float qFFMath_Exp(float x)
Computes the e (Euler's number, 2.7182818) raised to the given power x.
Definition qffmath.c:573
float qFFMath_Floor(float x)
Computes the largest integer value not greater than x.
Definition qffmath.c:296
float qFFMath_ASin(float x)
Computes the principal value of the arc sine of x.
Definition qffmath.c:458
float qFFMath_Round(float x)
Computes the nearest integer value to x (in floating-point format), rounding halfway cases away from ...
Definition qffmath.c:263
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 a...
Definition qffmath.c:847
float qFFMath_Sqrt(float x)
Computes the square-root of x.
Definition qffmath.c:177
float qFFMath_Max(float x, float y)
Returns the larger of two floating point arguments.
Definition qffmath.c:675
bool qFFMath_IsFinite(const float x)
Determines if the given floating point number x has finite value i.e. it is normal,...
Definition qffmath.c:135
float qFFMath_Lerp(float a, float b, float t)
Computes the linear interpolation between a and b, if the parameter t is inside [0,...
Definition qffmath.c:819
float qFFMath_Erf(float x)
Computes the error function of x.
Definition qffmath.c:655
float qFFMath_Ellint_2(float k, float phi)
Computes the incomplete elliptic integral of the second kind of k and phi.
Definition qffmath.c:1852
float qFFMath_LGamma(float x)
Computes the natural logarithm of the absolute value of the gamma function of x.
Definition qffmath.c:1189
float qFFMath_Laguerre(size_t n, float x)
Computes the non-associated Laguerre polynomials of the degree n, and argument x.
Definition qffmath.c:2114
float qFFMath_Cbrt(float x)
Computes the cubic-root of x.
Definition qffmath.c:252
float qFFMath_Comp_ellint_3(float k, float nu)
Computes the complete elliptic integral of the third kind of k and nu.
Definition qffmath.c:1806