forked from phoenix-rtos/libphoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath.h
171 lines (102 loc) · 3.72 KB
/
math.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
* Phoenix-RTOS
*
* libphoenix
*
* math.h
*
* Copyright 2017 Phoenix Systems
* Author: Aleksander Kaminski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/
#ifndef _LIBPHOENIX_MATH_H_
#define _LIBPHOENIX_MATH_H_
#include <stdarg.h>
#include <math/consts.h>
/* Trigonometric functions */
/* Returns the cosine of an angle of x radians. */
extern double cos(double x);
/* Returns the sine of an angle of x radians. */
extern double sin(double x);
/* Returns the tangent of an angle of x radians. */
extern double tan(double x);
/* Returns the principal value of the arc cosine of x, expressed in radians. */
extern double acos(double x);
/* Returns the principal value of the arc sine of x, expressed in radians. */
extern double asin(double x);
/* Returns the principal value of the arc tan of x, expressed in radians. */
extern double atan(double x);
/* Returns the principal value of the arc tangent of y/x, expressed in radians. */
extern double atan2(double y, double x);
/* Hyperbolic functions */
/* Returns the hyperbolic cosine of x. */
extern double cosh(double x);
/* Returns the hyperbolic sine of x. */
extern double sinh(double x);
/* Returns the hyperbolic tangent of x. */
extern double tanh(double x);
/* Exponential and logarithmic functions */
/* Returns the base-e exponential function of x, which is e raised to the power x: e^x. */
extern double exp(double x);
/* Breaks the floating point number x into its binary significand
* (a floating point with an absolute value between 0.5(included) and 1.0(excluded))
* and an integral exponent for 2. */
extern double frexp(double x, int* exp);
/* Returns the result of multiplying x (the significand) by 2 raised to the power of exp (the exponent). */
extern double ldexp(double x, int exp);
/* Returns the natural logarithm of x. */
extern double log(double x);
/* Returns the common (base-2) logarithm of x. */
extern double log2(double x);
/* Returns the common (base-10) logarithm of x. */
extern double log10(double x);
/* Breaks x into an integral and a fractional part. */
extern double modf(double x, double* intpart);
extern float modff(float x, float* intpart);
/* Power functions */
/* Returns base raised to the power exponent. */
extern double pow(double base, double exponent);
/* Returns the square root of x. */
extern double sqrt(double x);
/* Rounding and remainder functions */
/* Rounds x upward, returning the smallest integral value that is not less than x. */
extern double ceil(double x);
/* Rounds x downward, returning the largest integral value that is not greater than x. */
extern double floor(double x);
/* Returns the floating-point remainder of numer/denom (rounded towards zero). */
extern double fmod(double numer, double denom);
/* Return the integral value nearest to x */
extern double round(double x);
/* Rounds x toward zero, returning the nearest integral value that is not larger in magnitude than x. */
extern double trunc(double x);
/* Miscellaneous */
/* Returns the absolute value of x: |x|. */
extern double fabs(double x);
/* C99 extensions */
#define cosf(x) cos(x)
#define sinf(x) sin(x)
#define tanf(x) tan(x)
#define acosf(x) acos(x)
#define asinf(x) asin(x)
#define atanf(x) atan(x)
#define atan2f(y, x) atan2(y, x)
#define coshf(x) cosh(x)
#define sinhf(x) sinh(x)
#define tanhf(x) tanh(x)
#define expf(x) exp(x)
#define frexpf(x, exp) frexp(x, exp)
#define ldexpf(x, exp) ldexp(x, exp)
#define logf(x) log(x)
#define log10f(x) log10(x)
#define powf(base, exponent) pow(base, exponent)
#define sqrtf(x) sqrt(x)
#define roundf(x) round(x)
#define ceilf(x) ceil(x)
#define floorf(x) floor(x)
#define fmodf(numer, denom) fmod(numer, denom)
#define truncf(x) trunc(x)
#define fabsf(x) fabs(x)
#endif