]> pd.if.org Git - pdclib/blob - includes/tgmath.h
Some cleanup.
[pdclib] / includes / tgmath.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 // Type-generic math
8 // ----------------------------------------------------------------------------
9
10 #ifndef __TGMATH_H
11 #define __TGMATH_H __TGMATH_H
12
13 // These functions return the sine of their parameter.
14 double               sin(double               value);
15 float                sin(float                value);
16 long double          sin(long double          value);
17 double _Complex      sin(double _Complex      value);
18 float _Complex       sin(float _Complex       value);
19 long double _Complex sin(long double _Complex value);
20
21 // These functions return the hyperbolic sine of their parameter.
22 double               sinh(double               value);
23 float                sinh(float                value);
24 long double          sinh(long double          value);
25 double _Complex      sinh(double _Complex      value);
26 float _Complex       sinh(float _Complex       value);
27 long double _Complex sinh(long double _Complex value);
28
29 // These functions return the arcsine of their parameter.
30 double               asin(double               value);
31 float                asin(float                value);
32 long double          asin(long double          value);
33 double _Complex      asin(double _Complex      value);
34 float _Complex       asin(float _Complex       value);
35 long double _Complex asin(long double _Complex value);
36
37 // These functions return the hyperbolic arcsine of their parameter.
38 double               asinh(double               value);
39 float                asinh(float                value);
40 long double          asinh(long double          value);
41 double _Complex      asinh(double _Complex      value);
42 float _Complex       asinh(float _Complex       value);
43 long double _Complex asinh(long double _Complex value);
44
45 // These functions return the cosine of their parameter.
46 double               cos(double               value);
47 float                cos(float                value);
48 long double          cos(long double          value);
49 double _Complex      cos(double _Complex      value);
50 float _Complex       cos(float _Complex       value);
51 long double _Complex cos(long double _Complex value);
52
53 // These functions return the hyperbolic cosine of their parameter.
54 double               cosh(double               value);
55 float                cosh(float                value);
56 long double          cosh(long double          value);
57 double _Complex      cosh(double _Complex      value);
58 float _Complex       cosh(float _Complex       value);
59 long double _Complex cosh(long double _Complex value);
60
61 // These functions return the arccosine of their parameter.
62 double               acos(double               value);
63 float                acos(float                value);
64 long double          acos(long double          value);
65 double _Complex      acos(double _Complex      value);
66 float _Complex       acos(float _Complex       value);
67 long double _Complex acos(long double _Complex value);
68
69 // These functions return the hyperbolic arccosine of their parameter.
70 double               acosh(double               value);
71 float                acosh(float                value);
72 long double          acosh(long double          value);
73 double _Complex      acosh(double _Complex      value);
74 float _Complex       acosh(float _Complex       value);
75 long double _Complex acosh(long double _Complex value);
76
77 // These functions return the tangent of their parameter.
78 double               tan(double               value);
79 float                tan(float                value);
80 long double          tan(long double          value);
81 double _Complex      tan(double _Complex      value);
82 float _Complex       tan(float _Complex       value);
83 long double _Complex tan(long double _Complex value);
84
85 // These functions return the hyperbolic tangent of their parameter.
86 double               tanh(double               value);
87 float                tanh(float                value);
88 long double          tanh(long double          value);
89 double _Complex      tanh(double _Complex      value);
90 float _Complex       tanh(float _Complex       value);
91 long double _Complex tanh(long double _Complex value);
92
93 // These functions return the arctangent of their parameter.
94 double               atan(double               value);
95 float                atan(float                value);
96 long double          atan(long double          value);
97 double _Complex      atan(double _Complex      value);
98 float _Complex       atan(float _Complex       value);
99 long double _Complex atan(long double _Complex value);
100
101 // These functions return the hyperbolic arctangent of their parameter.
102 double               atanh(double               value);
103 float                atanh(float                value);
104 long double          atanh(long double          value);
105 double _Complex      atanh(double _Complex      value);
106 float _Complex       atanh(float _Complex       value);
107 long double _Complex atanh(long double _Complex value);
108
109 // These functions return the angle whose tangent is x / y.
110 double      atan2(double      x, double      y);
111 float       atan2(float       x, float       y);
112 long double atan2(long double x, long double y);
113
114 // These functions return the phase angle of their parameter.
115 double      carg(double _Complex      value);
116 float       carg(float _Complex       value);
117 long double carg(long double _Complex value);
118
119 // These functions return the largest integer no larger than their parameter.
120 double      floor(double      value);
121 float       floor(float       value);
122 long double floor(long double value);
123
124 // These functions return the smallest integer not less than their parameter.
125 double      ceil(double      value);
126 float       ceil(float       value);
127 long double ceil(long double value);
128
129 // These functions return the square root of their parameter.
130 double               sqrt(double               value);
131 float                sqrt(float                value);
132 long double          sqrt(long double          value);
133 double _Complex      sqrt(double _Complex      value);
134 float _Complex       sqrt(float _Complex       value);
135 long double _Complex sqrt(long double _Complex value);
136
137 // These functions return the cube root of their parameter.
138 double      cbrt(double      value);
139 float       cbrt(float       value);
140 long double cbrt(long double value);
141
142 // These functions return the imaginary part of their parameter.
143 double      cimag(double _Complex      value);
144 float       cimag(float _Complex       value);
145 long double cimag(long double _Complex value);
146
147 // These functions return the real value of their parameter.
148 double      creal(double _Complex      value);
149 float       creal(float _Complex       value);
150 long double creal(long double _Complex value);
151
152 // These functions return the conjugate of their parameter.
153 double _Complex      conj(double _Complex      value);
154 float _Complex       conj(float _Complex       value);
155 long double _Complex conj(long double _Complex value);
156
157 // These functions return their parameter x with the sign of y.
158 double      copysign(double      x, double      y);
159 float       copysign(float       x, float       y);
160 long double copysign(long double x, long double y);
161
162 // These functions return the projection of their parameter.
163 double _Complex      cproj(double _Complex      value);
164 float _Complex       cproj(float _Complex       value);
165 long double _Complex cproj(long double _Complex value);
166
167 // These functions return the error function of their parameter.
168 double      erf(double      value);
169 float       erf(float       value);
170 long double erf(long double value);
171
172 // These functions return the complementary error function of their parameter.
173 double      erfc(double      value);
174 float       erfc(float       value);
175 long double erfc(long double value);
176
177 // These functions return the exponential of their parameter (e^x).
178 double               exp(double               value);
179 float                exp(float                value);
180 long double          exp(long double          value);
181 double _Complex      exp(double _Complex      value);
182 float _Complex       exp(float _Complex       value);
183 long double _Complex exp(long double _Complex value);
184
185 // These functions return 2 raised to the power of their parameter (2^x).
186 double      exp2(double      value);
187 float       exp2(float       value);
188 long double exp2(long double value);
189
190 // These functions return exp(value) - 1.
191 double      expm1(double      value);
192 float       expm1(float       value);
193 long double expm1(long double value);
194
195 // These functions return the magnitude of their parameter.
196 double      fabs(double               value);
197 float       fabs(float                value);
198 long double fabs(long double          value);
199 double      fabs(double _Complex      value);
200 float       fabs(float _Complex       value);
201 long double fabs(long double _Complex value);
202
203 // These functions return the larger of (x-y) and zero.
204 double      fdim(double      x, double      y);
205 float       fdim(float       x, float       y);
206 long double fdim(long double x, long double y);
207
208 // These functions return (x * y + z) to arbitrary intermediate precision.
209 double      fma(double      x, double      y, double      z);
210 float       fma(float       x, float       y, float       z);
211 long double fma(long double x, long double y, long double z);
212
213 // These functions return the larger of their parameters.
214 double      fmax(double      x, double      y);
215 float       fmax(float       x, float       y);
216 long double fmax(long double x, long double y);
217
218 // These functions return the smaller of their parameters.
219 double      fmin(double      x, double      y);
220 float       fmin(float       x, float       y);
221 long double fmin(long double x, long double y);
222
223 // These functions return the remainder of (x/y).
224 double      fmod(double      x, double      y);
225 float       fmod(float       x, float       y);
226 long double fmod(long double x, long double y);
227
228 // These functions return a fraction (as return value) and an integer
229 // exponent (in the parameter 'exponent') that represent value, with the
230 // fraction being in the interval [0.5, 1) or being zero. If value is zero,
231 // exponent will also be zero.
232 // (fraction * 2^exponent) == value)
233 double      frexp(double      value, int * exponent);
234 float       frexp(float       value, int * exponent);
235 long double frexp(long double value, int * exponent);
236
237 // These functions return x raised to the power of y.
238 double               pow(double               x, double               y);
239 float                pow(float                x, float                y);
240 long double          pow(long double          x, long double          y);
241 double _Complex      pow(double _Complex      x, double _Complex      y);
242 float _Complex       pow(float _Complex       x, float _Complex       y);
243 long double _Complex pow(long double _Complex x, long double _Complex y);
244
245 // TODO: Check spelling of hypothenuse and cathedes.
246 // These functions determine the length of the hypothenuse for the cathedes
247 // x and y. (Square root of a^2 + b^2.)
248 double      hypot(double      a, double      b);
249 float       hypot(float       a, float       b);
250 long double hypot(long double a, long double b);
251
252 // These functions return (int) logb(value).
253 int ilogb(double      value);
254 int ilogb(float       value);
255 int ilogb(long double value);
256
257 // These functions return (value * 2^exponent).
258 double      ldexp(double      value, int exponent);
259 float       ldexp(float       value, int exponent);
260 long double ldexp(long double value, int exponent);
261
262 // These functions return the natural logarithm of their parameter.
263 double               log(double               value);
264 float                log(float                value);
265 long double          log(long double          value);
266 double _Complex      log(double _Complex      value);
267 float _Complex       log(float _Complex       value);
268 long double _Complex log(long double _Complex value);
269
270 // These functions return the logarithm (base 10) of their parameter.
271 double      log10(double      value);
272 float       log10(float       value);
273 long double log10(long double value);
274
275 // These functions return the natural logarithm of (their parameter + 1).
276 double      log1p(double      value);
277 float       log1p(float       value);
278 long double log1p(long double value);
279
280 // These functions return the logarithm (base 2) of their parameter.
281 double      log2(double      value);
282 float       log2(float       value);
283 long double log2(long double value);
284
285 // TODO: What do these functions actually do?
286 double      logb(double      value);
287 float       logb(float       value);
288 long double logb(long double value);
289
290 // These functions return their parameter rounded to the next integer, using
291 // the current rounding mode.
292 long long   llrint(double      value);
293 long long   llrint(float       value);
294 long long   llrint(long double value);
295 long        lrint(double       value);
296 long        lrint(float        value);
297 long        lrint(long double  value);
298 double      rint(double        value);
299 float       rint(float         value);
300 long double rint(long double   value);
301
302 // These functions return their parameter rounded to the next integer, with
303 // halfway values rounded away from zero regardless of current rounding mode.
304 long long   llround(double      value);
305 long long   llround(float       value);
306 long long   llround(long double value);
307 long        lround(double       value);
308 long        lround(float        value);
309 long        lround(long double  value);
310 // TODO: Do the round() functions really return FP values?
311 double      round(double        value);
312 float       round(float         value);
313 long double round(long double   value);
314
315 // These functions return their parameter, rounded toward zero.
316 // TODO: Do these functions really return FP values?
317 double      trunc(double      value);
318 float       trunc(float       value);
319 long double trunc(long double value);
320
321 // These functions store the integer part of value in integer, and return the
322 // remaining part of value.
323 double      modf(double      value, double *      integer);
324 float       modf(float       value, float *       integer);
325 long double modf(long double value, long double * integer);
326
327 // These functions return their parameter rounded to the next integer, using
328 // the current rounding mode but without raising an inexact FP exception.
329 double      nearbyint(double      value);
330 float       nearbyint(float       value);
331 long double nearbyint(long double value);
332
333 // These functions return the next representable value after the smaller of
334 // their parameters.
335 // TODO: This might be a wrong description.
336 double      nextafter(double      x, double      y);
337 float       nextafter(float       x, float       y);
338 long double nextafter(long double x, long double y);
339
340 // These functions return the next representable value after the smaller of
341 // their parameters.
342 // TODO: This might be a wrong description.
343 double      nexttoward(double      x, long double y);
344 float       nexttoward(float       x, long double y);
345 long double nexttoward(long double x, long double y);
346
347 // TODO
348 double      remainder(double      x, double      y);
349 float       remainder(float       x, float       y);
350 long double remainder(long double x, long double y);
351
352 // TODO
353 double      remquo(double      x, double      y, int * pquo);
354 float       remquo(float       x, float       y, int * pquo);
355 long double remquo(long double x, long double y, int * pquo);
356
357 // TODO
358 double      scalbln(double      x, long ex);
359 float       scalbln(float       x, long ex);
360 long double scalbln(long double x, long ex);
361
362 // TODO
363 double      scalbn(double      x, int ex);
364 float       scalbn(float       x, int ex);
365 long double scalbn(long double x, int ex);
366
367 // These functions return the gamma function of their parameter.
368 double      tgamma(double      value);
369 float       tgamma(float       value);
370 long double tgamma(long double value);
371
372 // These functions return log( fabs( tgamma(value) ) ).
373 double      lgamma(double      value);
374 float       lgamma(float       value);
375 long double lgamma(long double value);
376
377 #endif // __TGMATH_H