00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _MATH_H_
00023 #define _MATH_H_
00024
00025 #if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
00026 #define SYMBIAN
00027 #endif
00028
00029 #ifdef __SYMBIAN32__
00030 #ifdef __VC32__
00031
00032
00033
00034
00035 #pragma warning( disable: 4056 )
00036 #endif
00037 #ifdef __ARMCC__
00038
00039
00040
00041
00042 #pragma diag_suppress 222
00043 #pragma diag_suppress 39
00044 #pragma diag_suppress 2874
00045 #endif
00046
00047 #endif
00048
00049 #ifdef __SYMBIAN32__
00050 #include <_ansi.h>
00051
00052 #endif
00053
00054 #include <sys/cdefs.h>
00055 #include <sys/_types.h>
00056 #include <machine/_limits.h>
00057
00058 #ifdef __SYMBIAN32__
00059 #include <libm_aliases.h>
00060
00061 #endif
00062 #ifdef __SYMBIAN32__
00063 #include <signgam.h>
00064
00065
00066 #define __STDC_IEC_559__ 1
00067
00068 #endif
00069
00070
00071
00072
00073 #ifndef __SYMBIAN32__
00074 extern const union __infinity_un {
00075 unsigned char __uc[8];
00076 double __ud;
00077 } __infinity;
00078
00079 extern const union __nan_un {
00080 unsigned char __uc[sizeof(float)];
00081 float __uf;
00082 } __nan;
00083
00084 #endif
00085
00086 #if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
00087 #define __MATH_BUILTIN_CONSTANTS
00088 #endif
00089
00090 #if __GNUC_PREREQ__(3, 0) && !defined(__INTEL_COMPILER)
00091 #define __MATH_BUILTIN_RELOPS
00092 #endif
00093
00094 #ifdef __SYMBIAN32__
00095 #define HUGE_VAL __infinite(1.0)
00096 #else
00097 #ifdef __MATH_BUILTIN_CONSTANTS
00098 #define HUGE_VAL __builtin_huge_val()
00099 #else
00100 #define HUGE_VAL (__infinity.__ud)
00101 #endif
00102
00103 #endif
00104
00105 #if __ISO_C_VISIBLE >= 1999
00106 #define FP_ILOGB0 (-__INT_MAX)
00107 #define FP_ILOGBNAN __INT_MAX
00108
00109 #ifdef __MATH_BUILTIN_CONSTANTS
00110 #define HUGE_VALF __builtin_huge_valf()
00111 #define HUGE_VALL __builtin_huge_vall()
00112 #define INFINITY __builtin_inf()
00113 #define NAN __builtin_nan("")
00114 #else
00115 #define HUGE_VALF (float)HUGE_VAL
00116 #define HUGE_VALL (long double)HUGE_VAL
00117 #define INFINITY HUGE_VALF
00118 #ifdef __SYMBIAN32__
00119 #define NAN nanvalf()
00120 #else
00121 #define NAN (__nan.__uf)
00122
00123 #endif
00124 #endif
00125
00126 #define MATH_ERRNO 1
00127 #define MATH_ERREXCEPT 2
00128 #define math_errhandling MATH_ERREXCEPT
00129
00130
00131 #if defined(__ia64__) || defined(__sparc64__)
00132 #define FP_FAST_FMA
00133 #endif
00134 #ifdef __ia64__
00135 #define FP_FAST_FMAL
00136 #endif
00137 #define FP_FAST_FMAF
00138
00139
00140 #define FP_INFINITE 0x01
00141 #define FP_NAN 0x02
00142 #define FP_NORMAL 0x04
00143 #define FP_SUBNORMAL 0x08
00144 #define FP_ZERO 0x10
00145
00146 #define fpclassify(x) \
00147 ((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \
00148 : (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
00149 : __fpclassifyl(x))
00150
00151 #define isfinite(x) \
00152 ((sizeof (x) == sizeof (float)) ? __isfinitef(x) \
00153 : (sizeof (x) == sizeof (double)) ? __isfinite(x) \
00154 : __isfinitel(x))
00155 #define isinf(x) \
00156 ((sizeof (x) == sizeof (float)) ? __isinff(x) \
00157 : (sizeof (x) == sizeof (double)) ? __isinf(x) \
00158 : __isinfl(x))
00159 #define isnan(x) \
00160 ((sizeof (x) == sizeof (float)) ? __isnanf(x) \
00161 : (sizeof (x) == sizeof (double)) ? __isnan(x) \
00162 : __isnanl(x))
00163 #define isnormal(x) \
00164 ((sizeof (x) == sizeof (float)) ? __isnormalf(x) \
00165 : (sizeof (x) == sizeof (double)) ? __isnormal(x) \
00166 : __isnormall(x))
00167
00168
00169 #ifdef __MATH_BUILTIN_RELOPS
00170 #define isgreater(x, y) __builtin_isgreater((x), (y))
00171 #define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
00172 #define isless(x, y) __builtin_isless((x), (y))
00173 #define islessequal(x, y) __builtin_islessequal((x), (y))
00174 #define islessgreater(x, y) __builtin_islessgreater((x), (y))
00175 #define isunordered(x, y) __builtin_isunordered((x), (y))
00176 #else
00177 #define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
00178 #define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
00179 #define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
00180 #define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
00181 #define islessgreater(x, y) (!isunordered((x), (y)) && \
00182 ((x) > (y) || (y) > (x)))
00183 #define isunordered(x, y) (isnan(x) || isnan(y))
00184 #endif
00185
00186 #define signbit(x) \
00187 ((sizeof (x) == sizeof (float)) ? __signbitf(x) \
00188 : (sizeof (x) == sizeof (double)) ? __signbit(x) \
00189 : __signbitl(x))
00190
00191 typedef __double_t double_t;
00192 typedef __float_t float_t;
00193 #endif
00194
00195
00196
00197
00198 #if __BSD_VISIBLE || __XSI_VISIBLE
00199 #define M_E 2.7182818284590452354
00200 #define M_LOG2E 1.4426950408889634074
00201 #define M_LOG10E 0.43429448190325182765
00202 #define M_LN2 0.69314718055994530942
00203 #define M_LN10 2.30258509299404568402
00204 #define M_PI 3.14159265358979323846
00205 #define M_PI_2 1.57079632679489661923
00206 #define M_PI_4 0.78539816339744830962
00207 #define M_1_PI 0.31830988618379067154
00208 #define M_2_PI 0.63661977236758134308
00209 #define M_2_SQRTPI 1.12837916709551257390
00210 #define M_SQRT2 1.41421356237309504880
00211 #define M_SQRT1_2 0.70710678118654752440
00212
00213 #define MAXFLOAT ((float)3.40282346638528860e+38)
00214 #ifdef __SYMBIAN32__
00215 #ifndef __WINSCW__
00216 extern int _signgam;
00217
00218 #endif
00219 #else
00220 extern int signgam;
00221
00222 #endif
00223 #endif
00224
00225 #if __BSD_VISIBLE
00226 #if 0
00227
00228 #define HUGE HUGE_VAL
00229 #else
00230 #define HUGE MAXFLOAT
00231 #endif
00232 #endif
00233
00234
00235
00236
00237
00238
00239 __BEGIN_DECLS
00240
00241
00242
00243 #ifdef __SYMBIAN32__
00244 IMPORT_C double __infinite(double x);
00245 IMPORT_C float __infinitef(float x);
00246
00247 IMPORT_C double nanval(void );
00248 IMPORT_C float nanvalf(void );
00249
00250 #endif
00251
00252
00253 IMPORT_C int __fpclassifyd(double) __pure2;
00254 IMPORT_C int __fpclassifyf(float) __pure2;
00255 IMPORT_C int __fpclassifyl(long double) __pure2;
00256 IMPORT_C int __isfinitef(float) __pure2;
00257 IMPORT_C int __isfinite(double) __pure2;
00258 IMPORT_C int __isfinitel(long double) __pure2;
00259 IMPORT_C int __isinf(double) __pure2;
00260 IMPORT_C int __isinff(float) __pure2;
00261 IMPORT_C int __isinfl(long double) __pure2;
00262 #ifdef __SYMBIAN32__
00263 IMPORT_C int __isnan(double) __pure2;
00264 IMPORT_C int __isnanf(float) __pure2;
00265
00266 #endif
00267 IMPORT_C int __isnanl(long double) __pure2;
00268 IMPORT_C int __isnormalf(float) __pure2;
00269 IMPORT_C int __isnormal(double) __pure2;
00270 IMPORT_C int __isnormall(long double) __pure2;
00271 IMPORT_C int __signbit(double) __pure2;
00272 IMPORT_C int __signbitf(float) __pure2;
00273 IMPORT_C int __signbitl(long double) __pure2;
00274
00275 IMPORT_C double acos(double);
00276 IMPORT_C double asin(double);
00277 IMPORT_C double atan(double);
00278 IMPORT_C double atan2(double, double);
00279 IMPORT_C double cos(double);
00280 IMPORT_C double sin(double);
00281 IMPORT_C double tan(double);
00282
00283 IMPORT_C double cosh(double);
00284 IMPORT_C double sinh(double);
00285 IMPORT_C double tanh(double);
00286
00287 IMPORT_C double exp(double);
00288 IMPORT_C double frexp(double, int *);
00289 IMPORT_C double ldexp(double, int);
00290 IMPORT_C double log(double);
00291 IMPORT_C double log10(double);
00292 IMPORT_C double modf(double, double *);
00293
00294 IMPORT_C double pow(double, double);
00295 IMPORT_C double sqrt(double);
00296
00297 IMPORT_C double ceil(double);
00298 IMPORT_C double fabs(double) __pure2;
00299 IMPORT_C double floor(double);
00300 IMPORT_C double fmod(double, double);
00301
00302
00303
00304
00305 #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE
00306 IMPORT_C double acosh(double);
00307 IMPORT_C double asinh(double);
00308 IMPORT_C double atanh(double);
00309 IMPORT_C double cbrt(double);
00310 IMPORT_C double erf(double);
00311 IMPORT_C double erfc(double);
00312 IMPORT_C double exp2(double);
00313 IMPORT_C double expm1(double);
00314 IMPORT_C double fma(double, double, double);
00315 IMPORT_C double hypot(double, double);
00316
00317
00318 IMPORT_C int ilogb(double) __pure2;
00319
00320
00321
00322
00323 IMPORT_C double lgamma(double);
00324 IMPORT_C long long llrint(double);
00325 IMPORT_C long long llround(double);
00326 IMPORT_C double log1p(double);
00327 IMPORT_C double logb(double);
00328 IMPORT_C long lrint(double);
00329 IMPORT_C long lround(double);
00330 IMPORT_C double nextafter(double, double);
00331 IMPORT_C double remainder(double, double);
00332 IMPORT_C double remquo(double, double, int *);
00333 IMPORT_C double rint(double);
00334 #endif
00335
00336 #if __BSD_VISIBLE || __XSI_VISIBLE
00337 IMPORT_C double j0(double);
00338 IMPORT_C double j1(double);
00339 IMPORT_C double jn(int, double);
00340 IMPORT_C double scalb(double, double);
00341 IMPORT_C double y0(double);
00342 IMPORT_C double y1(double);
00343 IMPORT_C double yn(int, double);
00344
00345 #if __XSI_VISIBLE <= 500 || __BSD_VISIBLE
00346 IMPORT_C double gamma(double);
00347 #endif
00348 #endif
00349
00350 #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999
00351 IMPORT_C double copysign(double, double) __pure2;
00352 IMPORT_C double fdim(double, double);
00353 IMPORT_C double fmax(double, double) __pure2;
00354 IMPORT_C double fmin(double, double) __pure2;
00355 IMPORT_C double nearbyint(double);
00356 IMPORT_C double round(double);
00357 IMPORT_C double scalbln(double, long);
00358 IMPORT_C double scalbn(double, int);
00359 IMPORT_C double trunc(double);
00360 #endif
00361
00362
00363
00364
00365 #if __BSD_VISIBLE
00366 IMPORT_C double drem(double, double);
00367 IMPORT_C int finite(double) __pure2;
00368
00369
00370
00371
00372
00373 IMPORT_C double lgamma_r(double, int *);
00374
00375
00376
00377
00378 IMPORT_C double significand(double);
00379 #endif
00380
00381
00382 #if __ISO_C_VISIBLE >= 1999
00383 IMPORT_C float acosf(float);
00384
00385 IMPORT_C float acosf(float);
00386 IMPORT_C float asinf(float);
00387 IMPORT_C float atanf(float);
00388 IMPORT_C float atan2f(float, float);
00389 IMPORT_C float cosf(float);
00390 IMPORT_C float sinf(float);
00391 IMPORT_C float tanf(float);
00392
00393 IMPORT_C float coshf(float);
00394 IMPORT_C float sinhf(float);
00395 IMPORT_C float tanhf(float);
00396 IMPORT_C float exp2f(float);
00397 IMPORT_C float expf(float);
00398 IMPORT_C float expm1f(float);
00399 IMPORT_C float frexpf(float, int *);
00400 IMPORT_C int ilogbf(float) __pure2;
00401 #ifndef __SYMBIAN32__
00402 float ldexpf(float, int);
00403
00404 #endif
00405 IMPORT_C float log10f(float);
00406 IMPORT_C float log1pf(float);
00407 IMPORT_C float logf(float);
00408 IMPORT_C float modff(float, float *);
00409
00410 IMPORT_C float powf(float, float);
00411 IMPORT_C float sqrtf(float);
00412
00413 IMPORT_C float ceilf(float);
00414 IMPORT_C float fabsf(float) __pure2;
00415 IMPORT_C float floorf(float);
00416 IMPORT_C float fmodf(float, float);
00417 IMPORT_C float roundf(float);
00418
00419 IMPORT_C float erff(float);
00420 IMPORT_C float erfcf(float);
00421 IMPORT_C float hypotf(float, float);
00422 IMPORT_C float lgammaf(float);
00423
00424 IMPORT_C float acoshf(float);
00425 IMPORT_C float asinhf(float);
00426 IMPORT_C float atanhf(float);
00427 IMPORT_C float cbrtf(float);
00428 IMPORT_C float logbf(float);
00429 IMPORT_C float copysignf(float, float) __pure2;
00430 IMPORT_C long long llrintf(float);
00431 IMPORT_C long long llroundf(float);
00432 IMPORT_C long lrintf(float);
00433 IMPORT_C long lroundf(float);
00434 IMPORT_C float nearbyintf(float);
00435 IMPORT_C float nextafterf(float, float);
00436 IMPORT_C float remainderf(float, float);
00437 IMPORT_C float remquof(float, float, int *);
00438 IMPORT_C float rintf(float);
00439 IMPORT_C float scalblnf(float, long);
00440 IMPORT_C float scalbnf(float, int);
00441 IMPORT_C float truncf(float);
00442
00443 IMPORT_C float fdimf(float, float);
00444 IMPORT_C float fmaf(float, float, float);
00445 IMPORT_C float fmaxf(float, float) __pure2;
00446 IMPORT_C float fminf(float, float) __pure2;
00447 #endif
00448
00449
00450
00451
00452 #if __BSD_VISIBLE
00453
00454 #ifdef __SYMBIAN_COMPILE_UNUSED__
00455 float dremf(float, float);
00456 #endif
00457
00458 IMPORT_C int finitef(float) __pure2;
00459 IMPORT_C float gammaf(float);
00460 IMPORT_C float j0f(float);
00461 IMPORT_C float j1f(float);
00462 IMPORT_C float jnf(int, float);
00463 IMPORT_C float scalbf(float, float);
00464 IMPORT_C float y0f(float);
00465 IMPORT_C float y1f(float);
00466 IMPORT_C float ynf(int, float);
00467
00468
00469
00470
00471
00472
00473 IMPORT_C float lgammaf_r(float, int *);
00474
00475
00476
00477
00478 IMPORT_C float significandf(float);
00479 #endif
00480
00481
00482
00483
00484 #if __ISO_C_VISIBLE >= 1999
00485 #if 0
00486 long double acoshl(long double);
00487 long double acosl(long double);
00488 long double asinhl(long double);
00489 long double asinl(long double);
00490 long double atan2l(long double, long double);
00491 long double atanhl(long double);
00492 long double atanl(long double);
00493 long double cbrtl(long double);
00494 #endif
00495 #ifndef __SYMBIAN32__
00496 long double ceill(long double);
00497
00498 #endif
00499 IMPORT_C long double copysignl(long double, long double) __pure2;
00500 #if 0
00501 long double coshl(long double);
00502 long double cosl(long double);
00503 long double erfcl(long double);
00504 long double erfl(long double);
00505 long double exp2l(long double);
00506 long double expl(long double);
00507 long double expm1l(long double);
00508 #endif
00509 IMPORT_C long double fabsl(long double) __pure2;
00510 IMPORT_C long double fdiml(long double, long double);
00511 #ifndef __SYMBIAN32__
00512 long double floorl(long double);
00513 long double fmal(long double, long double, long double);
00514
00515 #endif
00516 IMPORT_C long double fmaxl(long double, long double) __pure2;
00517 #ifndef __SYMBIAN32__
00518 long double fminl(long double, long double) __pure2;
00519
00520 #endif
00521 #if 0
00522 long double fmodl(long double, long double);
00523 #endif
00524 #ifndef __SYMBIAN32__
00525 long double frexpl(long double value, int *);
00526
00527 #endif
00528 #if 0
00529 long double hypotl(long double, long double);
00530 #endif
00531 IMPORT_C int ilogbl(long double) __pure2;
00532 #ifndef __SYMBIAN32__
00533 long double ldexpl(long double, int);
00534
00535 #endif
00536 #if 0
00537 long double lgammal(long double);
00538 long long llrintl(long double);
00539 #endif
00540 #ifndef __SYMBIAN32__
00541 long long llroundl(long double);
00542
00543 #endif
00544 #if 0
00545 long double log10l(long double);
00546 long double log1pl(long double);
00547 long double log2l(long double);
00548 long double logbl(long double);
00549 long double logl(long double);
00550 long lrintl(long double);
00551 #endif
00552 #ifndef __SYMBIAN32__
00553 long lroundl(long double);
00554
00555 #endif
00556 #if 0
00557 long double modfl(long double, long double *);
00558 long double nanl(const char *) __pure2;
00559 long double nearbyintl(long double);
00560 #endif
00561 #ifndef __SYMBIAN32__
00562 long double nextafterl(long double, long double);
00563 double nexttoward(double, long double);
00564
00565 #endif
00566 IMPORT_C float nexttowardf(float, long double);
00567 #ifndef __SYMBIAN32__
00568 long double nexttowardl(long double, long double);
00569
00570 #endif
00571 #if 0
00572 long double powl(long double, long double);
00573 long double remainderl(long double, long double);
00574 long double remquol(long double, long double, int *);
00575 long double rintl(long double);
00576 #endif
00577 #ifndef __SYMBIAN32__
00578 long double roundl(long double);
00579
00580 #endif
00581 IMPORT_C long double scalblnl(long double, long);
00582 #ifndef __SYMBIAN32__
00583 long double scalbnl(long double, int);
00584
00585 #endif
00586 #if 0
00587 long double sinhl(long double);
00588 long double sinl(long double);
00589 long double sqrtl(long double);
00590 long double tanhl(long double);
00591 long double tanl(long double);
00592 #endif
00593 IMPORT_C long double truncl(long double);
00594
00595 #endif
00596 __END_DECLS
00597
00598 #endif