Dr Andrew Scott G7VAV

My photo
 
March 2024
Mo Tu We Th Fr Sa Su
26 27 28 29 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
1 2 3 4 5 6 7


math.h
001: /* Declarations for math functions.
002:    Copyright (C) 1991-1993, 1995-1999, 2001, 2002, 2004, 2006, 2009, 2011
003:    Free Software Foundation, Inc.
004:    This file is part of the GNU C Library.
005: 
006:    The GNU C Library is free software; you can redistribute it and/or
007:    modify it under the terms of the GNU Lesser General Public
008:    License as published by the Free Software Foundation; either
009:    version 2.1 of the License, or (at your option) any later version.
010: 
011:    The GNU C Library is distributed in the hope that it will be useful,
012:    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:    Lesser General Public License for more details.
015: 
016:    You should have received a copy of the GNU Lesser General Public
017:    License along with the GNU C Library; if not, write to the Free
018:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
019:    02111-1307 USA.  */
020: 
021: /*
022:  *      ISO C99 Standard: 7.12 Mathematics      <math.h>
023:  */
024: 
025: #ifndef _MATH_H
026: #define _MATH_H 1
027: 
028: #include <features.h>
029: 
030: __BEGIN_DECLS
031: 
032: /* Get machine-dependent HUGE_VAL value (returned on overflow).
033:    On all IEEE754 machines, this is +Infinity.  */
034: #include <bits/huge_val.h>
035: #ifdef __USE_ISOC99
036: # include <bits/huge_valf.h>
037: # include <bits/huge_vall.h>
038: 
039: /* Get machine-dependent INFINITY value.  */
040: # include <bits/inf.h>
041: 
042: /* Get machine-dependent NAN value (returned for some domain errors).  */
043: # include <bits/nan.h>
044: #endif /* __USE_ISOC99 */
045: 
046: /* Get general and ISO C99 specific information.  */
047: #include <bits/mathdef.h>
048: 
049: /* The file <bits/mathcalls.h> contains the prototypes for all the
050:    actual math functions.  These macros are used for those prototypes,
051:    so we can easily declare each function as both `name' and `__name',
052:    and can declare the float versions `namef' and `__namef'.  */
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: /* Include the file of declarations again, this time using `float'
081:    instead of `double' and appending f to each function name.  */
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) name/**/f/**/r
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: /* Include the file of declarations again, this time using `long double'
132:    instead of `double' and appending l to each function name.  */
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) name/**/l/**/r
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 /* __STDC__ || __GNUC__ */
153: 
154: #endif  /* Use misc or ISO C99.  */
155: #undef  __MATHDECL_1
156: #undef  __MATHDECL
157: #undef  __MATHCALL
158: 
159: 
160: #if defined __USE_MISC || defined __USE_XOPEN
161: /* This variable is used by `gamma' and `lgamma'.  */
162: extern int signgam;
163: #endif
164: 
165: 
166: /* ISO C99 defines some generic macros which work on any data type.  */
167: #ifdef __USE_ISOC99
168: 
169: /* Get the architecture specific values describing the floating-point
170:    evaluation.  The following symbols will get defined:
171: 
172:     float_t     floating-point type at least as wide as `float' used
173:                 to evaluate `float' expressions
174:     double_t    floating-point type at least as wide as `double' used
175:                 to evaluate `double' expressions
176: 
177:     FLT_EVAL_METHOD
178:                 Defined to
179:                   0     if `float_t' is `float' and `double_t' is `double'
180:                   1     if `float_t' and `double_t' are `double'
181:                   2     if `float_t' and `double_t' are `long double'
182:                   else  `float_t' and `double_t' are unspecified
183: 
184:     INFINITY    representation of the infinity value of type `float'
185: 
186:     FP_FAST_FMA
187:     FP_FAST_FMAF
188:     FP_FAST_FMAL
189:                 If defined it indicates that the `fma' function
190:                 generally executes about as fast as a multiply and an add.
191:                 This macro is defined only iff the `fma' function is
192:                 implemented directly with a hardware multiply-add instructions.
193: 
194:     FP_ILOGB0   Expands to a value returned by `ilogb (0.0)'.
195:     FP_ILOGBNAN Expands to a value returned by `ilogb (NAN)'.
196: 
197:     DECIMAL_DIG Number of decimal digits supported by conversion between
198:                 decimal and all internal floating-point formats.
199: 
200: */
201: 
202: /* All floating-point numbers can be put in one of these categories.  */
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: /* Return number of classification appropriate for X.  */
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: /* Return nonzero value if sign of X is negative.  */
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: /* Return nonzero value if X is not +-Inf or NaN.  */
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: /* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN.  */
254: # define isnormal(x) (fpclassify (x) == FP_NORMAL)
255: 
256: /* Return nonzero value if X is a NaN.  We could use `fpclassify' but
257:    we already have this functions `__isnan' and it is faster.  */
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: /* Return nonzero value if X is positive or negative infinity.  */
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: /* Bitmasks for the math_errhandling macro.  */
282: # define MATH_ERRNO     1       /* errno set by math functions.  */
283: # define MATH_ERREXCEPT 2       /* Exceptions raised by math functions.  */
284: 
285: /* By default all functions support both errno and exception handling.
286:    In gcc's fast math mode and if inline functions are defined this
287:    might not be true.  */
288: # ifndef __FAST_MATH__
289: #  define math_errhandling      (MATH_ERRNO | MATH_ERREXCEPT)
290: # endif
291: 
292: #endif /* Use ISO C99.  */
293: 
294: #ifdef  __USE_MISC
295: /* Support for various different standard error handling behaviors.  */
296: typedef enum
297: {
298:   _IEEE_ = -1,  /* According to IEEE 754/IEEE 854.  */
299:   _SVID_,       /* According to System V, release 4.  */
300:   _XOPEN_,      /* Nowadays also Unix98.  */
301:   _POSIX_,
302:   _ISOC_        /* Actually this is ISO C99.  */
303: } _LIB_VERSION_TYPE;
304: 
305: /* This variable can be changed at run-time to any of the values above to
306:    affect floating point error handling behavior (it may also be necessary
307:    to change the hardware FPU exception settings).  */
308: extern _LIB_VERSION_TYPE _LIB_VERSION;
309: #endif
310: 
311: 
312: #ifdef __USE_SVID
313: /* In SVID error handling, `matherr' is called with this description
314:    of the exceptional condition.
315: 
316:    We have a problem when using C++ since `exception' is a reserved
317:    name in C++.  */
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: /* Types of exceptions in the `type' field.  */
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: /* SVID mode specifies returning this large value instead of infinity.  */
348: # define HUGE           3.40282347e+38F
349: 
350: #else   /* !SVID */
351: 
352: # ifdef __USE_XOPEN
353: /* X/Open wants another strange constant.  */
354: #  define MAXFLOAT      3.40282347e+38F
355: # endif
356: 
357: #endif  /* SVID */
358: 
359: 
360: /* Some useful constants.  */
361: #if defined __USE_BSD || defined __USE_XOPEN
362: # define M_E            2.7182818284590452354   /* e */
363: # define M_LOG2E        1.4426950408889634074   /* log_2 e */
364: # define M_LOG10E       0.43429448190325182765  /* log_10 e */
365: # define M_LN2          0.69314718055994530942  /* log_e 2 */
366: # define M_LN10         2.30258509299404568402  /* log_e 10 */
367: # define M_PI           3.14159265358979323846  /* pi */
368: # define M_PI_2         1.57079632679489661923  /* pi/2 */
369: # define M_PI_4         0.78539816339744830962  /* pi/4 */
370: # define M_1_PI         0.31830988618379067154  /* 1/pi */
371: # define M_2_PI         0.63661977236758134308  /* 2/pi */
372: # define M_2_SQRTPI     1.12837916709551257390  /* 2/sqrt(pi) */
373: # define M_SQRT2        1.41421356237309504880  /* sqrt(2) */
374: # define M_SQRT1_2      0.70710678118654752440  /* 1/sqrt(2) */
375: #endif
376: 
377: /* The above constants are not adequate for computation using `long double's.
378:    Therefore we provide as an extension constants with similar names as a
379:    GNU extension.  Provide enough digits for the 128-bit IEEE quad.  */
380: #ifdef __USE_GNU
381: # define M_El           2.7182818284590452353602874713526625L  /* e */
382: # define M_LOG2El       1.4426950408889634073599246810018921L  /* log_2 e */
383: # define M_LOG10El      0.4342944819032518276511289189166051L  /* log_10 e */
384: # define M_LN2l         0.6931471805599453094172321214581766L  /* log_e 2 */
385: # define M_LN10l        2.3025850929940456840179914546843642L  /* log_e 10 */
386: # define M_PIl          3.1415926535897932384626433832795029L  /* pi */
387: # define M_PI_2l        1.5707963267948966192313216916397514L  /* pi/2 */
388: # define M_PI_4l        0.7853981633974483096156608458198757L  /* pi/4 */
389: # define M_1_PIl        0.3183098861837906715377675267450287L  /* 1/pi */
390: # define M_2_PIl        0.6366197723675813430755350534900574L  /* 2/pi */
391: # define M_2_SQRTPIl    1.1283791670955125738961589031215452L  /* 2/sqrt(pi) */
392: # define M_SQRT2l       1.4142135623730950488016887242096981L  /* sqrt(2) */
393: # define M_SQRT1_2l     0.7071067811865475244008443621048490L  /* 1/sqrt(2) */
394: #endif
395: 
396: 
397: /* When compiling in strict ISO C compatible mode we must not use the
398:    inline functions since they, among other things, do not set the
399:    `errno' variable correctly.  */
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: /* ISO C99 defines some macros to compare number while taking care for
406:    unordered numbers.  Many FPUs provide special instructions to support
407:    these operations.  Generic support in GCC for these as builtins went
408:    in before 3.0.0, but not all cpus added their patterns.  We define
409:    versions that use the builtins here, and <bits/mathinline.h> will
410:    undef/redefine as appropriate for the specific GCC version in use.  */
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: /* Get machine-dependent inline versions (if there are any).  */
420: #ifdef __USE_EXTERN_INLINES
421: # include <bits/mathinline.h>
422: #endif
423: 
424: /* Define special entry points to use when the compiler got told to
425:    only expect finite results.  */
426: #if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
427: # include <bits/math-finite.h>
428: #endif
429: 
430: #ifdef __USE_ISOC99
431: /* If we've still got undefined comparison macros, provide defaults.  */
432: 
433: /* Return nonzero value if X is greater than Y.  */
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: /* Return nonzero value if X is greater than or equal to Y.  */
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: /* Return nonzero value if X is less than Y.  */
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: /* Return nonzero value if X is less than or equal to Y.  */
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: /* Return nonzero value if either X is less than Y or Y is less than X.  */
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: /* Return nonzero value if arguments are unordered.  */
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 /* math.h  */
487: 


for client 44.223.94.103
© Andrew Scott 2006 - 2024,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/