]> pd.if.org Git - pdclib/blob - includes/math.h
Re-import from Subversion.
[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
19 #define HUGE_VAL  ((double)0x7FF0000000000000)          /* TODO */
20 #define HUGE_VALF ((float)0x7F800000)                   /* TODO */
21 #define HUGE_VALL ((long double)0x7FFF8000000000000000) /* TODO */
22
23 #define INFINITY ((float)0x7F800000) /* TODO */
24 #define NAN      ((float)0x7F800001) /* TODO */
25
26 /* The following values are platform dependant, must be personality. */
27 #if 0
28 #define FP_FAST_FMA  /* TODO */
29 #define FP_FAST_FMAF /* TODO */
30 #define FP_FAST_FMAL /* TODO */
31 #endif
32
33 /* These values are used instead of constants to classify numbers. */
34 #define FP_UNDEFINED 0
35 #define FP_INFINITE  1
36 #define FP_NAN       2
37 #define FP_NORMAL    3
38 #define FP_SUBNORMAL 4
39 #define FP_ZERO      5
40
41 #define FP_ILOGB0   /* TODO */
42 #define FP_ILOGBNAN /* TODO */
43
44 #define MATH_ERRNO       1
45 #define MATH_ERREXCEPT   2
46
47 /* should be MATH_ERRNO | MATH_ERREXCEPT if we do exceptions. Do we? It's 
48  * nice if this is implementation-wide the same.
49  */
50 #define math_errhandling ((int)MATH_ERRNO)
51
52 /* ----------------------------------------------------------------------------
53  * TYPEDEFS
54  * --------------------------------------------------------------------------*/
55
56 typedef double_t
57 #if FLT_EVAL_METHOD == 0
58     double
59 #elif FLT_EVAL_METHOD == 1
60     double
61 #elif FLT_EVAL_METHOD == 2
62     long double
63 #else
64     /* TODO - this is implementation defined and cpu dependant */
65 #endif
66 ;
67
68 typedef float_t
69 #if FLT_EVAL_METHOD == 0
70     float
71 #elif FLT_EVAL_METHOD == 1
72     double
73 #elif FLT_EVAL_METHOD == 2
74     long double
75 #else
76     /* TODO - this is implementation defined and cpu dependant */
77 #endif
78 ;
79
80 /* ----------------------------------------------------------------------------
81  * MACROS
82  * --------------------------------------------------------------------------*/
83
84 #define isgreater( x, y )      /* TODO */
85 #define isgreaterequal( x, y ) /* TODO */
86 #define isless( x, y )         /* TODO */
87 #define islessequal( x, y )    /* TODO */
88 #define islessgreater( x, y )  /* TODO */
89 #define isunordered( x, y )    /* TODO */
90
91 /* Could somebody clean this macro up? It uses 7 other definitions (below).
92  * Also, I suspect this macro to be personality-dependant. Somebody confirm
93  * or deny?
94  */
95 #define fp_mef 0x7F800000
96 #define fp_mff 0x007FFFFF
97 #define fp_med 0x7FF0000000000000
98 #define fp_mfd 0x000FFFFFFFFFFFFF
99 #define fp_mel 0x7FFF8000000000000000
100 #define fp_mjl 0x00004000000000000000 // the j-bit mask
101 #define fp_mfl 0x00003FFFFFFFFFFFFFFF
102
103 #define fpclassify( x ) ((sizeof(x) == sizeof(float)) ? ( \
104                           (((x) & fp_mef) == (fp_mef)) ? ( \
105                            (((x) & fp_mff) == (0)) ? ( \
106                             FP_INFINITY \
107                            ) : ( \
108                             FP_NAN \
109                            ) \
110                           ) : ( \
111                            (((x) & fp_mef) == (0)) ? ( \
112                             (((x) & fp_mff) == (0)) ? ( \
113                              FP_ZERO \
114                             ) : ( \
115                              FP_DENORMAL \
116                             ) \
117                            ) : ( \
118                             FP_NORMAL \
119                            ) \
120                           ) \
121                          ) : (
122                           (sizeof(x) == sizeof(double)) ? ( \
123                            (((x) & fp_med) == (fp_med)) ? ( \
124                             (((x) & fp_mfd) == (0)) ? ( \
125                              FP_INFINITY \
126                             ) : ( \
127                              FP_NAN \
128                             ) \
129                            ) : ( \
130                             (((x) & fp_med) == (0)) ? ( \
131                              (((x) & fp_mfd) == (0)) ? ( \
132                               FP_ZERO \
133                              ) : ( \
134                               FP_DENORMAL \
135                              ) \
136                             ) : ( \
137                              FP_NORMAL \
138                             ) \
139                            ) \
140                           ) : ( \
141                            (((x) & fp_mel) == (fp_mel)) ? ( \
142                             (((x) & fp_mjl) == (fp_mjl)) ? ( \
143                              FP_UNSUPPORTED \
144                             ) : ( \
145                              (((x) & fp_mfl) == (fp_mfl)) ? ( \
146                               FP_NAN \
147                              ) : ( \
148                               FP_INFINITY \
149                              ) \
150                             ) \
151                            ) : ( \
152                             (((x) & fp_mel) == (0)) ? ( \
153                              (((x) & fp_mjl) == (fp_mjl)) ? ( \
154                               FP_NORMAL \ // or actually, pseudo-denormal
155                              ) : ( \
156                               (((x) & fp_mfl) == (fp_mfl)) ? ( \
157                                FP_DENORMAL \
158                               ) : ( \
159                                FP_ZERO \
160                               ) \
161                              ) \
162                             ) : ( \
163                              (((x) & fp_mjl) == (fp_mjl)) ? ( \
164                               FP_NORMAL \
165                              ) : ( \
166                               FP_UNDEFINED \
167                              ) \
168                             ) \
169                            ) \
170                           ) \
171                          ) \
172                         )
173
174 #define isfinite( x )   ((sizeof(x) == sizeof(float)) ? ( \
175                           (((x) & fp_mef) == (fp_mef)) ? ( \
176                            0 \
177                           ) : ( \
178                            1 \
179                           ) \
180                          ) : (
181                           (sizeof(x) == sizeof(double)) ? ( \
182                            (((x) & fp_med) == (fp_med)) ? ( \
183                             0 \
184                            ) : ( \
185                             1 \
186                            ) \
187                           ) : ( \
188                            (((x) & fp_mel) == (fp_mel)) ? ( \
189                             0 \
190                            ) : ( \
191                             (((x) & fp_mel) == (0)) ? ( \
192                              (((x) & fp_mjl) == (fp_mjl)) ? ( \
193                               1 \
194                              ) : ( \
195                               0 \
196                              ) \
197                             ) : ( \
198                              (((x) & fp_mjl) == (fp_mjl)) ? ( \
199                               1 \
200                              ) : ( \
201                               0 \
202                              ) \
203                             ) \
204                            ) \
205                           ) \
206                          ) \
207                         )
208
209 #define isinf( x )      ((sizeof(x) == sizeof(float)) ? ( \
210                           (((x) & fp_mef) == (fp_mef)) ? ( \
211                            (((x) & fp_mff) == (0)) ? ( \
212                             1 \
213                            ) : ( \
214                             0 \
215                            ) \
216                           ) : ( \
217                            0 \
218                           ) \
219                          ) : ((sizeof(x) == sizeof(double)) ? ( \
220                            (((x) & fp_med) == (fp_med)) ? ( \
221                             (((x) & fp_mfd) == (0)) ? ( \
222                              1 \
223                             ) : ( \
224                              0 \
225                             ) \
226                            ) : ( \
227                             0 \
228                            ) \
229                           ) : ( \
230                            (((x) & fp_mel) == (fp_mel)) ? ( \
231                             (((x) & fp_mjl) == (0)) ? ( \
232                              (((x) & fp_mfl) == (fp_mfl)) ? ( \
233                               0 \
234                              ) : ( \
235                               1 \
236                              ) \
237                             ) : ( \
238                              0 \
239                             ) \
240                            ) : ( \
241                             0 \
242                            ) \
243                           ) \
244                          ) \
245                         )
246
247 #define isnan( x )      ((sizeof(x) == sizeof(float)) ? ( \
248                           (((x) & fp_mef) == (fp_mef)) ? ( \
249                            (((x) & fp_mff) == (0)) ? ( \
250                             0 \
251                            ) : ( \
252                             1 \
253                            ) \
254                           ) : ( \
255                            0 \
256                           ) \
257                          ) : ((sizeof(x) == sizeof(double)) ? ( \
258                            (((x) & fp_med) == (fp_med)) ? ( \
259                             (((x) & fp_mfd) == (0)) ? ( \
260                              0 \
261                             ) : ( \
262                              1 \
263                             ) \
264                            ) : ( \
265                             0 \
266                            ) \
267                           ) : ( \
268                            (((x) & fp_mel) == (fp_mel)) ? ( \
269                             (((x) & fp_mjl) == (0)) ? ( \
270                              (((x) & fp_mfl) == (fp_mfl)) ? ( \
271                               1 \
272                              ) : ( \
273                               0 \
274                              ) \
275                             ) : ( \
276                              0 \
277                             ) \
278                            ) : ( \
279                             0 \
280                            ) \
281                           ) \
282                          ) \
283                         )
284
285 #define isnormal( x )   ((sizeof(x) == sizeof(float)) ? ( \
286                           (((x) & fp_mef) == (fp_mef)) ? ( \
287                            0 \
288                           ) : ( \
289                            (((x) & fp_mef) == (0)) ? ( \
290                             0 \
291                            ) : ( \
292                             1 \
293                            ) \
294                           ) \
295                          ) : ((sizeof(x) == sizeof(double)) ? ( \
296                            (((x) & fp_med) == (fp_med)) ? ( \
297                             0 \
298                            ) : ( \
299                             (((x) & fp_med) == (0)) ? ( \
300                              0 \
301                             ) : ( \
302                              1 \
303                             ) \
304                            ) \
305                           ) : ( \
306                            (((x) & fp_mel) == (fp_mel)) ? ( \
307                             0 \
308                            ) : ( \
309                             (((x) & fp_mel) == (0)) ? ( \
310                              (((x) & fp_mjl) == (fp_mjl)) ? ( \
311                               1 \
312                              ) : ( \
313                               0 \
314                              ) \
315                             ) : ( \
316                              (((x) & fp_mjl) == (fp_mjl)) ? ( \
317                               1 \
318                              ) : ( \
319                               0 \
320                              ) \
321                             ) \
322                            ) \
323                           ) \
324                          ) \
325                         )
326
327 #define signbit( x )    ((sizeof(x) == sizeof(float)) ? ( \
328                           (((x) & 0x80000000) == (0)) ? ( \
329                            0 \
330                           ) : ( \
331                            1 \
332                           ) \
333                          ) : ((sizeof(x) == sizeof(double)) ? ( \
334                            (((x) & 0x8000000000000000) == (0)) ? ( \
335                             0 \
336                            ) : ( \
337                             1 \
338                            ) \
339                           ) : ( \
340                            (((x) & 0x80000000000000000000) == (0)) ? ( \
341                             0 \
342                            ) : ( \
343                             1 \
344                            ) \
345                           ) \
346                          ) \
347                         )
348
349 /* ----------------------------------------------------------------------------
350  * FUNCTIONS
351  * --------------------------------------------------------------------------*/
352
353 /** These functions return the magnitude of x.
354  *  @param x The value to find the absolute value of.
355  *  @return The absolute value of x.
356  *  @see fabsl()
357  *  @see fabsf()
358  */
359 double      fabs( double       x );
360
361 /** These functions return the magnitude of x.
362  *  @param x The value to find the absolute value of.
363  *  @return The absolute value of x.
364  *  @see fabsl()
365  *  @see fabs()
366  */
367 float       fabsf( float       x );
368
369 /** These functions return the magnitude of x.
370  *  @param x The value to find the absolute value of.
371  *  @return The absolute value of x.
372  *  @see fabs()
373  *  @see fabsf()
374  */
375 long double fabsl( long double x );
376
377 /** These functions compute the sine of x (measured in radians).
378  *  @param x The value to compute the sine of.
379  *  @return The sine of x.
380  *  @see sinf()
381  *  @see sinl()
382  *  @see cos()
383  *  @see tan()
384  *  @see sinh()
385  *  @see asin()
386  */
387 double      sin( double       x );
388
389 /** These functions compute the sine of x (measured in radians).
390  *  @param x The value to compute the sine of.
391  *  @return The sine of x.
392  *  @see sin()
393  *  @see sinl()
394  *  @see cosf()
395  *  @see tanf()
396  *  @see sinhf()
397  *  @see asinf()
398  */
399 float       sinf( float       x );
400
401 /** These functions compute the sine of x (measured in radians).
402  *  @param x The value to compute the sine of.
403  *  @return The sine of x.
404  *  @see sinf()
405  *  @see sin()
406  *  @see cosl()
407  *  @see tanl()
408  *  @see sinhl()
409  *  @see asinl()
410  */
411 long double sinl( long double x );
412
413 /** These functions compute the hyperbolic sine of x (measured in radians).
414  *  @param x The value to compute the hyperbolic sine of.
415  *  @return The hyperbolic sine of x.
416  *  @see sinhf()
417  *  @see sinhl()
418  *  @see sin()
419  *  @see cosh()
420  *  @see tanh()
421  *  @see asinh()
422  */
423 double      sinh( double       x );
424
425 /** These functions compute the hyperbolic sine of x (measured in radians).
426  *  @param x The value to compute the hyperbolic sine of.
427  *  @return The hyperbolic sine of x.
428  *  @see sinh()
429  *  @see sinhl()
430  *  @see sinf()
431  *  @see coshf()
432  *  @see tanhf()
433  *  @see asinhf()
434  */
435 float       sinhf( float       x );
436
437 /** These functions compute the hyperbolic sine of x (measured in radians).
438  *  @param x The value to compute the hyperbolic sine of.
439  *  @return The hyperbolic sine of x.
440  *  @see sinh()
441  *  @see sinhf()
442  *  @see sinl()
443  *  @see coshl()
444  *  @see tanhl()
445  *  @see asinhl()
446  */
447 long double sinhl( long double x );
448
449 /** These functions compute the arcsine of x (measured in radians).
450  *  @param x The value to compute the arcsine of.
451  *  @return The arcsine of x.
452  *  @see asinf()
453  *  @see asinl()
454  *  @see sin()
455  *  @see acos()
456  *  @see atan()
457  *  @see asinh()
458  */
459 double      asin( double       x );
460
461 /** These functions compute the arcsine of x (measured in radians).
462  *  @param x The value to compute the arcsine of.
463  *  @return The arcsine of x.
464  *  @see asin()
465  *  @see asinl()
466  *  @see sinf()
467  *  @see acosf()
468  *  @see atanf()
469  *  @see asinhf()
470  */
471 float       asinf( float       x );
472
473 /** These functions compute the arcsine of x (measured in radians).
474  *  @param x The value to compute the arcsine of.
475  *  @return The arcsine of x.
476  *  @see asin()
477  *  @see asinf()
478  *  @see sinl()
479  *  @see acosl()
480  *  @see atanl()
481  *  @see asinhl()
482  */
483 long double asinl( long double x );
484
485 /** These functions compute the hyperbolic arcsine of x (measured in radians).
486  *  @param x The value to compute the hyperbolic arcsine of.
487  *  @return The hyperbolic arcsine of x.
488  *  @see asinhf()
489  *  @see asinhl()
490  *  @see asin()
491  *  @see acosh()
492  *  @see atanh()
493  *  @see sinh()
494  */
495 double      asinh( double       x );
496
497 /** These functions compute the hyperbolic arcsine of x (measured in radians).
498  *  @param x The value to compute the hyperbolic arcsine of.
499  *  @return The hyperbolic arcsine of x.
500  *  @see asinh()
501  *  @see asinhl()
502  *  @see asinf()
503  *  @see acoshf()
504  *  @see atanhf()
505  *  @see sinhf()
506  */
507 float       asinhf( float       x );
508
509 /** These functions compute the hyperbolic arcsine of x (measured in radians).
510  *  @param x The value to compute the hyperbolic arcsine of.
511  *  @return The hyperbolic arcsine of x.
512  *  @see asinh()
513  *  @see asinhf()
514  *  @see asinl()
515  *  @see acoshl()
516  *  @see atanhl()
517  *  @see sinhl()
518  */
519 long double asinhl( long double x );
520
521 /** These functions compute the cosine of x (measured in radians).
522  *  @param x The value to compute the cosine of.
523  *  @return The cosine of x.
524  *  @see cosf()
525  *  @see cosl()
526  *  @see sin()
527  *  @see cosh()
528  *  @see tan()
529  *  @see acos()
530  */
531 double      cos( double       x );
532
533 /** These functions compute the cosine of x (measured in radians).
534  *  @param x The value to compute the cosine of.
535  *  @return The cosine of x.
536  *  @see cos()
537  *  @see cosl()
538  *  @see sinf()
539  *  @see coshf()
540  *  @see tanf()
541  *  @see acosf()
542  */
543 float       cosf( float       x );
544
545 /** These functions compute the cosine of x (measured in radians).
546  *  @param x The value to compute the cosine of.
547  *  @return The cosine of x.
548  *  @see cos()
549  *  @see cosf()
550  *  @see sinl()
551  *  @see coshl()
552  *  @see tanl()
553  *  @see acosl()
554  */
555 long double cosl( long double x );
556
557 /** These functions compute the hyperbolic cosine of x (measured in radians).
558  *  @param x The value to compute the hyperbolic cosine of.
559  *  @return The hyperbolic cosine of x.
560  *  @see coshf()
561  *  @see coshl()
562  *  @see sinh()
563  *  @see cos()
564  *  @see tanh()
565  *  @see acosh()
566  */
567 double      cosh( double       x );
568
569 /** These functions compute the hyperbolic cosine of x (measured in radians).
570  *  @param x The value to compute the hyperbolic cosine of.
571  *  @return The hyperbolic cosine of x.
572  *  @see cosh()
573  *  @see coshl()
574  *  @see sinhf()
575  *  @see cosf()
576  *  @see tanhf()
577  *  @see acoshf()
578  */
579 float       coshf( float       x );
580
581 /** These functions compute the hyperbolic cosine of x (measured in radians).
582  *  @param x The value to compute the hyperbolic cosine of.
583  *  @return The hyperbolic cosine of x.
584  *  @see cosh()
585  *  @see coshf()
586  *  @see sinhl()
587  *  @see cosl()
588  *  @see tanhl()
589  *  @see acoshl()
590  */
591 long double coshl( long double x );
592
593 /** These functions compute the arccosine of x (measured in radians).
594  *  @param x The value to compute the arccosine of.
595  *  @return The arccosine of x.
596  *  @see acosf()
597  *  @see acosl()
598  *  @see asin()
599  *  @see cos()
600  *  @see atan()
601  *  @see acosh()
602  */
603 double      acos( double       x );
604
605 /** These functions compute the arccosine of x (measured in radians).
606  *  @param x The value to compute the arccosine of.
607  *  @return The arccosine of x.
608  *  @see acos()
609  *  @see acosl()
610  *  @see asinf()
611  *  @see cosf()
612  *  @see atanf()
613  *  @see acoshf()
614  */
615 float       acosf( float       x );
616
617 /** These functions compute the arccosine of x (measured in radians).
618  *  @param x The value to compute the arccosine of.
619  *  @return The arccosine of x.
620  *  @see acos()
621  *  @see acosf()
622  *  @see asinl()
623  *  @see cosl()
624  *  @see atanl()
625  *  @see acoshl()
626  */
627 long double acosl( long double x );
628
629 /** These functions compute the hyperbolic arccosine of x (measured in radians).
630  *  @param x The value to compute the hyperbolic arccosine of.
631  *  @return The hyperbolic arccosine of x.
632  *  @see acoshf()
633  *  @see acoshl()
634  *  @see asinh()
635  *  @see cosh()
636  *  @see atanh()
637  *  @see acos()
638  */
639 double      acosh( double       x );
640
641 /** These functions compute the hyperbolic arccosine of x (measured in radians).
642  *  @param x The value to compute the hyperbolic arccosine of.
643  *  @return The hyperbolic arccosine of x.
644  *  @see acosh()
645  *  @see acoshl()
646  *  @see asinhf()
647  *  @see coshf()
648  *  @see atanhf()
649  *  @see acosf()
650  */
651 float       acoshf( float       x );
652
653 /** These functions compute the hyperbolic arccosine of x (measured in radians).
654  *  @param x The value to compute the hyperbolic arccosine of.
655  *  @return The hyperbolic arccosine of x.
656  *  @see acosh()
657  *  @see acoshf()
658  *  @see asinhl()
659  *  @see coshl()
660  *  @see atanhl()
661  *  @see acosl()
662  */
663 long double acoshl( long double x );
664
665 /** These functions compute the tangent of x (measured in radians).
666  *  @param x The value to compute the tangent of.
667  *  @return The tangent of x.
668  *  @see tanf()
669  *  @see tanl()
670  *  @see sin()
671  *  @see cos()
672  *  @see tanh()
673  *  @see atan()
674  */
675 double      tan( double       x );
676
677 /** These functions compute the tangent of x (measured in radians).
678  *  @param x The value to compute the tangent of.
679  *  @return The tangent of x.
680  *  @see tan()
681  *  @see tanl()
682  *  @see sinf()
683  *  @see cosf()
684  *  @see tanhf()
685  *  @see atanf()
686  */
687 float       tanf( float       x );
688
689 /** These functions compute the tangent of x (measured in radians).
690  *  @param x The value to compute the tangent of.
691  *  @return The tangent of x.
692  *  @see tan()
693  *  @see tanf()
694  *  @see sinl()
695  *  @see cosl()
696  *  @see tanhl()
697  *  @see atanl()
698  */
699 long double tanl( long double x );
700
701 /** These functions compute the hyperbolic tangent of x (measured in radians).
702  *  @param x The value to compute the hyperbolic tangent of.
703  *  @return The hyperbolic tangent of x.
704  *  @see tanhf()
705  *  @see tanhl()
706  *  @see sinh()
707  *  @see cosh()
708  *  @see tan()
709  *  @see atanh()
710  */
711 double      tanh( double       x );
712
713 /** These functions compute the hyperbolic tangent of x (measured in radians).
714  *  @param x The value to compute the hyperbolic tangent of.
715  *  @return The hyperbolic tangent of x.
716  *  @see tanh()
717  *  @see tanhl()
718  *  @see sinhf()
719  *  @see coshf()
720  *  @see tanf()
721  *  @see atanhf()
722  */
723 float       tanhf( float       x );
724
725 /** These functions compute the hyperbolic tangent of x (measured in radians).
726  *  @param x The value to compute the hyperbolic tangent of.
727  *  @return The hyperbolic tangent of x.
728  *  @see tanh()
729  *  @see tanhf()
730  *  @see sinhl()
731  *  @see coshl()
732  *  @see tanl()
733  *  @see atanhl()
734  */
735 long double tanhl( long double x );
736
737 /** These functions compute the arctangent of x (measured in radians).
738  *  @param x The value to compute the arctangent of.
739  *  @return The arctangent of x.
740  *  @see atanf()
741  *  @see atanl()
742  *  @see atan2()
743  *  @see asin()
744  *  @see acos()
745  *  @see tan()
746  *  @see atanh()
747  */
748 double      atan( double       x );
749
750 /** These functions compute the arctangent of x (measured in radians).
751  *  @param x The value to compute the arctangent of.
752  *  @return The arctangent of x.
753  *  @see atan()
754  *  @see atanl()
755  *  @see atan2f()
756  *  @see asinf()
757  *  @see acosf()
758  *  @see tanf()
759  *  @see atanhf()
760  */
761 float       atanf( float       x );
762
763 /** These functions compute the arctangent of x (measured in radians).
764  *  @param x The value to compute the arctangent of.
765  *  @return The arctangent of x.
766  *  @see atan()
767  *  @see atanf()
768  *  @see atan2l()
769  *  @see asinl()
770  *  @see acosl()
771  *  @see tanl()
772  *  @see atanhl()
773  */
774 long double atanl( long double x );
775
776 /** These functions compute the hyperbolic arctangent of x (measured in radians).
777  *  @param x The value to compute the hyperbolic arctangent of.
778  *  @return The hyperbolic arctangent of x.
779  *  @see atanhf()
780  *  @see atanhl()
781  *  @see asinh()
782  *  @see acosh()
783  *  @see tanh()
784  *  @see atan()
785  */
786 double      atanh( double       x );
787
788 /** These functions compute the hyperbolic arctangent of x (measured in radians).
789  *  @param x The value to compute the hyperbolic arctangent of.
790  *  @return The hyperbolic arctangent of x.
791  *  @see atanh()
792  *  @see atanhl()
793  *  @see asinhf()
794  *  @see acoshf()
795  *  @see tanhf()
796  *  @see atanf()
797  */
798 float       atanhf( float       x );
799
800 /** These functions compute the hyperbolic arctangent of x (measured in radians).
801  *  @param x The value to compute the hyperbolic arctangent of.
802  *  @return The hyperbolic arctangent of x.
803  *  @see atanh()
804  *  @see atanhf()
805  *  @see asinhl()
806  *  @see acoshl()
807  *  @see tanhl()
808  *  @see atanl()
809  */
810 long double atanhl( long double x );
811
812 /** These functions compute the hyperbolic arctangent of x / y (measured in radians).
813  *  They return their answer between pi and -pi.
814  *  @param y The first side of the triangle.
815  *  @param x The second side of the triangle.
816  *  @return The angle between the first and the second side.
817  *  @see atan2f()
818  *  @see atan2l()
819  *  @see atan()
820  *  @see asin()
821  *  @see acos()
822  *  @see atanh()
823  *  @see tanh()
824  */
825 double      atan2( double       y, double      x );
826
827 /** These functions compute the hyperbolic arctangent of x / y (measured in radians).
828  *  They return their answer between pi and -pi.
829  *  @param y The first side of the triangle.
830  *  @param x The second side of the triangle.
831  *  @return The angle between the first and the second side.
832  *  @see atan2f()
833  *  @see atan2l()
834  *  @see atanf()
835  *  @see asinf()
836  *  @see acosf()
837  *  @see atanhf()
838  *  @see tanhf()
839  */
840 float       atan2f( float       y, float       x );
841
842 /** These functions compute the hyperbolic arctangent of x / y (measured in radians).
843  *  They return their answer between pi and -pi.
844  *  @param y The first side of the triangle.
845  *  @param x The second side of the triangle.
846  *  @return The angle between the first and the second side.
847  *  @see atan2f()
848  *  @see atan2l()
849  *  @see atanl()
850  *  @see asinl()
851  *  @see acosl()
852  *  @see atanhl()
853  *  @see tanhl()
854  */
855 long double atan2l( long double y, long double x );
856
857 /** These functions compute the hypotenuse of a straight triangle.
858  *  @param x The length of one side of the triangle.
859  *  @param y The length of the other side of the triangle.
860  *  @return The length of the hypotenuse, according to h = sqrt(x*x+y*y).
861  *  @see hypotf()
862  *  @see hypotl()
863  */
864 double      hypot( double       x, double      y );
865
866 /** These functions compute the hypotenuse of a straight triangle.
867  *  @param x The length of one side of the triangle.
868  *  @param y The length of the other side of the triangle.
869  *  @return The length of the hypotenuse, according to h = sqrt(x*x+y*y).
870  *  @see hypot()
871  *  @see hypotl()
872  */
873 float       hypotf( float       x, float       y );
874
875 /** These functions compute the hypotenuse of a straight triangle.
876  *  @param x The length of one side of the triangle.
877  *  @param y The length of the other side of the triangle.
878  *  @return The length of the hypotenuse, according to h = sqrt(x*x+y*y).
879  *  @see hypot()
880  *  @see hypotf()
881  */
882 long double hypotl( long double x, long double y );
883
884 /** These functions compute x raised to the power y.
885  *  @param x The base of the power.
886  *  @param y The exponent of the power.
887  *  @return The base raised to the power of the exponent.
888  *  @see powf()
889  *  @see powl()
890  */
891 double      pow( double       x, double      y );
892
893 /** These functions compute x raised to the power y.
894  *  @param x The base of the power.
895  *  @param y The exponent of the power.
896  *  @return The base raised to the power of the exponent.
897  *  @see pow()
898  *  @see powl()
899  */
900 float       powf( float       x, float       y );
901
902 /** These functions compute x raised to the power y.
903  *  @param x The base of the power.
904  *  @pa am y The exponent of the power.
905  *  @return The base raised to the power of the exponent.
906  *  @see pow()
907  *  @see powf()
908  */
909 long double powl( long double x, long double y );
910
911 /** These functions compute the square root of x.
912  *  @param x The value to take the square root of.
913  *  @return The square root of x.
914  *  @see sqrtf()
915  *  @see sqrtl()
916  */
917 double      sqrt( double       x );
918
919 /** These functions compute the square root of x.
920  *  @param x The value to take the square root of.
921  *  @return The square root of x.
922  *  @see sqrt()
923  *  @see sqrtl()
924  */
925 float       sqrtf( float       x );
926
927 /** These functions compute the square root of x.
928  *  @param x The value to take the square root of.
929  *  @return The square root of x.
930  *  @see sqrt()
931  *  @see sqrtf()
932  */
933 long double sqrtl( long double x );
934
935 /* TODO */
936 double      cbrt( double       x );
937 float       cbrtf( float       x );
938 long double cbrtl( long double x );
939
940 /* TODO */
941 double      exp( double       x );
942 float       expf( float       x );
943 long double expl( long double x );
944
945 /* TODO */
946 double      exp2( double       x );
947 float       exp2f( float       x );
948 long double exp2l( long double x );
949
950 /* TODO */
951 double      expm1( double       x );
952 float       expm1f( float       x );
953 long double expm1l( long double x );
954
955 /* TODO */
956 double      frexp( double       x, int * exp );
957 float       frexpf( float       x, int * exp );
958 long double frexpl( long double x, int * exp );
959
960 /* TODO */
961 double      ldexp( double       x, int exp );
962 float       ldexpf( float       x, int exp );
963 long double ldexpl( long double x, int exp );
964
965 /** These functions compute the logarithm (base e) of x.
966  *  @param x The value to take the logarithm of.
967  *  @return The logarithm of x.
968  *  @see logf()
969  *  @see logl()
970  *  @todo is this really the natural logarithm? wouldn't it be ln()?
971  */
972 double      log( double       x );
973
974 /** These functions compute the logarithm (base e) of x.
975  *  @param x The value to take the logarithm of.
976  *  @return The logarithm of x.
977  *  @see log()
978  *  @see logl()
979  *  @todo is this really the natural logarithm? wouldn't it be ln()?
980  */
981 float       logf( float       x );
982
983 /** These functions compute the logarithm (base e) of x.
984  *  @param x The value to take the logarithm of.
985  *  @return The logarithm of x.
986  *  @see log()
987  *  @see logf()
988  *  @todo is this really the natural logarithm? wouldn't it be ln()?
989  */
990 long double logl( long double x );
991
992 /** These functions compute the logarithm (base 10) of x.
993  *  @param x The value to take the logarithm of.
994  *  @return The logarithm of x.
995  *  @see log10f()
996  *  @see log10l()
997  */
998 double      log10( double       x );
999
1000 /** These functions compute the logarithm (base 10) of x.
1001  *  @param x The value to take the logarithm of.
1002  *  @return The logarithm of x.
1003  *  @see log10()
1004  *  @see log10l()
1005  */
1006 float       log10f( float       x );
1007
1008 /** These functions compute the logarithm (base 10) of x.
1009  *  @param x The value to take the logarithm of.
1010  *  @return The logarithm of x.
1011  *  @see log10()
1012  *  @see log10f()
1013  */
1014 long double log10l( long double x );
1015
1016 /** These functions compute the logarithm (base 2) of x.
1017  *  @param x The value to take the logarithm of.
1018  *  @return The logarithm of x.
1019  *  @see log2f()
1020  *  @see log2l()
1021  */
1022 double      log2( double       x );
1023
1024 /** These functions compute the logarithm (base 2) of x.
1025  *  @param x The value to take the logarithm of.
1026  *  @return The logarithm of x.
1027  *  @see log2()
1028  *  @see log2l()
1029  */
1030 float       log2f( float       x );
1031
1032 /** These functions compute the logarithm (base 2) of x.
1033  *  @param x The value to take the logarithm of.
1034  *  @return The logarithm of x.
1035  *  @see log2()
1036  *  @see log2f()
1037  */
1038 long double log2l( long double x );
1039
1040 /* TODO */
1041 double      logb( double       x );
1042 float       logbf( float       x );
1043 long double logbl( long double x );
1044
1045 /* TODO */
1046 int ilogb( double       x );
1047 int ilogbf( float       x );
1048 int ilogbl( long double x );
1049
1050 /* TODO */
1051 double      log1p( double       x );
1052 float       log1pf( float       x );
1053 long double log1pl( long double x );
1054
1055 /** These functions increase x to the next whole number.
1056  *  @param x The value to increase.
1057  *  @return The next whole number after x.
1058  *  @see ceilf()
1059  *  @see ceill()
1060  */
1061 double      ceil( double       x );
1062
1063 /** These functions increase x to the next whole number.
1064  *  @param x The value to increase.
1065  *  @return The next whole number after x.
1066  *  @see ceil()
1067  *  @see ceill()
1068  */
1069 float       ceilf( float       x );
1070
1071 /** These functions increase x to the next whole number.
1072  *  @param x The value to increase.
1073  *  @return The next whole number after x.
1074  *  @see ceil()
1075  *  @see ceilf()
1076  */
1077 long double ceill( long double x );
1078
1079 /** These functions decrease x to the previous whole number.
1080  *  @param x The value to decrease.
1081  *  @return The previous whole number before x.
1082  *  @see floorf()
1083  *  @see floorl()
1084  */
1085 double      floor( double       x );
1086
1087 /** These functions decrease x to the previous whole number.
1088  *  @param x The value to decrease.
1089  *  @return The previous whole number before x.
1090  *  @see floor()
1091  *  @see floorl()
1092  */
1093 float       floorf( float       x );
1094
1095 /** These functions decrease x to the previous whole number.
1096  *  @param x The value to decrease.
1097  *  @return The previous whole number before x.
1098  *  @see floor()
1099  *  @see floorf()
1100  */
1101 long double floorl( long double x );
1102
1103 /** These functions compute the modulus of x and y.
1104  *  @param x The value to take the modulus of.
1105  *  @param y The modulus.
1106  *  @return The value of x modulus y.
1107  *  @see fmodf()
1108  *  @see fmodl()
1109  */
1110 double      fmod( double       x, double      y );
1111
1112 /** These functions compute the modulus of x and y.
1113  *  @param x The value to take the modulus of.
1114  *  @param y The modulus.
1115  *  @return The value of x modulus y.
1116  *  @see fmod()
1117  *  @see fmodl()
1118  */
1119 float       fmodf( float       x, float       y );
1120
1121 /** These functions compute the modulus of x and y.
1122  *  @param x The value to take the modulus of.
1123  *  @param y The modulus.
1124  *  @return The value of x modulus y.
1125  *  @see fmod()
1126  *  @see fmodf()
1127  */
1128 long double fmodl( long double x, long double y );
1129
1130 /* TODO */
1131 double      modf( double       x, double *      integer );
1132 float       modff( float       x, float *       integer );
1133 long double modfl( long double x, long double * integer );
1134
1135 /** These functions return x with the sign of y.
1136  *  @param x The value to set the sign of.
1137  *  @param y The value from which to read the sign.
1138  *  @return The magnitude of x with the sign of y.
1139  *  @see copysignf()
1140  *  @see copysignl()
1141  */
1142 double      copysign( double       x, double      y );
1143
1144 /** These functions return x with the sign of y.
1145  *  @param x The value to set the sign of.
1146  *  @param y The value from which to read the sign.
1147  *  @return The magnitude of x with the sign of y.
1148  *  @see copysign()
1149  *  @see copysignl()
1150  */
1151 float       copysignf( float       x, float       y );
1152
1153 /** These functions return x with the sign of y.
1154  *  @param x The value to set the sign of.
1155  *  @param y The value from which to read the sign.
1156  *  @return The magnitude of x with the sign of y.
1157  *  @see copysign()
1158  *  @see copysignf()
1159  */
1160 long double copysignl( long double x, long double y );
1161
1162 /* TODO */
1163 double      erf( double       x );
1164 float       erff( float       x );
1165 long double erfl( long double x );
1166
1167 /* TODO */
1168 double      erfc( double       x );
1169 float       erfcf( float       x );
1170 long double erfcl( long double x );
1171
1172 /* TODO */
1173 double      fdim( double       x, double      y );
1174 float       fdimf( float       x, float       y );
1175 long double fdiml( long double x, long double y );
1176
1177 /* TODO */
1178 double      fma( double       x, double      y, double      z );
1179 float       fmaf( float       x, float       y, float       z );
1180 long double fmal( long double x, long double y, long double z );
1181
1182 /** These functions return the largest of the parameters.
1183  *  @param x The first candidate.
1184  *  @param y The second candidate.
1185  *  @return The largest of x and y.
1186  *  @see fmaxf()
1187  *  @see fmaxl()
1188  */
1189 double      fmax( double       x, double      y );
1190
1191 /** These functions return the largest of the parameters.
1192  *  @param x The first candidate.
1193  *  @param y The second candidate.
1194  *  @return The largest of x and y.
1195  *  @see fmax()
1196  *  @see fmaxl()
1197  */
1198 float       fmaxf( float       x, float       y );
1199
1200 /** These functions return the largest of the parameters.
1201  *  @param x The first candidate.
1202  *  @param y The second candidate.
1203  *  @return The largest of x and y.
1204  *  @see fmax()
1205  *  @see fmaxf()
1206  */
1207 long double fmaxl( long double x, long double y );
1208
1209 /** These functions return the smallest of the parameters.
1210  *  @param x The first candidate.
1211  *  @param y The second candidate.
1212  *  @return The smallest of x and y.
1213  *  @see fminf()
1214  *  @see fminl()
1215  */
1216 double      fmin( double       x, double      y );
1217
1218 /** These functions return the smallest of the parameters.
1219  *  @param x The first candidate.
1220  *  @param y The second candidate.
1221  *  @return The smallest of x and y.
1222  *  @see fmin()
1223  *  @see fminl()
1224  */
1225 float       fminf( float       x, float       y );
1226
1227 /** These functions return the smallest of the parameters.
1228  *  @param x The first candidate.
1229  *  @param y The second candidate.
1230  *  @return The smallest of x and y.
1231  *  @see fmin()
1232  *  @see fminf()
1233  */
1234 long double fminl( long double x, long double y );
1235
1236 /* TODO */
1237 long long llrint( double       x );
1238 long long llrintf( float       x );
1239 long long llrintl( long double x );
1240 long lrint( double       x );
1241 long lrintf( float       x );
1242 long lrintl( long double x );
1243 double      rint( double       x );
1244 float       rintf( float       x );
1245 long double rintl( long double x );
1246
1247 /* TODO - These functions return their parameter correctly rounded according
1248  * to the current rounding settings.
1249  */
1250 long long llround( double       x );
1251 long long llroundf( float       x );
1252 long long llroundl( long double x );
1253 long lround( double       x );
1254 long lroundf( float       x );
1255 long lroundl( long double x );
1256 double      round( double       x );
1257 float       roundf( float       x );
1258 long double roundl( long double x );
1259
1260 /* TODO - These functions return their parameter with its decimal part
1261  * truncated.
1262  */
1263 double      trunc( double       x );
1264 float       truncf( float       x );
1265 long double truncl( long double x );
1266
1267 double      nearbyint( double       x );
1268 float       nearbyintf( float       x );
1269 long double nearbyintl( long double x );
1270
1271 double      nextafter( double       x, double      y );
1272 float       nextafterf( float       x, float       y );
1273 long double nextafterl( long double x, long double y );
1274
1275 /* TODO */
1276 double      nexttoward( double       x, long double y );
1277 float       nexttowardf( float       x, long double y );
1278 long double nexttowardl( long double x, long double y );
1279
1280 /* TODO - These functions divide parameter x by parameter y and return the
1281  * remainder.
1282  */
1283 double      remainder( double       x, double      y );
1284 float       remainderf( float       x, float       y );
1285 long double remainderl( long double x, long double y );
1286
1287 /* TODO */
1288 double      remquo( double       x, double      y, int * pquo );
1289 float       remquof( float       x, float       y, int * pquo );
1290 long double remquol( long double x, long double y, int * pquo );
1291
1292 /* TODO */
1293 double      scalbn( double       x, int ex );
1294 float       scalbnf( float       x, int ex );
1295 long double scalbnl( long double x, int ex );
1296
1297 /* TODO */
1298 double      scalbln( double       x, long ex );
1299 float       scalblnf( float       x, long ex );
1300 long double scalblnl( long double x, long ex );
1301
1302 /* TODO */
1303 double      lgamma( double       x );
1304 float       lgammaf( float       x );
1305 long double lgammal( long double x );
1306
1307 /* TODO */
1308 double      tgamma( double       x );
1309 float       tgammaf( float       x );
1310 long double tgammal( long double x );
1311
1312 /* TODO */
1313 double      nan( const char  *str );
1314 float       nanf( const char *str );
1315 long double nanl( const char *str );
1316
1317 #endif /* _MATH_H */