math.h
001: 
002: 
003: 
004: 
005: 
006: 
007: 
008: 
009: 
010: 
011: 
012: 
013: 
014: 
015: 
016: 
017: 
018: 
019: 
020: 
021: 
022: 
023: 
024: 
025: #ifndef _MATH_H
026: #define _MATH_H 1
027: 
028: #include <features.h>
029: 
030: __BEGIN_DECLS
031: 
032: 
033: 
034: #include <bits/huge_val.h>
035: #ifdef __USE_ISOC99
036: # include <bits/huge_valf.h>
037: # include <bits/huge_vall.h>
038: 
039: 
040: # include <bits/inf.h>
041: 
042: 
043: # include <bits/nan.h>
044: #endif 
045: 
046: 
047: #include <bits/mathdef.h>
048: 
049: 
050: 
051: 
052: 
053: 
054: #define __MATHCALL(function,suffix, args)       \
055:   __MATHDECL (_Mdouble_,function,suffix, args)
056: #define __MATHDECL(type, function,suffix, args) \
057:   __MATHDECL_1(type, function,suffix, args); \
058:   __MATHDECL_1(type, __CONCAT(__,function),suffix, args)
059: #define __MATHCALLX(function,suffix, args, attrib)      \
060:   __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
061: #define __MATHDECLX(type, function,suffix, args, attrib) \
062:   __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
063:   __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)
064: #define __MATHDECL_1(type, function,suffix, args) \
065:   extern type __MATH_PRECNAME(function,suffix) args __THROW
066: 
067: #define _Mdouble_               double
068: #define __MATH_PRECNAME(name,r) __CONCAT(name,r)
069: #define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
070: #define _Mdouble_END_NAMESPACE   __END_NAMESPACE_STD
071: #include <bits/mathcalls.h>
072: #undef  _Mdouble_
073: #undef _Mdouble_BEGIN_NAMESPACE
074: #undef _Mdouble_END_NAMESPACE
075: #undef  __MATH_PRECNAME
076: 
077: #if defined __USE_MISC || defined __USE_ISOC99
078: 
079: 
080: 
081: 
082: 
083: # ifndef _Mfloat_
084: #  define _Mfloat_              float
085: # endif
086: # define _Mdouble_              _Mfloat_
087: # ifdef __STDC__
088: #  define __MATH_PRECNAME(name,r) name##f##r
089: # else
090: #  define __MATH_PRECNAME(name,r) namer
091: # endif
092: # define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
093: # define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99
094: # include <bits/mathcalls.h>
095: # undef _Mdouble_
096: # undef _Mdouble_BEGIN_NAMESPACE
097: # undef _Mdouble_END_NAMESPACE
098: # undef __MATH_PRECNAME
099: 
100: # if (__STDC__ - 0 || __GNUC__ - 0) \
101:      && (!(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
102:          || defined __LDBL_COMPAT)
103: #  ifdef __LDBL_COMPAT
104: 
105: #   ifdef __USE_ISOC99
106: extern float __nldbl_nexttowardf (float __x, long double __y)
107:                                   __THROW __attribute__ ((__const__));
108: #    ifdef __REDIRECT_NTH
109: extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y),
110:                              __nldbl_nexttowardf)
111:      __attribute__ ((__const__));
112: extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
113:                               nextafter) __attribute__ ((__const__));
114: extern long double __REDIRECT_NTH (nexttowardl,
115:                                    (long double __x, long double __y),
116:                                    nextafter) __attribute__ ((__const__));
117: #    endif
118: #   endif
119: #  endif
120: 
121: #  if defined __LDBL_COMPAT || defined __NO_LONG_DOUBLE_MATH
122: 
123: #   undef __MATHDECL_1
124: #   define __MATHDECL_2(type, function,suffix, args, alias) \
125:   extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \
126:                              args, alias)
127: #   define __MATHDECL_1(type, function,suffix, args) \
128:   __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))
129: #  endif
130: 
131: 
132: 
133: 
134: #  ifndef _Mlong_double_
135: #   define _Mlong_double_       long double
136: #  endif
137: #  define _Mdouble_             _Mlong_double_
138: #  ifdef __STDC__
139: #   define __MATH_PRECNAME(name,r) name##l##r
140: #  else
141: #   define __MATH_PRECNAME(name,r) namer
142: #  endif
143: #  define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
144: #  define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99
145: #  define __MATH_DECLARE_LDOUBLE   1
146: #  include <bits/mathcalls.h>
147: #  undef _Mdouble_
148: #  undef _Mdouble_BEGIN_NAMESPACE
149: #  undef _Mdouble_END_NAMESPACE
150: #  undef __MATH_PRECNAME
151: 
152: # endif 
153: 
154: #endif  
155: #undef  __MATHDECL_1
156: #undef  __MATHDECL
157: #undef  __MATHCALL
158: 
159: 
160: #if defined __USE_MISC || defined __USE_XOPEN
161: 
162: extern int signgam;
163: #endif
164: 
165: 
166: 
167: #ifdef __USE_ISOC99
168: 
169: 
170: 
171: 
172: 
173: 
174: 
175: 
176: 
177: 
178: 
179: 
180: 
181: 
182: 
183: 
184: 
185: 
186: 
187: 
188: 
189: 
190: 
191: 
192: 
193: 
194: 
195: 
196: 
197: 
198: 
199: 
200: 
201: 
202: 
203: enum
204:   {
205:     FP_NAN,
206: # define FP_NAN FP_NAN
207:     FP_INFINITE,
208: # define FP_INFINITE FP_INFINITE
209:     FP_ZERO,
210: # define FP_ZERO FP_ZERO
211:     FP_SUBNORMAL,
212: # define FP_SUBNORMAL FP_SUBNORMAL
213:     FP_NORMAL
214: # define FP_NORMAL FP_NORMAL
215:   };
216: 
217: 
218: # ifdef __NO_LONG_DOUBLE_MATH
219: #  define fpclassify(x) \
220:      (sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x))
221: # else
222: #  define fpclassify(x) \
223:      (sizeof (x) == sizeof (float)                                            \
224:       ? __fpclassifyf (x)                                                     \
225:       : sizeof (x) == sizeof (double)                                         \
226:       ? __fpclassify (x) : __fpclassifyl (x))
227: # endif
228: 
229: 
230: # ifdef __NO_LONG_DOUBLE_MATH
231: #  define signbit(x) \
232:      (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))
233: # else
234: #  define signbit(x) \
235:      (sizeof (x) == sizeof (float)                                            \
236:       ? __signbitf (x)                                                        \
237:       : sizeof (x) == sizeof (double)                                         \
238:       ? __signbit (x) : __signbitl (x))
239: # endif
240: 
241: 
242: # ifdef __NO_LONG_DOUBLE_MATH
243: #  define isfinite(x) \
244:      (sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x))
245: # else
246: #  define isfinite(x) \
247:      (sizeof (x) == sizeof (float)                                            \
248:       ? __finitef (x)                                                         \
249:       : sizeof (x) == sizeof (double)                                         \
250:       ? __finite (x) : __finitel (x))
251: # endif
252: 
253: 
254: # define isnormal(x) (fpclassify (x) == FP_NORMAL)
255: 
256: 
257: 
258: # ifdef __NO_LONG_DOUBLE_MATH
259: #  define isnan(x) \
260:      (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
261: # else
262: #  define isnan(x) \
263:      (sizeof (x) == sizeof (float)                                            \
264:       ? __isnanf (x)                                                          \
265:       : sizeof (x) == sizeof (double)                                         \
266:       ? __isnan (x) : __isnanl (x))
267: # endif
268: 
269: 
270: # ifdef __NO_LONG_DOUBLE_MATH
271: #  define isinf(x) \
272:      (sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))
273: # else
274: #  define isinf(x) \
275:      (sizeof (x) == sizeof (float)                                            \
276:       ? __isinff (x)                                                          \
277:       : sizeof (x) == sizeof (double)                                         \
278:       ? __isinf (x) : __isinfl (x))
279: # endif
280: 
281: 
282: # define MATH_ERRNO     1       
283: # define MATH_ERREXCEPT 2       
284: 
285: 
286: 
287: 
288: # ifndef __FAST_MATH__
289: #  define math_errhandling      (MATH_ERRNO | MATH_ERREXCEPT)
290: # endif
291: 
292: #endif 
293: 
294: #ifdef  __USE_MISC
295: 
296: typedef enum
297: {
298:   _IEEE_ = -1,  
299:   _SVID_,       
300:   _XOPEN_,      
301:   _POSIX_,
302:   _ISOC_        
303: } _LIB_VERSION_TYPE;
304: 
305: 
306: 
307: 
308: extern _LIB_VERSION_TYPE _LIB_VERSION;
309: #endif
310: 
311: 
312: #ifdef __USE_SVID
313: 
314: 
315: 
316: 
317: 
318: # ifdef __cplusplus
319: struct __exception
320: # else
321: struct exception
322: # endif
323:   {
324:     int type;
325:     char *name;
326:     double arg1;
327:     double arg2;
328:     double retval;
329:   };
330: 
331: # ifdef __cplusplus
332: extern int matherr (struct __exception *__exc) throw ();
333: # else
334: extern int matherr (struct exception *__exc);
335: # endif
336: 
337: # define X_TLOSS        1.41484755040568800000e+16
338: 
339: 
340: # define DOMAIN         1
341: # define SING           2
342: # define OVERFLOW       3
343: # define UNDERFLOW      4
344: # define TLOSS          5
345: # define PLOSS          6
346: 
347: 
348: # define HUGE           3.40282347e+38F
349: 
350: #else   
351: 
352: # ifdef __USE_XOPEN
353: 
354: #  define MAXFLOAT      3.40282347e+38F
355: # endif
356: 
357: #endif  
358: 
359: 
360: 
361: #if defined __USE_BSD || defined __USE_XOPEN
362: # define M_E            2.7182818284590452354   
363: # define M_LOG2E        1.4426950408889634074   
364: # define M_LOG10E       0.43429448190325182765  
365: # define M_LN2          0.69314718055994530942  
366: # define M_LN10         2.30258509299404568402  
367: # define M_PI           3.14159265358979323846  
368: # define M_PI_2         1.57079632679489661923  
369: # define M_PI_4         0.78539816339744830962  
370: # define M_1_PI         0.31830988618379067154  
371: # define M_2_PI         0.63661977236758134308  
372: # define M_2_SQRTPI     1.12837916709551257390  
373: # define M_SQRT2        1.41421356237309504880  
374: # define M_SQRT1_2      0.70710678118654752440  
375: #endif
376: 
377: 
378: 
379: 
380: #ifdef __USE_GNU
381: # define M_El           2.7182818284590452353602874713526625L  
382: # define M_LOG2El       1.4426950408889634073599246810018921L  
383: # define M_LOG10El      0.4342944819032518276511289189166051L  
384: # define M_LN2l         0.6931471805599453094172321214581766L  
385: # define M_LN10l        2.3025850929940456840179914546843642L  
386: # define M_PIl          3.1415926535897932384626433832795029L  
387: # define M_PI_2l        1.5707963267948966192313216916397514L  
388: # define M_PI_4l        0.7853981633974483096156608458198757L  
389: # define M_1_PIl        0.3183098861837906715377675267450287L  
390: # define M_2_PIl        0.6366197723675813430755350534900574L  
391: # define M_2_SQRTPIl    1.1283791670955125738961589031215452L  
392: # define M_SQRT2l       1.4142135623730950488016887242096981L  
393: # define M_SQRT1_2l     0.7071067811865475244008443621048490L  
394: #endif
395: 
396: 
397: 
398: 
399: 
400: #if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES
401: # define __NO_MATH_INLINES      1
402: #endif
403: 
404: #if defined __USE_ISOC99 && __GNUC_PREREQ(2,97)
405: 
406: 
407: 
408: 
409: 
410: 
411: # define isgreater(x, y)        __builtin_isgreater(x, y)
412: # define isgreaterequal(x, y)   __builtin_isgreaterequal(x, y)
413: # define isless(x, y)           __builtin_isless(x, y)
414: # define islessequal(x, y)      __builtin_islessequal(x, y)
415: # define islessgreater(x, y)    __builtin_islessgreater(x, y)
416: # define isunordered(u, v)      __builtin_isunordered(u, v)
417: #endif
418: 
419: 
420: #ifdef __USE_EXTERN_INLINES
421: # include <bits/mathinline.h>
422: #endif
423: 
424: 
425: 
426: #if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
427: # include <bits/math-finite.h>
428: #endif
429: 
430: #ifdef __USE_ISOC99
431: 
432: 
433: 
434: # ifndef isgreater
435: #  define isgreater(x, y) \
436:   (__extension__                                                              \
437:    ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);                       \
438:       !isunordered (__x, __y) && __x > __y; }))
439: # endif
440: 
441: 
442: # ifndef isgreaterequal
443: #  define isgreaterequal(x, y) \
444:   (__extension__                                                              \
445:    ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);                       \
446:       !isunordered (__x, __y) && __x >= __y; }))
447: # endif
448: 
449: 
450: # ifndef isless
451: #  define isless(x, y) \
452:   (__extension__                                                              \
453:    ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);                       \
454:       !isunordered (__x, __y) && __x < __y; }))
455: # endif
456: 
457: 
458: # ifndef islessequal
459: #  define islessequal(x, y) \
460:   (__extension__                                                              \
461:    ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);                       \
462:       !isunordered (__x, __y) && __x <= __y; }))
463: # endif
464: 
465: 
466: # ifndef islessgreater
467: #  define islessgreater(x, y) \
468:   (__extension__                                                              \
469:    ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);                       \
470:       !isunordered (__x, __y) && (__x < __y || __y < __x); }))
471: # endif
472: 
473: 
474: # ifndef isunordered
475: #  define isunordered(u, v) \
476:   (__extension__                                                              \
477:    ({ __typeof__(u) __u = (u); __typeof__(v) __v = (v);                       \
478:       fpclassify (__u) == FP_NAN || fpclassify (__v) == FP_NAN; }))
479: # endif
480: 
481: #endif
482: 
483: __END_DECLS
484: 
485: 
486: #endif 
487: 
      
      
      
      
   
      
      
         
            
            © Andrew Scott 2006 -
            2025, 
            All Rights Reserved