liba 0.1.15
An algorithm library based on C/C++
 
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
56
57#if defined(__cplusplus)
58extern "C" {
59#endif /* __cplusplus */
60
67A_EXTERN a_u32 a_u32_gcd(a_u32 a, a_u32 b);
68A_EXTERN a_u64 a_u64_gcd(a_u64 a, a_u64 b);
69
76A_EXTERN a_u32 a_u32_lcm(a_u32 a, a_u32 b);
77A_EXTERN a_u64 a_u64_lcm(a_u64 a, a_u64 b);
78
85A_EXTERN a_u32 a_u64_sqrt(a_u64 x);
86
94A_EXTERN a_f64 a_f64_rsqrt(a_f64 x);
95
96#if defined(__cplusplus)
97} /* extern "C" */
98#endif /* __cplusplus */
99
100#define a_f32_modf A_F32_F(modf)
101#define a_f32_frexp A_F32_F(frexp)
102#define a_f32_ldexp A_F32_F(ldexp)
103#define a_f32_scalbn A_F32_F(scalbn)
104#define a_f32_scalbln A_F32_F(scalbln)
105#define a_f32_nextafter A_F32_F(nextafter)
106#define a_f32_nexttoward A_F32_F(nexttoward)
107#define a_f32_copysign A_F32_F(copysign)
108
109#define a_f32_ma A_F32_F(fma)
110#define a_f32_nan A_F32_F(nan)
111#define a_f32_abs A_F32_F(fabs)
112#define a_f32_mod A_F32_F(fmod)
113#define a_f32_max A_F32_F(fmax)
114#define a_f32_min A_F32_F(fmin)
115#define a_f32_dim A_F32_F(fdim)
116#define a_f32_remquo A_F32_F(remquo)
117#define a_f32_remainder A_F32_F(remainder)
118
119#define a_f32_exp A_F32_F(exp)
120#define a_f32_exp2 A_F32_F(exp2)
121#define a_f32_expm1 A_F32_F(expm1)
122
123#define a_f32_log A_F32_F(log)
124#define a_f32_logb A_F32_F(logb)
125#define a_f32_log2 A_F32_F(log2)
126#define a_f32_log10 A_F32_F(log10)
127#define a_f32_log1p A_F32_F(log1p)
128#define a_f32_ilogb A_F32_F(ilogb)
129
130#define a_f32_pow A_F32_F(pow)
131#define a_f32_sqrt A_F32_F(sqrt)
132#define a_f32_cbrt A_F32_F(cbrt)
133#define a_f32_hypot A_F32_F(hypot)
134
135#define a_f32_sin A_F32_F(sin)
136#define a_f32_cos A_F32_F(cos)
137#define a_f32_tan A_F32_F(tan)
138#define a_f32_asin A_F32_F(asin)
139#define a_f32_acos A_F32_F(acos)
140#define a_f32_atan A_F32_F(atan)
141#define a_f32_atan2 A_F32_F(atan2)
142
143#define a_f32_sinh A_F32_F(sinh)
144#define a_f32_cosh A_F32_F(cosh)
145#define a_f32_tanh A_F32_F(tanh)
146#define a_f32_asinh A_F32_F(asinh)
147#define a_f32_acosh A_F32_F(acosh)
148#define a_f32_atanh A_F32_F(atanh)
149
150#define a_f32_erf A_F32_F(erf)
151#define a_f32_erfc A_F32_F(erfc)
152#define a_f32_tgamma A_F32_F(tgamma)
153#define a_f32_lgamma A_F32_F(lgamma)
154
155#define a_f32_ceil A_F32_F(ceil)
156#define a_f32_floor A_F32_F(floor)
157#define a_f32_trunc A_F32_F(trunc)
158#define a_f32_round A_F32_F(round)
159#define a_f32_lround A_F32_F(lround)
160#define a_f32_llround A_F32_F(llround)
161#define a_f32_nearbyint A_F32_F(nearbyint)
162#define a_f32_rint A_F32_F(rint)
163#define a_f32_lrintt A_F32_F(lrint)
164#define a_f32_llrintt A_F32_F(llrint)
165
166#define a_f64_modf A_F64_F(modf)
167#define a_f64_frexp A_F64_F(frexp)
168#define a_f64_ldexp A_F64_F(ldexp)
169#define a_f64_scalbn A_F64_F(scalbn)
170#define a_f64_scalbln A_F64_F(scalbln)
171#define a_f64_nextafter A_F64_F(nextafter)
172#define a_f64_nexttoward A_F64_F(nexttoward)
173#define a_f64_copysign A_F64_F(copysign)
174
175#define a_f64_ma A_F64_F(fma)
176#define a_f64_nan A_F64_F(nan)
177#define a_f64_abs A_F64_F(fabs)
178#define a_f64_mod A_F64_F(fmod)
179#define a_f64_max A_F64_F(fmax)
180#define a_f64_min A_F64_F(fmin)
181#define a_f64_dim A_F64_F(fdim)
182#define a_f64_remquo A_F64_F(remquo)
183#define a_f64_remainder A_F64_F(remainder)
184
185#define a_f64_exp A_F64_F(exp)
186#define a_f64_exp2 A_F64_F(exp2)
187#define a_f64_expm1 A_F64_F(expm1)
188
189#define a_f64_log A_F64_F(log)
190#define a_f64_logb A_F64_F(logb)
191#define a_f64_log2 A_F64_F(log2)
192#define a_f64_log10 A_F64_F(log10)
193#define a_f64_log1p A_F64_F(log1p)
194#define a_f64_ilogb A_F64_F(ilogb)
195
196#define a_f64_pow A_F64_F(pow)
197#define a_f64_sqrt A_F64_F(sqrt)
198#define a_f64_cbrt A_F64_F(cbrt)
199#define a_f64_hypot A_F64_F(hypot)
200
201#define a_f64_sin A_F64_F(sin)
202#define a_f64_cos A_F64_F(cos)
203#define a_f64_tan A_F64_F(tan)
204#define a_f64_asin A_F64_F(asin)
205#define a_f64_acos A_F64_F(acos)
206#define a_f64_atan A_F64_F(atan)
207#define a_f64_atan2 A_F64_F(atan2)
208
209#define a_f64_sinh A_F64_F(sinh)
210#define a_f64_cosh A_F64_F(cosh)
211#define a_f64_tanh A_F64_F(tanh)
212#define a_f64_asinh A_F64_F(asinh)
213#define a_f64_acosh A_F64_F(acosh)
214#define a_f64_atanh A_F64_F(atanh)
215
216#define a_f64_erf A_F64_F(erf)
217#define a_f64_erfc A_F64_F(erfc)
218#define a_f64_tgamma A_F64_F(tgamma)
219#define a_f64_lgamma A_F64_F(lgamma)
220
221#define a_f64_ceil A_F64_F(ceil)
222#define a_f64_floor A_F64_F(floor)
223#define a_f64_trunc A_F64_F(trunc)
224#define a_f64_round A_F64_F(round)
225#define a_f64_lround A_F64_F(lround)
226#define a_f64_llround A_F64_F(llround)
227#define a_f64_nearbyint A_F64_F(nearbyint)
228#define a_f64_rint A_F64_F(rint)
229#define a_f64_lrintt A_F64_F(lrint)
230#define a_f64_llrintt A_F64_F(llrint)
231
233
239
241#define A_REAL_E A_REAL_C(A_E)
243#define A_REAL_LOG2E A_REAL_C(A_LOG2E)
245#define A_REAL_LOG10E A_REAL_C(A_LOG10E)
247#define A_REAL_LN2 A_REAL_C(A_LN2)
249#define A_REAL_LN1_2 A_REAL_C(A_LN1_2)
251#define A_REAL_LN10 A_REAL_C(A_LN10)
253#define A_REAL_LN1_10 A_REAL_C(A_LN1_10)
255#define A_REAL_PI A_REAL_C(A_PI)
257#define A_REAL_TAU A_REAL_C(A_TAU)
259#define A_REAL_PI_2 A_REAL_C(A_PI_2)
261#define A_REAL_PI_4 A_REAL_C(A_PI_4)
263#define A_REAL_1_PI A_REAL_C(A_1_PI)
265#define A_REAL_2_PI A_REAL_C(A_2_PI)
267#define A_REAL_1_TAU A_REAL_C(A_1_TAU)
269#define A_REAL_2_SQRTPI A_REAL_C(A_2_SQRTPI)
271#define A_REAL_SQRT2 A_REAL_C(A_SQRT2)
273#define A_REAL_SQRT1_2 A_REAL_C(A_SQRT1_2)
275#define A_REAL_SQRT3 A_REAL_C(A_SQRT3)
277#define A_REAL_SQRT1_3 A_REAL_C(A_SQRT1_3)
278
279#if defined(__cplusplus)
280extern "C" {
281#endif /* __cplusplus */
282
283A_EXTERN a_real a_real_asinh(a_real x);
284A_EXTERN a_real a_real_acosh(a_real x);
285A_EXTERN a_real a_real_atanh(a_real x);
286A_EXTERN a_real a_real_expm1(a_real x);
287A_EXTERN a_real a_real_log1p(a_real x);
288A_EXTERN a_real a_real_atan2(a_real y, a_real x);
289A_EXTERN a_real a_real_norm2(a_real x, a_real y);
290A_EXTERN a_real a_real_norm3(a_real x, a_real y, a_real z);
291
298A_EXTERN a_real a_real_norm(a_size n, a_real const *p);
299A_EXTERN a_real a_real_norm_(a_size n, a_real const *p, a_size c);
300
307A_EXTERN a_real a_real_sum(a_size n, a_real const *p);
308A_EXTERN a_real a_real_sum_(a_size n, a_real const *p, a_size c);
309
316A_EXTERN a_real a_real_sum1(a_size n, a_real const *p);
317A_EXTERN a_real a_real_sum1_(a_size n, a_real const *p, a_size c);
318
325A_EXTERN a_real a_real_sum2(a_size n, a_real const *p);
326A_EXTERN a_real a_real_sum2_(a_size n, a_real const *p, a_size c);
327
334A_EXTERN a_real a_real_mean(a_size n, a_real const *p);
335A_EXTERN a_real a_real_mean_(a_size n, a_real const *p, a_size c);
336
344A_EXTERN a_real a_real_dot(a_size n, a_real const *X, a_real const *Y);
345
355A_EXTERN a_real a_real_dot_(a_size n, a_real const *X, a_size Xc, a_real const *Y, a_size Yc);
356
363A_EXTERN A_NONULL((2, 3)) void a_real_copy(a_size n, a_real *__restrict dst, a_real const *__restrict src);
364A_EXTERN void a_real_copy_(a_size n, a_real *dst, a_size dc, a_real const *src, a_size sc);
365
372A_EXTERN A_NONULL((2, 3)) void a_real_swap(a_size n, a_real *__restrict lhs, a_real *__restrict rhs);
373A_EXTERN void a_real_swap_(a_size n, a_real *lhs, a_size lc, a_real *rhs, a_size rc);
374
381A_EXTERN void a_real_fill(a_size n, a_real *p, a_real v);
382
388A_EXTERN void a_real_zero(a_size n, a_real *p);
389
396A_EXTERN void a_real_push_fore(a_real *p, a_size n, a_real x);
397
404A_EXTERN void a_real_push_back(a_real *p, a_size n, a_real x);
405
413A_EXTERN void a_real_push_fore_(a_real *block_p, a_size block_n,
414 a_real const *cache_p, a_size cache_n);
415
423A_EXTERN void a_real_push_back_(a_real *block_p, a_size block_n,
424 a_real const *cache_p, a_size cache_n);
425
431A_EXTERN void a_real_roll_fore(a_real *p, a_size n);
432
438A_EXTERN void a_real_roll_back(a_real *p, a_size n);
439
447A_EXTERN void a_real_roll_fore_(a_real *block_p, a_size block_n,
448 a_real *shift_p, a_size shift_n);
449
457A_EXTERN void a_real_roll_back_(a_real *block_p, a_size block_n,
458 a_real *shift_p, a_size shift_n);
459
460#if defined(__cplusplus)
461} /* extern "C" */
462#endif /* __cplusplus */
463
464#define a_real_modf A_REAL_F(modf)
465#define a_real_frexp A_REAL_F(frexp)
466#define a_real_ldexp A_REAL_F(ldexp)
467#define a_real_scalbn A_REAL_F(scalbn)
468#define a_real_scalbln A_REAL_F(scalbln)
469#define a_real_nextafter A_REAL_F(nextafter)
470#define a_real_nexttoward A_REAL_F(nexttoward)
471#define a_real_copysign A_REAL_F(copysign)
472
473#define a_real_ma A_REAL_F(fma)
474#define a_real_nan A_REAL_F(nan)
475#define a_real_abs A_REAL_F(fabs)
476#define a_real_mod A_REAL_F(fmod)
477#define a_real_max A_REAL_F(fmax)
478#define a_real_min A_REAL_F(fmin)
479#define a_real_dim A_REAL_F(fdim)
480#define a_real_remquo A_REAL_F(remquo)
481#define a_real_remainder A_REAL_F(remainder)
482
483#define a_real_exp A_REAL_F(exp)
484#define a_real_exp2 A_REAL_F(exp2)
485#if defined(A_HAVE_EXPM1) && (A_HAVE_EXPM1 + 0 > 0)
486#define a_real_expm1 A_REAL_F(expm1)
487#endif /* A_HAVE_EXPM1 */
488
489#define a_real_log A_REAL_F(log)
490#define a_real_logb A_REAL_F(logb)
491#define a_real_log2 A_REAL_F(log2)
492#define a_real_log10 A_REAL_F(log10)
493#if defined(A_HAVE_LOG1P) && (A_HAVE_LOG1P + 0 > 0)
494#define a_real_log1p A_REAL_F(log1p)
495#endif /* A_HAVE_LOG1P */
496#define a_real_ilogb A_REAL_F(ilogb)
497
498#define a_real_pow A_REAL_F(pow)
499#define a_real_sqrt A_REAL_F(sqrt)
500#define a_real_cbrt A_REAL_F(cbrt)
501#if defined(_MSC_VER) && (_MSC_VER < 1900)
502#define a_real_hypot A_REAL_F(_hypot)
503#elif defined(A_HAVE_HYPOT) && (A_HAVE_HYPOT + 0 > 0)
504#define a_real_hypot A_REAL_F(hypot)
505#else /* !A_HAVE_HYPOT */
506#define a_real_hypot a_real_norm2
507#endif /* A_HAVE_HYPOT */
508
509#define a_real_sin A_REAL_F(sin)
510#define a_real_cos A_REAL_F(cos)
511#define a_real_tan A_REAL_F(tan)
512#define a_real_asin A_REAL_F(asin)
513#define a_real_acos A_REAL_F(acos)
514#define a_real_atan A_REAL_F(atan)
515#if defined(A_HAVE_ATAN2) && (A_HAVE_ATAN2 + 0 > 0)
516#define a_real_atan2 A_REAL_F(atan2)
517#endif /* A_HAVE_ATAN2 */
518
519#define a_real_sinh A_REAL_F(sinh)
520#define a_real_cosh A_REAL_F(cosh)
521#define a_real_tanh A_REAL_F(tanh)
522#if defined(A_HAVE_ASINH) && (A_HAVE_ASINH + 0 > 0)
523#define a_real_asinh A_REAL_F(asinh)
524#endif /* A_HAVE_ASINH */
525#if defined(A_HAVE_ACOSH) && (A_HAVE_ACOSH + 0 > 0)
526#define a_real_acosh A_REAL_F(acosh)
527#endif /* A_HAVE_ACOSH */
528#if defined(A_HAVE_ATANH) && (A_HAVE_ATANH + 0 > 0)
529#define a_real_atanh A_REAL_F(atanh)
530#endif /* A_HAVE_ATANH */
531
532#define a_real_erf A_REAL_F(erf)
533#define a_real_erfc A_REAL_F(erfc)
534#define a_real_tgamma A_REAL_F(tgamma)
535#define a_real_lgamma A_REAL_F(lgamma)
536
537#define a_real_ceil A_REAL_F(ceil)
538#define a_real_floor A_REAL_F(floor)
539#define a_real_trunc A_REAL_F(trunc)
540#define a_real_round A_REAL_F(round)
541#define a_real_lround A_REAL_F(lround)
542#define a_real_llround A_REAL_F(llround)
543#define a_real_nearbyint A_REAL_F(nearbyint)
544#define a_real_rint A_REAL_F(rint)
545#define a_real_lrintt A_REAL_F(lrint)
546#define a_real_llrintt A_REAL_F(llrint)
547
549
550#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)
calculate 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)
calculate the mean of a float array
a_real a_real_norm(a_size n, a_real const *p)
calculate the magnitude of a vector
double a_real
compiler built-in floating-point number type
Definition a.h:1003
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)
calculate 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)
calculate 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