liba 0.1.15
An algorithm library based on C/C++
 
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1
5
6#ifndef LIBA_MATH_H
7#define LIBA_MATH_H
8
9#include "a.h"
10#include <math.h>
11
17
19#define A_E 2.71828182845904523536
21#define A_LOG2E 1.44269504088896340736
23#define A_LOG10E 0.434294481903251827651
25#define A_LN2 0.693147180559945309417
27#define A_LN1_2 3.32192809488736218171
29#define A_LN10 2.30258509299404568402
31#define A_LN1_10 0.434294481903251827651
33#define A_PI 3.14159265358979323846
35#define A_TAU 6.28318530717958647693
37#define A_PI_2 1.57079632679489661923
39#define A_PI_4 0.785398163397448309616
41#define A_1_PI 0.318309886183790671538
43#define A_2_PI 0.636619772367581343076
45#define A_1_TAU 0.159154943091895335769
47#define A_2_SQRTPI 1.12837916709551257390
49#define A_SQRT2 1.41421356237309504880
51#define A_SQRT1_2 0.707106781186547524401
53#define A_SQRT3 1.73205080756887729352
55#define A_SQRT1_3 0.57735026918962576450
57#define A_RAD2DEG 57.2957795130823208768
59#define A_DEG2RAD 0.01745329251994329576924
60
61#if defined(__cplusplus)
62extern "C" {
63#endif /* __cplusplus */
64
71A_EXTERN a_u32 a_u32_gcd(a_u32 a, a_u32 b);
72A_EXTERN a_u64 a_u64_gcd(a_u64 a, a_u64 b);
73
80A_EXTERN a_u32 a_u32_lcm(a_u32 a, a_u32 b);
81A_EXTERN a_u64 a_u64_lcm(a_u64 a, a_u64 b);
82
89A_EXTERN a_u32 a_u64_sqrt(a_u64 x);
90
98A_EXTERN a_f64 a_f64_rsqrt(a_f64 x);
99
100#if defined(__cplusplus)
101} /* extern "C" */
102#endif /* __cplusplus */
103
104#define a_f32_modf A_F32_F(modf)
105#define a_f32_frexp A_F32_F(frexp)
106#define a_f32_ldexp A_F32_F(ldexp)
107#define a_f32_scalbn A_F32_F(scalbn)
108#define a_f32_scalbln A_F32_F(scalbln)
109#define a_f32_nextafter A_F32_F(nextafter)
110#define a_f32_nexttoward A_F32_F(nexttoward)
111#define a_f32_copysign A_F32_F(copysign)
112
113#define a_f32_ma A_F32_F(fma)
114#define a_f32_nan A_F32_F(nan)
115#define a_f32_abs A_F32_F(fabs)
116#define a_f32_mod A_F32_F(fmod)
117#define a_f32_max A_F32_F(fmax)
118#define a_f32_min A_F32_F(fmin)
119#define a_f32_dim A_F32_F(fdim)
120#define a_f32_remquo A_F32_F(remquo)
121#define a_f32_remainder A_F32_F(remainder)
122
123#define a_f32_exp A_F32_F(exp)
124#define a_f32_exp2 A_F32_F(exp2)
125#define a_f32_expm1 A_F32_F(expm1)
126
127#define a_f32_log A_F32_F(log)
128#define a_f32_logb A_F32_F(logb)
129#define a_f32_log2 A_F32_F(log2)
130#define a_f32_log10 A_F32_F(log10)
131#define a_f32_log1p A_F32_F(log1p)
132#define a_f32_ilogb A_F32_F(ilogb)
133
134#define a_f32_pow A_F32_F(pow)
135#define a_f32_sqrt A_F32_F(sqrt)
136#define a_f32_cbrt A_F32_F(cbrt)
137#define a_f32_hypot A_F32_F(hypot)
138
139#define a_f32_sin A_F32_F(sin)
140#define a_f32_cos A_F32_F(cos)
141#define a_f32_tan A_F32_F(tan)
142#define a_f32_asin A_F32_F(asin)
143#define a_f32_acos A_F32_F(acos)
144#define a_f32_atan A_F32_F(atan)
145#define a_f32_atan2 A_F32_F(atan2)
146
147#define a_f32_sinh A_F32_F(sinh)
148#define a_f32_cosh A_F32_F(cosh)
149#define a_f32_tanh A_F32_F(tanh)
150#define a_f32_asinh A_F32_F(asinh)
151#define a_f32_acosh A_F32_F(acosh)
152#define a_f32_atanh A_F32_F(atanh)
153
154#define a_f32_erf A_F32_F(erf)
155#define a_f32_erfc A_F32_F(erfc)
156#define a_f32_tgamma A_F32_F(tgamma)
157#define a_f32_lgamma A_F32_F(lgamma)
158
159#define a_f32_ceil A_F32_F(ceil)
160#define a_f32_floor A_F32_F(floor)
161#define a_f32_trunc A_F32_F(trunc)
162#define a_f32_round A_F32_F(round)
163#define a_f32_lround A_F32_F(lround)
164#define a_f32_llround A_F32_F(llround)
165#define a_f32_nearbyint A_F32_F(nearbyint)
166#define a_f32_rint A_F32_F(rint)
167#define a_f32_lrintt A_F32_F(lrint)
168#define a_f32_llrintt A_F32_F(llrint)
169
170#define a_f64_modf A_F64_F(modf)
171#define a_f64_frexp A_F64_F(frexp)
172#define a_f64_ldexp A_F64_F(ldexp)
173#define a_f64_scalbn A_F64_F(scalbn)
174#define a_f64_scalbln A_F64_F(scalbln)
175#define a_f64_nextafter A_F64_F(nextafter)
176#define a_f64_nexttoward A_F64_F(nexttoward)
177#define a_f64_copysign A_F64_F(copysign)
178
179#define a_f64_ma A_F64_F(fma)
180#define a_f64_nan A_F64_F(nan)
181#define a_f64_abs A_F64_F(fabs)
182#define a_f64_mod A_F64_F(fmod)
183#define a_f64_max A_F64_F(fmax)
184#define a_f64_min A_F64_F(fmin)
185#define a_f64_dim A_F64_F(fdim)
186#define a_f64_remquo A_F64_F(remquo)
187#define a_f64_remainder A_F64_F(remainder)
188
189#define a_f64_exp A_F64_F(exp)
190#define a_f64_exp2 A_F64_F(exp2)
191#define a_f64_expm1 A_F64_F(expm1)
192
193#define a_f64_log A_F64_F(log)
194#define a_f64_logb A_F64_F(logb)
195#define a_f64_log2 A_F64_F(log2)
196#define a_f64_log10 A_F64_F(log10)
197#define a_f64_log1p A_F64_F(log1p)
198#define a_f64_ilogb A_F64_F(ilogb)
199
200#define a_f64_pow A_F64_F(pow)
201#define a_f64_sqrt A_F64_F(sqrt)
202#define a_f64_cbrt A_F64_F(cbrt)
203#define a_f64_hypot A_F64_F(hypot)
204
205#define a_f64_sin A_F64_F(sin)
206#define a_f64_cos A_F64_F(cos)
207#define a_f64_tan A_F64_F(tan)
208#define a_f64_asin A_F64_F(asin)
209#define a_f64_acos A_F64_F(acos)
210#define a_f64_atan A_F64_F(atan)
211#define a_f64_atan2 A_F64_F(atan2)
212
213#define a_f64_sinh A_F64_F(sinh)
214#define a_f64_cosh A_F64_F(cosh)
215#define a_f64_tanh A_F64_F(tanh)
216#define a_f64_asinh A_F64_F(asinh)
217#define a_f64_acosh A_F64_F(acosh)
218#define a_f64_atanh A_F64_F(atanh)
219
220#define a_f64_erf A_F64_F(erf)
221#define a_f64_erfc A_F64_F(erfc)
222#define a_f64_tgamma A_F64_F(tgamma)
223#define a_f64_lgamma A_F64_F(lgamma)
224
225#define a_f64_ceil A_F64_F(ceil)
226#define a_f64_floor A_F64_F(floor)
227#define a_f64_trunc A_F64_F(trunc)
228#define a_f64_round A_F64_F(round)
229#define a_f64_lround A_F64_F(lround)
230#define a_f64_llround A_F64_F(llround)
231#define a_f64_nearbyint A_F64_F(nearbyint)
232#define a_f64_rint A_F64_F(rint)
233#define a_f64_lrintt A_F64_F(lrint)
234#define a_f64_llrintt A_F64_F(llrint)
235
237
243
245#define A_REAL_E A_REAL_C(A_E)
247#define A_REAL_LOG2E A_REAL_C(A_LOG2E)
249#define A_REAL_LOG10E A_REAL_C(A_LOG10E)
251#define A_REAL_LN2 A_REAL_C(A_LN2)
253#define A_REAL_LN1_2 A_REAL_C(A_LN1_2)
255#define A_REAL_LN10 A_REAL_C(A_LN10)
257#define A_REAL_LN1_10 A_REAL_C(A_LN1_10)
259#define A_REAL_PI A_REAL_C(A_PI)
261#define A_REAL_TAU A_REAL_C(A_TAU)
263#define A_REAL_PI_2 A_REAL_C(A_PI_2)
265#define A_REAL_PI_4 A_REAL_C(A_PI_4)
267#define A_REAL_1_PI A_REAL_C(A_1_PI)
269#define A_REAL_2_PI A_REAL_C(A_2_PI)
271#define A_REAL_1_TAU A_REAL_C(A_1_TAU)
273#define A_REAL_2_SQRTPI A_REAL_C(A_2_SQRTPI)
275#define A_REAL_SQRT2 A_REAL_C(A_SQRT2)
277#define A_REAL_SQRT1_2 A_REAL_C(A_SQRT1_2)
279#define A_REAL_SQRT3 A_REAL_C(A_SQRT3)
281#define A_REAL_SQRT1_3 A_REAL_C(A_SQRT1_3)
283#define A_REAL_RAD2DEG A_REAL_C(A_RAD2DEG)
285#define A_REAL_DEG2RAD A_REAL_C(A_DEG2RAD)
286
287#if defined(__cplusplus)
288extern "C" {
289#endif /* __cplusplus */
290
291A_EXTERN a_real a_real_rad2deg(a_real x);
292A_EXTERN a_real a_real_deg2rad(a_real x);
293
294A_EXTERN void a_real_cart2pol(a_real x, a_real y, a_real *rho, a_real *theta);
295A_EXTERN void a_real_pol2cart(a_real rho, a_real theta, a_real *x, a_real *y);
296A_EXTERN void a_real_cart2sph(a_real x, a_real y, a_real z, a_real *rho, a_real *theta, a_real *alpha);
297A_EXTERN void a_real_sph2cart(a_real rho, a_real theta, a_real alpha, a_real *x, a_real *y, a_real *z);
298
299A_EXTERN a_real a_real_asinh(a_real x);
300A_EXTERN a_real a_real_acosh(a_real x);
301A_EXTERN a_real a_real_atanh(a_real x);
302A_EXTERN a_real a_real_expm1(a_real x);
303A_EXTERN a_real a_real_log1p(a_real x);
304A_EXTERN a_real a_real_atan2(a_real y, a_real x);
305A_EXTERN a_real a_real_norm2(a_real x, a_real y);
306A_EXTERN a_real a_real_norm3(a_real x, a_real y, a_real z);
307
314A_EXTERN a_real a_real_norm(a_size n, a_real const *p);
315A_EXTERN a_real a_real_norm_(a_size n, a_real const *p, a_size c);
316
323A_EXTERN a_real a_real_sum(a_size n, a_real const *p);
324A_EXTERN a_real a_real_sum_(a_size n, a_real const *p, a_size c);
325
332A_EXTERN a_real a_real_sum1(a_size n, a_real const *p);
333A_EXTERN a_real a_real_sum1_(a_size n, a_real const *p, a_size c);
334
341A_EXTERN a_real a_real_sum2(a_size n, a_real const *p);
342A_EXTERN a_real a_real_sum2_(a_size n, a_real const *p, a_size c);
343
350A_EXTERN a_real a_real_mean(a_size n, a_real const *p);
351A_EXTERN a_real a_real_mean_(a_size n, a_real const *p, a_size c);
352
360A_EXTERN a_real a_real_dot(a_size n, a_real const *X, a_real const *Y);
361
371A_EXTERN a_real a_real_dot_(a_size n, a_real const *X, a_size Xc, a_real const *Y, a_size Yc);
372
379A_EXTERN A_NONULL((2, 3)) void a_real_copy(a_size n, a_real *__restrict dst, a_real const *__restrict src);
380A_EXTERN void a_real_copy_(a_size n, a_real *dst, a_size dc, a_real const *src, a_size sc);
381
388A_EXTERN A_NONULL((2, 3)) void a_real_swap(a_size n, a_real *__restrict lhs, a_real *__restrict rhs);
389A_EXTERN void a_real_swap_(a_size n, a_real *lhs, a_size lc, a_real *rhs, a_size rc);
390
397A_EXTERN void a_real_fill(a_size n, a_real *p, a_real v);
398
404A_EXTERN void a_real_zero(a_size n, a_real *p);
405
412A_EXTERN void a_real_push_fore(a_real *p, a_size n, a_real x);
413
420A_EXTERN void a_real_push_back(a_real *p, a_size n, a_real x);
421
429A_EXTERN void a_real_push_fore_(a_real *block_p, a_size block_n,
430 a_real const *cache_p, a_size cache_n);
431
439A_EXTERN void a_real_push_back_(a_real *block_p, a_size block_n,
440 a_real const *cache_p, a_size cache_n);
441
447A_EXTERN void a_real_roll_fore(a_real *p, a_size n);
448
454A_EXTERN void a_real_roll_back(a_real *p, a_size n);
455
463A_EXTERN void a_real_roll_fore_(a_real *block_p, a_size block_n,
464 a_real *shift_p, a_size shift_n);
465
473A_EXTERN void a_real_roll_back_(a_real *block_p, a_size block_n,
474 a_real *shift_p, a_size shift_n);
475
476#if defined(__cplusplus)
477} /* extern "C" */
478#endif /* __cplusplus */
479
480#define a_real_modf A_REAL_F(modf)
481#define a_real_frexp A_REAL_F(frexp)
482#define a_real_ldexp A_REAL_F(ldexp)
483#define a_real_scalbn A_REAL_F(scalbn)
484#define a_real_scalbln A_REAL_F(scalbln)
485#define a_real_nextafter A_REAL_F(nextafter)
486#define a_real_nexttoward A_REAL_F(nexttoward)
487#define a_real_copysign A_REAL_F(copysign)
488
489#define a_real_ma A_REAL_F(fma)
490#define a_real_nan A_REAL_F(nan)
491#define a_real_abs A_REAL_F(fabs)
492#define a_real_mod A_REAL_F(fmod)
493#define a_real_max A_REAL_F(fmax)
494#define a_real_min A_REAL_F(fmin)
495#define a_real_dim A_REAL_F(fdim)
496#define a_real_remquo A_REAL_F(remquo)
497#define a_real_remainder A_REAL_F(remainder)
498
499#define a_real_exp A_REAL_F(exp)
500#define a_real_exp2 A_REAL_F(exp2)
501#if defined(A_HAVE_EXPM1) && (A_HAVE_EXPM1 + 0 > 0)
502#define a_real_expm1 A_REAL_F(expm1)
503#endif /* A_HAVE_EXPM1 */
504
505#define a_real_log A_REAL_F(log)
506#define a_real_logb A_REAL_F(logb)
507#define a_real_log2 A_REAL_F(log2)
508#define a_real_log10 A_REAL_F(log10)
509#if defined(A_HAVE_LOG1P) && (A_HAVE_LOG1P + 0 > 0)
510#define a_real_log1p A_REAL_F(log1p)
511#endif /* A_HAVE_LOG1P */
512#define a_real_ilogb A_REAL_F(ilogb)
513
514#define a_real_pow A_REAL_F(pow)
515#define a_real_sqrt A_REAL_F(sqrt)
516#define a_real_cbrt A_REAL_F(cbrt)
517#if defined(_MSC_VER) && (_MSC_VER < 1900)
518#define a_real_hypot A_REAL_F(_hypot)
519#elif defined(A_HAVE_HYPOT) && (A_HAVE_HYPOT + 0 > 0)
520#define a_real_hypot A_REAL_F(hypot)
521#else /* !A_HAVE_HYPOT */
522#define a_real_hypot a_real_norm2
523#endif /* A_HAVE_HYPOT */
524
525#define a_real_sin A_REAL_F(sin)
526#define a_real_cos A_REAL_F(cos)
527#define a_real_tan A_REAL_F(tan)
528#define a_real_asin A_REAL_F(asin)
529#define a_real_acos A_REAL_F(acos)
530#define a_real_atan A_REAL_F(atan)
531#if defined(A_HAVE_ATAN2) && (A_HAVE_ATAN2 + 0 > 0)
532#define a_real_atan2 A_REAL_F(atan2)
533#endif /* A_HAVE_ATAN2 */
534
535#define a_real_sinh A_REAL_F(sinh)
536#define a_real_cosh A_REAL_F(cosh)
537#define a_real_tanh A_REAL_F(tanh)
538#if defined(A_HAVE_ASINH) && (A_HAVE_ASINH + 0 > 0)
539#define a_real_asinh A_REAL_F(asinh)
540#endif /* A_HAVE_ASINH */
541#if defined(A_HAVE_ACOSH) && (A_HAVE_ACOSH + 0 > 0)
542#define a_real_acosh A_REAL_F(acosh)
543#endif /* A_HAVE_ACOSH */
544#if defined(A_HAVE_ATANH) && (A_HAVE_ATANH + 0 > 0)
545#define a_real_atanh A_REAL_F(atanh)
546#endif /* A_HAVE_ATANH */
547
548#define a_real_erf A_REAL_F(erf)
549#define a_real_erfc A_REAL_F(erfc)
550#define a_real_tgamma A_REAL_F(tgamma)
551#define a_real_lgamma A_REAL_F(lgamma)
552
553#define a_real_ceil A_REAL_F(ceil)
554#define a_real_floor A_REAL_F(floor)
555#define a_real_trunc A_REAL_F(trunc)
556#define a_real_round A_REAL_F(round)
557#define a_real_lround A_REAL_F(lround)
558#define a_real_llround A_REAL_F(llround)
559#define a_real_nearbyint A_REAL_F(nearbyint)
560#define a_real_rint A_REAL_F(rint)
561#define a_real_lrintt A_REAL_F(lrint)
562#define a_real_llrintt A_REAL_F(llrint)
563
565
566#endif /* a/math.h */
algorithm library
a_f32 a_f32_rsqrt(a_f32 x)
compute the reciprocal of square-root,
a_u32 a_u32_lcm(a_u32 a, a_u32 b)
compute the least common multiple of two unsigned integers
a_u32 a_u32_gcd(a_u32 a, a_u32 b)
compute the greatest common divisor of two unsigned integers
a_u16 a_u32_sqrt(a_u32 x)
compute the square root of an unsigned integer
a_real a_real_sum1(a_size n, a_real const *p)
compute the absolute sum of a float array
a_real a_real_dot(a_size n, a_real const *X, a_real const *Y)
compute the dot product of two vectors.
a_real a_real_dot_(a_size n, a_real const *X, a_size Xc, a_real const *Y, a_size Yc)
compute the dot product of two vectors.
void a_real_zero(a_size n, a_real *p)
set all elements of an array of a_real numbers to zero.
void a_real_push_back(a_real *p, a_size n, a_real x)
push an element into the end of a float array
void a_real_roll_fore(a_real *p, a_size n)
roll forward the elements of a float array circularly
void a_real_push_fore_(a_real *block_p, a_size block_n, a_real const *cache_p, a_size cache_n)
push the elements into the front of a float array
void a_real_push_back_(a_real *block_p, a_size block_n, a_real const *cache_p, a_size cache_n)
push the elements into the end of a float array
a_real a_real_mean(a_size n, a_real const *p)
compute the mean of a float array
a_real a_real_norm(a_size n, a_real const *p)
compute the magnitude of a vector
double a_real
compiler built-in floating-point number type
Definition a.h:1006
void a_real_roll_back(a_real *p, a_size n)
roll backward the elements of a float array circularly
void a_real_swap(a_size n, a_real *__restrict lhs, a_real *__restrict rhs)
swap two different a_real blocks of the same size
void a_real_push_fore(a_real *p, a_size n, a_real x)
push an element into the front of a float array
void a_real_roll_fore_(a_real *block_p, a_size block_n, a_real *shift_p, a_size shift_n)
roll forward the elements of a float array circularly
void a_real_copy(a_size n, a_real *__restrict dst, a_real const *__restrict src)
copy n elements from the source array src to the destination array dst.
void a_real_roll_back_(a_real *block_p, a_size block_n, a_real *shift_p, a_size shift_n)
roll backward the elements of a float array circularly
a_real a_real_sum2(a_size n, a_real const *p)
compute the sum of squares of a float array
void a_real_fill(a_size n, a_real *p, a_real v)
fill an array of a_real numbers with a specified value.
a_real a_real_sum(a_size n, a_real const *p)
compute the sum of a float array
float a_f32
single precision floating point type. Matches IEEE-754 binary32 format if supported.
Definition a.h:877
unsigned long a_u64
unsigned integer type with width of exactly 64 bits
Definition a.h:627
unsigned short a_u16
unsigned integer type with width of exactly 16 bits
Definition a.h:486
double a_f64
double precision floating point type. Matches IEEE-754 binary64 format if supported.
Definition a.h:901
unsigned long a_u32
unsigned integer type with width of exactly 32 bits
Definition a.h:538
size_t a_size
unsigned integer type returned by the sizeof operator
Definition a.h:823
mathematical algorithm library