Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qffmath.h
1
9
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 ( qFFMath_NotANumber[ 0 ] )
51 #define QLIB_FMOD qFFMath_Mod
52 #define QLIB_ROUND qFFMath_Round
54
60
62 #define QFFM_E ( 2.7182818284590452354F )
64 #define QFFM_LOG2E ( 1.4426950408889634074F )
66 #define QFFM_LOG10E ( 0.43429448190325182765F )
68 #define QFFM_LN2 ( 0.69314718055994530942F )
70 #define QFFM_LN10 ( 2.30258509299404568402F )
72 #define QFFM_PI ( 3.14159265358979323846F )
74 #define QFFM_PI_2 ( 1.57079632679489661923F )
76 #define QFFM_PI_4 ( 0.78539816339744830962F )
78 #define QFFM_1_PI ( 0.31830988618379067154F )
80 #define QFFM_2_PI ( 0.63661977236758134308F )
82 #define QFFM_2_SQRTPI ( 1.12837916709551257390F )
84 #define QFFM_SQRT2 ( 1.41421356237309504880F )
86 #define QFFM_SQRT1_2 ( 0.70710678118654752440F )
88 #define QFFM_LN_SQRT_2PI ( 0.918938533204672669540968854562379419F )
89
91 #define QFFM_GAMMA_E ( 0.577215664901532860606512090082402431F )
93 #define QFFM_2PI ( 6.283185307179586231995926937088370323F )
95 #define QFFM_LN_PI ( 1.144729885849400163877476188645232468F )
96
98 #define QFFM_MAXFLOAT ( 3.40282347e+38F )
100 #define QFFM_INFINITY ( qFFMath_Infinity[ 0 ] )
102 #define QFFM_NAN ( qFFMath_NotANumber[ 0 ] )
103
105 #define QFFM_FP_ZERO ( 0 )
106
108 #define QFFM_FP_SUBNORMAL ( 1 )
109
112 #define QFFM_FP_NORMAL ( 2 )
113
116 #define QFFM_FP_INFINITE ( 3 )
117
119 #define QFFM_FP_NAN ( 4 )
120
137 int qFFMath_FPClassify( const float f );
138
145 bool qFFMath_IsNaN( const float x );
146
152 bool qFFMath_IsInf( const float x );
153
160 bool qFFMath_IsFinite( const float x );
161
168 bool qFFMath_IsNormal( const float x );
169
171 bool qFFMath_IsEqual( const float a,
172 const float b );
173
174 bool qFFMath_IsAlmostEqual( const float a,
175 const float b,
176 const float tol );
178
184 float qFFMath_Abs( float x );
185
192 float qFFMath_Recip( float x );
193
200 float qFFMath_Sqrt( float x );
201
209 float qFFMath_RSqrt( float x );
210
217 float qFFMath_Cbrt( float x );
218
226 float qFFMath_RCbrt( float x );
227
235 float qFFMath_Round( float x );
236
242 float qFFMath_Floor( float x );
243
249 float qFFMath_Ceil( float x );
250
257 float qFFMath_Trunc( float x );
258
264 float qFFMath_Frac( float x );
265
274 float qFFMath_Remainder( float x,
275 float y );
276
285 float qFFMath_Mod( float x,
286 float y );
287
295 float qFFMath_Sin( float x );
296
304 float qFFMath_Cos( float x );
305
312 float qFFMath_Tan( float x );
313
321 float qFFMath_ASin( float x );
322
330 float qFFMath_ACos( float x );
331
339 float qFFMath_ATan( float x );
340
350 float qFFMath_ATan2( float y,
351 float x );
352
360 float qFFMath_Exp2( float x );
361
369 float qFFMath_Log2( float x );
370
379 float qFFMath_Exp( float x );
380
388 float qFFMath_Exp10( float x );
389
397 float qFFMath_Log( float x );
398
406 float qFFMath_Log10( float x );
407
417 float qFFMath_Pow( float b,
418 float e );
419
427 float qFFMath_Sinh( float x );
428
435 float qFFMath_Cosh( float x );
436
443 float qFFMath_Tanh( float x );
444
451 float qFFMath_ASinh( float x );
452
459 float qFFMath_ACosh( float x );
460
468 float qFFMath_ATanh( float x );
469
477 float qFFMath_WrapToPi( float x );
478
486 float qFFMath_WrapTo2Pi( float x );
487
495 float qFFMath_WrapTo180( float x );
496
504 float qFFMath_WrapTo360( float x );
505
511 float qFFMath_Erf( float x );
512
519 float qFFMath_Erfc( float x );
520
527 float qFFMath_Max( float x,
528 float y );
529
536 float qFFMath_Min( float x,
537 float y );
538
551 float qFFMath_RExp( float x,
552 int32_t *pw2 );
553
564 float qFFMath_LDExp( float x,
565 int32_t pw2 );
566
578 float qFFMath_Hypot( float x,
579 float y );
580
592 float qFFMath_NextAfter( float x,
593 float y );
594
602 float qFFMath_Midpoint( float a,
603 float b );
604
626 float qFFMath_Lerp( float a,
627 float b,
628 float t );
629
638 float qFFMath_Normalize( const float x,
639 const float xMin,
640 const float xMax );
641
652 float qFFMath_Map( const float x,
653 const float xMin,
654 const float xMax,
655 const float yMin,
656 const float yMax );
657
668 bool qFFMath_InRangeCoerce( float * const x,
669 const float lowerL,
670 const float upperL );
671
682 bool qFFMath_InPolygon( const float x,
683 const float y,
684 const float * const px,
685 const float * const py,
686 const size_t p );
687
698 bool qFFMath_InCircle( const float x,
699 const float y,
700 const float cx,
701 const float cy,
702 const float r );
703
718 float qFFMath_TGamma( float x );
719
734 float qFFMath_LGamma( float x );
735
748 float qFFMath_Factorial( float x );
749
761 float qFFMath_Assoc_laguerre( size_t n,
762 size_t m,
763 float x );
764
776 float qFFMath_Assoc_legendre( size_t n,
777 size_t m,
778 float x );
779
789 float qFFMath_Beta( float x,
790 float y );
791
799 float qFFMath_Comp_ellint_1( float k );
800
808 float qFFMath_Comp_ellint_2( float k );
809
819 float qFFMath_Comp_ellint_3( float k,
820 float nu );
821
831 float qFFMath_Ellint_1( float k,
832 float phi );
833
843 float qFFMath_Ellint_2( float k,
844 float phi );
845
856 float qFFMath_Ellint_3( float k,
857 float nu,
858 float phi );
859
867 float qFFMath_Expint( float num );
868
878 float qFFMath_Hermite( size_t n,
879 float x );
880
891 float qFFMath_Laguerre( size_t n,
892 float x );
893
904 float qFFMath_Legendre( size_t n,
905 float x );
906
913 float qFFMath_Riemann_zeta( float s );
914
925 float qFFMath_Sph_bessel( size_t n,
926 float x );
927
939 float qFFMath_Sph_neumann( size_t n,
940 float x );
941
952 float qFFMath_Cyl_bessel_i( float nu,
953 float x );
954
965 float qFFMath_Cyl_bessel_j( float nu,
966 float x );
967
979 float qFFMath_Cyl_bessel_k( float nu,
980 float x );
981
992 float qFFMath_Cyl_neumann( float nu,
993 float x );
994
1006 float qFFMath_Sph_legendre( size_t l,
1007 size_t m,
1008 float theta );
1009
1011 extern const float * const qFFMath_Infinity;
1012 extern const float * const qFFMath_NotANumber;
1014
1015#endif /*#ifdef QLIBS_USE_STD_MATH*/
1016
1018
1019#ifdef __cplusplus
1020}
1021#endif
1022
1023#endif
float qFFMath_Trunc(float x)
Computes the nearest integer not greater in magnitude than x.
Definition qffmath.c:374
bool qFFMath_IsNaN(const float x)
Determine if x is Not-A-Number (NaN) aka QFFM_NAN.
Definition qffmath.c:117
float qFFMath_Tanh(float x)
Computes hyperbolic tangent of x.
Definition qffmath.c:605
float qFFMath_Hermite(size_t n, float x)
Computes the (physicist's) Hermite polynomials of the degree n and argument x.
Definition qffmath.c:2066
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:907
float qFFMath_Log10(float x)
Computes the common (base-10) logarithm of x.
Definition qffmath.c:580
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:750
float qFFMath_Ellint_1(float k, float phi)
Computes the incomplete elliptic integral of the first kind of k and phi.
Definition qffmath.c:1819
float qFFMath_Legendre(size_t n, float x)
Computes the unassociated Legendre polynomials of the degree n, and argument x.
Definition qffmath.c:2112
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:1443
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:2858
float qFFMath_Sinh(float x)
Computes hyperbolic sine of x.
Definition qffmath.c:591
float qFFMath_RSqrt(float x)
Computes the reciprocal square-root of x denoted as 1/sqrt(x)
Definition qffmath.c:194
float qFFMath_Cyl_bessel_i(float nu, float x)
Computes the regular modified cylindrical Bessel function of nu and x.
Definition qffmath.c:2748
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:471
float qFFMath_Cosh(float x)
Computes hyperbolic cosine of x.
Definition qffmath.c:598
float qFFMath_ACosh(float x)
Computes the inverse hyperbolic cosine of x.
Definition qffmath.c:616
float qFFMath_TGamma(float x)
Computes the gamma function of x.
Definition qffmath.c:917
float qFFMath_ASinh(float x)
Computes the inverse hyperbolic sine of x.
Definition qffmath.c:611
float qFFMath_Comp_ellint_1(float k)
Computes the complete elliptic integral of the first kind of k.
Definition qffmath.c:1762
float qFFMath_Exp10(float x)
Computes the value of 10 raised to the power of x.
Definition qffmath.c:570
float qFFMath_Mod(float x, float y)
Computes the floating-point remainder of the division operation x/y.
Definition qffmath.c:406
float qFFMath_Sph_bessel(size_t n, float x)
Computes the spherical Bessel function of the first kind n, and x.
Definition qffmath.c:2506
float qFFMath_Log(float x)
Computes the natural (base e) logarithm of x.
Definition qffmath.c:575
float qFFMath_Min(float x, float y)
Returns the smaller of two floating point arguments.
Definition qffmath.c:673
float qFFMath_Riemann_zeta(float s)
Computes the Riemann zeta function of s.
Definition qffmath.c:2232
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:679
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:2881
float qFFMath_Sin(float x)
Computes the sine of x (measured in radians).
Definition qffmath.c:413
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:637
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:642
float qFFMath_Remainder(float x, float y)
Computes the IEEE remainder of the floating point division operation x/y.
Definition qffmath.c:400
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:89
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:155
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:848
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:1359
float qFFMath_Tan(float x)
Computes the tangent of x (measured in radians).
Definition qffmath.c:445
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:627
float qFFMath_Pow(float b, float e)
Computes the value of b raised to the power e.
Definition qffmath.c:585
float qFFMath_Ceil(float x)
Computes the smallest integer value not less than x.
Definition qffmath.c:332
float qFFMath_Frac(float x)
Obtain the fractional part of x.
Definition qffmath.c:395
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:832
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:719
float qFFMath_Midpoint(float a, float b)
Computes the midpoint of the floating-points a and b.
Definition qffmath.c:786
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:132
float qFFMath_Log2(float x)
Computes the base 2 logarithm of x.
Definition qffmath.c:516
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:1877
float qFFMath_ACos(float x)
Computes the principal value of the arc cosine of x.
Definition qffmath.c:456
float qFFMath_Beta(float x, float y)
Computes the Beta function of x and y.
Definition qffmath.c:1501
float qFFMath_Exp2(float x)
Computes 2 raised to the given power x.
Definition qffmath.c:482
float qFFMath_RCbrt(float x)
Computes the reciprocal cubic-root of x denoted as 1/cbrt(x)
Definition qffmath.c:249
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:2527
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:2813
float qFFMath_Factorial(float x)
Return the factorial of the integer part of x.
Definition qffmath.c:1222
float qFFMath_Comp_ellint_2(float k)
Computes the complete elliptic integral of the second kind of k.
Definition qffmath.c:1776
float qFFMath_ATan(float x)
Computes the principal value of the arc tangent of x.
Definition qffmath.c:461
float qFFMath_Erfc(float x)
Computes the complementary error function of x.
Definition qffmath.c:662
float qFFMath_Expint(float num)
Computes the Exponential integral of num.
Definition qffmath.c:2061
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:872
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:2840
float qFFMath_Abs(float x)
Computes the absolute value of a floating point value x.
Definition qffmath.c:150
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:699
float qFFMath_Cos(float x)
Computes the cosine of x (measured in radians).
Definition qffmath.c:430
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:632
bool qFFMath_IsInf(const float x)
Determine if x is Infinity.
Definition qffmath.c:122
float qFFMath_ATanh(float x)
Computes the inverse hyperbolic tangent of x.
Definition qffmath.c:622
float qFFMath_Exp(float x)
Computes the e (Euler's number, 2.7182818) raised to the given power x.
Definition qffmath.c:565
float qFFMath_Floor(float x)
Computes the largest integer value not greater than x.
Definition qffmath.c:288
float qFFMath_ASin(float x)
Computes the principal value of the arc sine of x.
Definition qffmath.c:450
float qFFMath_Round(float x)
Computes the nearest integer value to x (in floating-point format), rounding halfway cases away from ...
Definition qffmath.c:255
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:839
float qFFMath_Sqrt(float x)
Computes the square-root of x.
Definition qffmath.c:169
float qFFMath_Max(float x, float y)
Returns the larger of two floating point arguments.
Definition qffmath.c:667
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:127
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:811
float qFFMath_Erf(float x)
Computes the error function of x.
Definition qffmath.c:647
float qFFMath_Ellint_2(float k, float phi)
Computes the incomplete elliptic integral of the second kind of k and phi.
Definition qffmath.c:1844
float qFFMath_LGamma(float x)
Computes the natural logarithm of the absolute value of the gamma function of x.
Definition qffmath.c:1181
float qFFMath_Laguerre(size_t n, float x)
Computes the non-associated Laguerre polynomials of the degree n, and argument x.
Definition qffmath.c:2106
float qFFMath_Cbrt(float x)
Computes the cubic-root of x.
Definition qffmath.c:244
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:1798