]> pd.if.org Git - pdclib/blob - includes/math.h
ef80c92775d192540504a4ab664b2b5d9ee756f8
[pdclib] / includes / math.h
1 // ----------------------------------------------------------------------------
2 // $Id$
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
7 // Mathematics
8 // ----------------------------------------------------------------------------
9
10 #ifndef __MATH_H
11 #define __MATH_H __MATH_H
12
13 // TODO: Documentation
14
15 // ----------------------------------------------------------------------------
16 // DEFINES
17
18 #define HUGE_VAL  // TODO - personality?
19 #define HUGE_VALF // TODO - personality?
20 #define HUGE_VALL // TODO - personality?
21
22 #define INFINITY // TODO - personality?
23 #define NAN      // TODO - personality?
24
25 #define FP_FAST_FMA  // TODO - personality?
26 #define FP_FAST_FMAF // TODO - personality?
27 #define FP_FAST_FMAL // TODO - personality?
28
29 #define FP_INFINITE  // TODO - personality?
30 #define FP_NAN       // TODO - personality?
31 #define FP_NORMAL    // TODO - personality?
32 #define FP_SUBNORMAL // TODO - personality?
33 #define FP_ZERO      // TODO - personality?
34
35 #define FP_ILOGB0   // TODO - personality?
36 #define FP_ILOGBNAN // TODO - personality?
37
38 #define MATH_ERRNO       1 // personality?
39 #define MATH_ERREXCEPT   2 // personality?
40 #define math_errhandling // TODO - personality?
41
42 // --------------------------------------------------------------------------
43 // TYPEDEFS
44
45 typedef double_t; // TODO - personality?
46 typedef float_t;  // TODO - personality?
47
48 // --------------------------------------------------------------------------
49 // MACROS
50
51 #define isgreater( x, y )      // TODO
52 #define isgreaterequal( x, y ) // TODO
53 #define isless( x, y )         // TODO
54 #define islessequal( x, y )    // TODO
55 #define islessgreater( x, y )  // TODO
56 #define isunordered( x, y )    // TODO
57 #define fpclassify( x )        // TODO
58 #define isfinite( x )          // TODO
59
60 #define isinf( x )             // TODO
61 #define isnan( x )             // TODO
62 #define isnormal( x )          // TODO
63 #define signbit( x )           // TODO
64
65 // ----------------------------------------------------------------------------
66 // FUNCTIONS
67
68 // These functions return the magnitude of their parameter.
69 double      fabs( double       x );
70 float       fabsf( float       x );
71 long double fabsl( long double x );
72
73 // These functions compute the sine of x (measured in radians).
74 double      sin( double       x );
75 float       sinf( float       x );
76 long double sinl( long double x );
77
78 // These functions return the hyperbolic cosine of their parameter.
79 double      sinh( double       x );
80 float       sinhf( float       x );
81 long double sinhl( long double x );
82
83 // These functions return the arcsine of their parameter.
84 double      asin( double       x );
85 float       asinf( float       x );
86 long double asinl( long double x );
87
88 // These functions return the hyperbolic arcsine of their parameter.
89 double      asinh( double       x );
90 float       asinhf( float       x );
91 long double asinhl( long double x );
92
93 // These functions compute the cosine of x (measured in radians).
94 double      cos( double       x );
95 float       cosf( float       x );
96 long double cosl( long double x );
97
98 // These functions return the hyperbolic cosine of their parameter.
99 double      cosh( double       x );
100 float       coshf( float       x );
101 long double coshl( long double x );
102
103 // These functions return the arccosine of their parameter.
104 double      acos( double       x );
105 float       acosf( float       x );
106 long double acosl( long double x );
107
108 // These functions return the hyperbolic arccosine of their parameter.
109 double      acosh( double       x );
110 float       acoshf( float       x );
111 long double acoshl( long double x );
112
113 // These functions return the tangent of x.
114 double      tan( double       x );
115 float       tanf( float       x );
116 long double tanl( long double x );
117
118 // These functions return the hyperbolic tangent of their parameter.
119 double      tanh( double       x );
120 float       tanhf( float       x );
121 long double tanhl( long double x );
122
123 // These functions compute the arctangent of x.
124 double      atan( double       x );
125 float       atanf( float       x );
126 long double atanl( long double x );
127
128 // These functions return the hyperbolic arctangent of their parameter.
129 double      atanh( double       x );
130 float       atanhf( float       x );
131 long double atanhl( long double x );
132
133 // TODO
134 double      atan2( double       y, double      x );
135 float       atan2f( float       y, float       x );
136 long double atan2l( long double y, long double x );
137
138 // These functions return sqrt(x^2 + y^2 ).
139 double      hypot( double       x, double      y );
140 float       hypotf( float       x, float       y );
141 long double hypotl( long double x, long double y );
142
143 // These functions return their parameter x, raised to the power y.
144 double      pow( double       x, double      y );
145 float       powf( float       x, float       y );
146 long double powl( long double x, long double y );
147
148 // These functions return the square root of their parameter.
149 double      sqrt( double       x );
150 float       sqrtf( float       x );
151 long double sqrtl( long double x );
152
153 // TODO
154 double      cbrt( double       x );
155 float       cbrtf( float       x );
156 long double cbrtl( long double x );
157
158 // TODO
159 double      exp( double       x );
160 float       expf( float       x );
161 long double expl( long double x );
162
163 // TODO
164 double      exp2( double       x );
165 float       exp2f( float       x );
166 long double exp2l( long double x );
167
168 // TODO
169 double      expm1( double       x );
170 float       expm1f( float       x );
171 long double expm1l( long double x );
172
173 // TODO
174 double      frexp( double       x, int * exp );
175 float       frexpf( float       x, int * exp );
176 long double frexpl( long double x, int * exp );
177
178 // TODO
179 double      ldexp( double       x, int exp );
180 float       ldexpf( float       x, int exp );
181 long double ldexpl( long double x, int exp );
182
183 // These functions return the natural logarithm of their parameter.
184 double      log( double       x );
185 float       logf( float       x );
186 long double logl( long double x );
187
188 // These functions return the logarithm (base 10 ) of their parameter.
189 double      log10( double       x );
190 float       log10f( float       x );
191 long double log10l( long double x );
192
193 // These functions return the logarithm (base 2 ) of their parameter.
194 double      log2( double       x );
195 float       log2f( float       x );
196 long double log2l( long double x );
197
198 // TODO
199 double      logb( double       x );
200 float       logbf( float       x );
201 long double logbl( long double x );
202
203 // TODO
204 int ilogb( double       x );
205 int ilogbf( float       x );
206 int ilogbl( long double x );
207
208 // TODO
209 double      log1p( double       x );
210 float       log1pf( float       x );
211 long double log1pl( long double x );
212
213 // These functions return the smallest integer no smaller than value.
214 double      ceil( double       x );
215 float       ceilf( float       x );
216 long double ceill( long double x );
217
218 // These functions return the largest integer no larger than their parameter.
219 double      floor( double       x );
220 float       floorf( float       x );
221 long double floorl( long double x );
222
223 // TODO
224 double      fmod( double       x, double      y );
225 float       fmodf( float       x, float       y );
226 long double fmodl( long double x, long double y );
227
228 // TODO
229 double      modf( double       x, double *      integer );
230 float       modff( float       x, float *       integer );
231 long double modfl( long double x, long double * integer );
232
233 // These functions return their parameter x, with the sign of parameter y.
234 double      copysign( double       x, double      y );
235 float       copysignf( float       x, float       y );
236 long double copysignl( long double x, long double y );
237
238 // TODO
239 double      erf( double       x );
240 float       erff( float       x );
241 long double erfl( long double x );
242
243 // TODO
244 double      erfc( double       x );
245 float       erfcf( float       x );
246 long double erfcl( long double x );
247
248 // TODO
249 double      fdim( double       x, double      y );
250 float       fdimf( float       x, float       y );
251 long double fdiml( long double x, long double y );
252
253 // TODO
254 double      fma( double       x, double      y, double      z );
255 float       fmaf( float       x, float       y, float       z );
256 long double fmal( long double x, long double y, long double z );
257
258 // These functions return the larger of their parameters.
259 double      fmax( double       x, double      y );
260 float       fmaxf( float       x, float       y );
261 long double fmaxl( long double x, long double y );
262
263 // These functions return the smaller of their parameters.
264 double      fmin( double       x, double      y );
265 float       fminf( float       x, float       y );
266 long double fminl( long double x, long double y );
267
268 // TODO
269 long long llrint( double       x );
270 long long llrintf( float       x );
271 long long llrintl( long double x );
272 long lrint( double       x );
273 long lrintf( float       x );
274 long lrintl( long double x );
275 double      rint( double       x );
276 float       rintf( float       x );
277 long double rintl( long double x );
278
279 // TODO
280 long long llround( double       x );
281 long long llroundf( float       x );
282 long long llroundl( long double x );
283 long lround( double       x );
284 long lroundf( float       x );
285 long lroundl( long double x );
286 double      round( double       x );
287 float       roundf( float       x );
288 long double roundl( long double x );
289
290 // TODO
291 double      trunc( double       x );
292 float       truncf( float       x );
293 long double truncl( long double x );
294
295 double      nearbyint( double       x );
296 float       nearbyintf( float       x );
297 long double nearbyintl( long double x );
298
299 double      nextafter( double       x, double      y );
300 float       nextafterf( float       x, float       y );
301 long double nextafterl( long double x, long double y );
302
303 // TODO
304 double      nexttoward( double       x, long double y );
305 float       nexttowardf( float       x, long double y );
306 long double nexttowardl( long double x, long double y );
307
308 // TODO
309 double      remainder( double       x, double      y );
310 float       remainderf( float       x, float       y );
311 long double remainderl( long double x, long double y );
312
313 // TODO
314 double      remquo( double       x, double      y, int * pquo );
315 float       remquof( float       x, float       y, int * pquo );
316 long double remquol( long double x, long double y, int * pquo );
317
318 // TODO
319 double      scalbn( double       x, int ex );
320 float       scalbnf( float       x, int ex );
321 long double scalbnl( long double x, int ex );
322
323 // TODO
324 double      scalbln( double       x, long ex );
325 float       scalblnf( float       x, long ex );
326 long double scalblnl( long double x, long ex );
327
328 // TODO
329 double      lgamma( double       x );
330 float       lgammaf( float       x );
331 long double lgammal( long double x );
332
333 // TODO
334 double      tgamma( double       x );
335 float       tgammaf( float       x );
336 long double tgammal( long double x );
337
338 // TODO
339 double      nan( const char  *str );
340 float       nanf( const char *str );
341 long double nanl( const char *str );
342
343 #endif // __MATH_H