cmath revision 300770
1227825Stheraven// -*- C++ -*- 2227825Stheraven//===---------------------------- cmath -----------------------------------===// 3227825Stheraven// 4227825Stheraven// The LLVM Compiler Infrastructure 5227825Stheraven// 6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open 7227825Stheraven// Source Licenses. See LICENSE.TXT for details. 8227825Stheraven// 9227825Stheraven//===----------------------------------------------------------------------===// 10227825Stheraven 11227825Stheraven#ifndef _LIBCPP_CMATH 12227825Stheraven#define _LIBCPP_CMATH 13227825Stheraven 14227825Stheraven/* 15227825Stheraven cmath synopsis 16227825Stheraven 17227825StheravenMacros: 18227825Stheraven 19227825Stheraven HUGE_VAL 20227825Stheraven HUGE_VALF // C99 21227825Stheraven HUGE_VALL // C99 22227825Stheraven INFINITY // C99 23227825Stheraven NAN // C99 24227825Stheraven FP_INFINITE // C99 25227825Stheraven FP_NAN // C99 26227825Stheraven FP_NORMAL // C99 27227825Stheraven FP_SUBNORMAL // C99 28227825Stheraven FP_ZERO // C99 29227825Stheraven FP_FAST_FMA // C99 30227825Stheraven FP_FAST_FMAF // C99 31227825Stheraven FP_FAST_FMAL // C99 32227825Stheraven FP_ILOGB0 // C99 33227825Stheraven FP_ILOGBNAN // C99 34227825Stheraven MATH_ERRNO // C99 35227825Stheraven MATH_ERREXCEPT // C99 36227825Stheraven math_errhandling // C99 37227825Stheraven 38227825Stheravennamespace std 39227825Stheraven{ 40227825Stheraven 41227825StheravenTypes: 42227825Stheraven 43227825Stheraven float_t // C99 44227825Stheraven double_t // C99 45227825Stheraven 46227825Stheraven// C90 47227825Stheraven 48227825Stheravenfloating_point abs(floating_point x); 49227825Stheraven 50227825Stheravenfloating_point acos (arithmetic x); 51227825Stheravenfloat acosf(float x); 52227825Stheravenlong double acosl(long double x); 53227825Stheraven 54227825Stheravenfloating_point asin (arithmetic x); 55227825Stheravenfloat asinf(float x); 56227825Stheravenlong double asinl(long double x); 57227825Stheraven 58227825Stheravenfloating_point atan (arithmetic x); 59227825Stheravenfloat atanf(float x); 60227825Stheravenlong double atanl(long double x); 61227825Stheraven 62227825Stheravenfloating_point atan2 (arithmetic y, arithmetic x); 63227825Stheravenfloat atan2f(float y, float x); 64227825Stheravenlong double atan2l(long double y, long double x); 65227825Stheraven 66227825Stheravenfloating_point ceil (arithmetic x); 67227825Stheravenfloat ceilf(float x); 68227825Stheravenlong double ceill(long double x); 69227825Stheraven 70227825Stheravenfloating_point cos (arithmetic x); 71227825Stheravenfloat cosf(float x); 72227825Stheravenlong double cosl(long double x); 73227825Stheraven 74227825Stheravenfloating_point cosh (arithmetic x); 75227825Stheravenfloat coshf(float x); 76227825Stheravenlong double coshl(long double x); 77227825Stheraven 78227825Stheravenfloating_point exp (arithmetic x); 79227825Stheravenfloat expf(float x); 80227825Stheravenlong double expl(long double x); 81227825Stheraven 82227825Stheravenfloating_point fabs (arithmetic x); 83227825Stheravenfloat fabsf(float x); 84227825Stheravenlong double fabsl(long double x); 85227825Stheraven 86227825Stheravenfloating_point floor (arithmetic x); 87227825Stheravenfloat floorf(float x); 88227825Stheravenlong double floorl(long double x); 89227825Stheraven 90227825Stheravenfloating_point fmod (arithmetic x, arithmetic y); 91227825Stheravenfloat fmodf(float x, float y); 92227825Stheravenlong double fmodl(long double x, long double y); 93227825Stheraven 94227825Stheravenfloating_point frexp (arithmetic value, int* exp); 95227825Stheravenfloat frexpf(float value, int* exp); 96227825Stheravenlong double frexpl(long double value, int* exp); 97227825Stheraven 98227825Stheravenfloating_point ldexp (arithmetic value, int exp); 99227825Stheravenfloat ldexpf(float value, int exp); 100227825Stheravenlong double ldexpl(long double value, int exp); 101227825Stheraven 102227825Stheravenfloating_point log (arithmetic x); 103227825Stheravenfloat logf(float x); 104227825Stheravenlong double logl(long double x); 105227825Stheraven 106227825Stheravenfloating_point log10 (arithmetic x); 107227825Stheravenfloat log10f(float x); 108227825Stheravenlong double log10l(long double x); 109227825Stheraven 110227825Stheravenfloating_point modf (floating_point value, floating_point* iptr); 111227825Stheravenfloat modff(float value, float* iptr); 112227825Stheravenlong double modfl(long double value, long double* iptr); 113227825Stheraven 114227825Stheravenfloating_point pow (arithmetic x, arithmetic y); 115227825Stheravenfloat powf(float x, float y); 116227825Stheravenlong double powl(long double x, long double y); 117227825Stheraven 118227825Stheravenfloating_point sin (arithmetic x); 119227825Stheravenfloat sinf(float x); 120227825Stheravenlong double sinl(long double x); 121227825Stheraven 122227825Stheravenfloating_point sinh (arithmetic x); 123227825Stheravenfloat sinhf(float x); 124227825Stheravenlong double sinhl(long double x); 125227825Stheraven 126227825Stheravenfloating_point sqrt (arithmetic x); 127227825Stheravenfloat sqrtf(float x); 128227825Stheravenlong double sqrtl(long double x); 129227825Stheraven 130227825Stheravenfloating_point tan (arithmetic x); 131227825Stheravenfloat tanf(float x); 132227825Stheravenlong double tanl(long double x); 133227825Stheraven 134227825Stheravenfloating_point tanh (arithmetic x); 135227825Stheravenfloat tanhf(float x); 136227825Stheravenlong double tanhl(long double x); 137227825Stheraven 138227825Stheraven// C99 139227825Stheraven 140246468Stheravenbool signbit(arithmetic x); 141227825Stheraven 142246468Stheravenint fpclassify(arithmetic x); 143227825Stheraven 144246468Stheravenbool isfinite(arithmetic x); 145246468Stheravenbool isinf(arithmetic x); 146246468Stheravenbool isnan(arithmetic x); 147246468Stheravenbool isnormal(arithmetic x); 148227825Stheraven 149246468Stheravenbool isgreater(arithmetic x, arithmetic y); 150246468Stheravenbool isgreaterequal(arithmetic x, arithmetic y); 151246468Stheravenbool isless(arithmetic x, arithmetic y); 152246468Stheravenbool islessequal(arithmetic x, arithmetic y); 153246468Stheravenbool islessgreater(arithmetic x, arithmetic y); 154246468Stheravenbool isunordered(arithmetic x, arithmetic y); 155227825Stheraven 156227825Stheravenfloating_point acosh (arithmetic x); 157227825Stheravenfloat acoshf(float x); 158227825Stheravenlong double acoshl(long double x); 159227825Stheraven 160227825Stheravenfloating_point asinh (arithmetic x); 161227825Stheravenfloat asinhf(float x); 162227825Stheravenlong double asinhl(long double x); 163227825Stheraven 164227825Stheravenfloating_point atanh (arithmetic x); 165227825Stheravenfloat atanhf(float x); 166227825Stheravenlong double atanhl(long double x); 167227825Stheraven 168227825Stheravenfloating_point cbrt (arithmetic x); 169227825Stheravenfloat cbrtf(float x); 170227825Stheravenlong double cbrtl(long double x); 171227825Stheraven 172227825Stheravenfloating_point copysign (arithmetic x, arithmetic y); 173227825Stheravenfloat copysignf(float x, float y); 174227825Stheravenlong double copysignl(long double x, long double y); 175227825Stheraven 176227825Stheravenfloating_point erf (arithmetic x); 177227825Stheravenfloat erff(float x); 178227825Stheravenlong double erfl(long double x); 179227825Stheraven 180227825Stheravenfloating_point erfc (arithmetic x); 181227825Stheravenfloat erfcf(float x); 182227825Stheravenlong double erfcl(long double x); 183227825Stheraven 184227825Stheravenfloating_point exp2 (arithmetic x); 185227825Stheravenfloat exp2f(float x); 186227825Stheravenlong double exp2l(long double x); 187227825Stheraven 188227825Stheravenfloating_point expm1 (arithmetic x); 189227825Stheravenfloat expm1f(float x); 190227825Stheravenlong double expm1l(long double x); 191227825Stheraven 192227825Stheravenfloating_point fdim (arithmetic x, arithmetic y); 193227825Stheravenfloat fdimf(float x, float y); 194227825Stheravenlong double fdiml(long double x, long double y); 195227825Stheraven 196227825Stheravenfloating_point fma (arithmetic x, arithmetic y, arithmetic z); 197227825Stheravenfloat fmaf(float x, float y, float z); 198227825Stheravenlong double fmal(long double x, long double y, long double z); 199227825Stheraven 200227825Stheravenfloating_point fmax (arithmetic x, arithmetic y); 201227825Stheravenfloat fmaxf(float x, float y); 202227825Stheravenlong double fmaxl(long double x, long double y); 203227825Stheraven 204227825Stheravenfloating_point fmin (arithmetic x, arithmetic y); 205227825Stheravenfloat fminf(float x, float y); 206227825Stheravenlong double fminl(long double x, long double y); 207227825Stheraven 208227825Stheravenfloating_point hypot (arithmetic x, arithmetic y); 209227825Stheravenfloat hypotf(float x, float y); 210227825Stheravenlong double hypotl(long double x, long double y); 211227825Stheraven 212227825Stheravenint ilogb (arithmetic x); 213227825Stheravenint ilogbf(float x); 214227825Stheravenint ilogbl(long double x); 215227825Stheraven 216227825Stheravenfloating_point lgamma (arithmetic x); 217227825Stheravenfloat lgammaf(float x); 218227825Stheravenlong double lgammal(long double x); 219227825Stheraven 220227825Stheravenlong long llrint (arithmetic x); 221227825Stheravenlong long llrintf(float x); 222227825Stheravenlong long llrintl(long double x); 223227825Stheraven 224227825Stheravenlong long llround (arithmetic x); 225227825Stheravenlong long llroundf(float x); 226227825Stheravenlong long llroundl(long double x); 227227825Stheraven 228227825Stheravenfloating_point log1p (arithmetic x); 229227825Stheravenfloat log1pf(float x); 230227825Stheravenlong double log1pl(long double x); 231227825Stheraven 232227825Stheravenfloating_point log2 (arithmetic x); 233227825Stheravenfloat log2f(float x); 234227825Stheravenlong double log2l(long double x); 235227825Stheraven 236227825Stheravenfloating_point logb (arithmetic x); 237227825Stheravenfloat logbf(float x); 238227825Stheravenlong double logbl(long double x); 239227825Stheraven 240227825Stheravenlong lrint (arithmetic x); 241227825Stheravenlong lrintf(float x); 242227825Stheravenlong lrintl(long double x); 243227825Stheraven 244227825Stheravenlong lround (arithmetic x); 245227825Stheravenlong lroundf(float x); 246227825Stheravenlong lroundl(long double x); 247227825Stheraven 248227825Stheravendouble nan (const char* str); 249227825Stheravenfloat nanf(const char* str); 250227825Stheravenlong double nanl(const char* str); 251227825Stheraven 252227825Stheravenfloating_point nearbyint (arithmetic x); 253227825Stheravenfloat nearbyintf(float x); 254227825Stheravenlong double nearbyintl(long double x); 255227825Stheraven 256227825Stheravenfloating_point nextafter (arithmetic x, arithmetic y); 257227825Stheravenfloat nextafterf(float x, float y); 258227825Stheravenlong double nextafterl(long double x, long double y); 259227825Stheraven 260227825Stheravenfloating_point nexttoward (arithmetic x, long double y); 261227825Stheravenfloat nexttowardf(float x, long double y); 262227825Stheravenlong double nexttowardl(long double x, long double y); 263227825Stheraven 264227825Stheravenfloating_point remainder (arithmetic x, arithmetic y); 265227825Stheravenfloat remainderf(float x, float y); 266227825Stheravenlong double remainderl(long double x, long double y); 267227825Stheraven 268227825Stheravenfloating_point remquo (arithmetic x, arithmetic y, int* pquo); 269227825Stheravenfloat remquof(float x, float y, int* pquo); 270227825Stheravenlong double remquol(long double x, long double y, int* pquo); 271227825Stheraven 272227825Stheravenfloating_point rint (arithmetic x); 273227825Stheravenfloat rintf(float x); 274227825Stheravenlong double rintl(long double x); 275227825Stheraven 276227825Stheravenfloating_point round (arithmetic x); 277227825Stheravenfloat roundf(float x); 278227825Stheravenlong double roundl(long double x); 279227825Stheraven 280227825Stheravenfloating_point scalbln (arithmetic x, long ex); 281227825Stheravenfloat scalblnf(float x, long ex); 282227825Stheravenlong double scalblnl(long double x, long ex); 283227825Stheraven 284227825Stheravenfloating_point scalbn (arithmetic x, int ex); 285227825Stheravenfloat scalbnf(float x, int ex); 286227825Stheravenlong double scalbnl(long double x, int ex); 287227825Stheraven 288227825Stheravenfloating_point tgamma (arithmetic x); 289227825Stheravenfloat tgammaf(float x); 290227825Stheravenlong double tgammal(long double x); 291227825Stheraven 292227825Stheravenfloating_point trunc (arithmetic x); 293227825Stheravenfloat truncf(float x); 294227825Stheravenlong double truncl(long double x); 295227825Stheraven 296227825Stheraven} // std 297227825Stheraven 298227825Stheraven*/ 299227825Stheraven 300227825Stheraven#include <__config> 301227825Stheraven#include <math.h> 302227825Stheraven 303227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 304227825Stheraven#pragma GCC system_header 305227825Stheraven#endif 306227825Stheraven 307227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 308227825Stheraven 309227825Stheravenusing ::signbit; 310227825Stheravenusing ::fpclassify; 311227825Stheravenusing ::isfinite; 312227825Stheravenusing ::isinf; 313227825Stheravenusing ::isnan; 314227825Stheravenusing ::isnormal; 315227825Stheravenusing ::isgreater; 316227825Stheravenusing ::isgreaterequal; 317227825Stheravenusing ::isless; 318227825Stheravenusing ::islessequal; 319227825Stheravenusing ::islessgreater; 320227825Stheravenusing ::isunordered; 321227825Stheravenusing ::isunordered; 322227825Stheraven 323227825Stheravenusing ::float_t; 324227825Stheravenusing ::double_t; 325227825Stheraven 326300770Sdim#ifndef _AIX 327288943Sdimusing ::abs; 328288943Sdim#endif 329288943Sdim 330232924Stheraven#ifndef __sun__ 331227825Stheravenusing ::acos; 332227825Stheravenusing ::acosf; 333227825Stheravenusing ::asin; 334227825Stheravenusing ::asinf; 335227825Stheravenusing ::atan; 336227825Stheravenusing ::atanf; 337227825Stheravenusing ::atan2; 338227825Stheravenusing ::atan2f; 339227825Stheravenusing ::ceil; 340227825Stheravenusing ::ceilf; 341227825Stheravenusing ::cos; 342227825Stheravenusing ::cosf; 343227825Stheravenusing ::cosh; 344227825Stheravenusing ::coshf; 345232924Stheraven#endif // __sun__ 346227825Stheraven 347227825Stheravenusing ::exp; 348227825Stheravenusing ::expf; 349227825Stheraven 350232924Stheraven#ifndef __sun__ 351227825Stheravenusing ::fabs; 352227825Stheravenusing ::fabsf; 353227825Stheravenusing ::floor; 354227825Stheravenusing ::floorf; 355300770Sdim#endif //__sun__ 356227825Stheraven 357227825Stheravenusing ::fmod; 358227825Stheravenusing ::fmodf; 359300770Sdim 360232924Stheraven#ifndef __sun__ 361227825Stheravenusing ::frexp; 362227825Stheravenusing ::frexpf; 363227825Stheravenusing ::ldexp; 364227825Stheravenusing ::ldexpf; 365300770Sdim#endif // __sun__ 366227825Stheraven 367227825Stheravenusing ::log; 368227825Stheravenusing ::logf; 369300770Sdim 370232924Stheraven#ifndef __sun__ 371227825Stheravenusing ::log10; 372227825Stheravenusing ::log10f; 373227825Stheravenusing ::modf; 374227825Stheravenusing ::modff; 375300770Sdim#endif // __sun__ 376227825Stheraven 377227825Stheravenusing ::pow; 378227825Stheravenusing ::powf; 379227825Stheraven 380232924Stheraven#ifndef __sun__ 381227825Stheravenusing ::sin; 382227825Stheravenusing ::sinf; 383227825Stheravenusing ::sinh; 384227825Stheravenusing ::sinhf; 385300770Sdim#endif // __sun__ 386227825Stheraven 387227825Stheravenusing ::sqrt; 388227825Stheravenusing ::sqrtf; 389227825Stheravenusing ::tan; 390227825Stheravenusing ::tanf; 391300770Sdim 392232924Stheraven#ifndef __sun__ 393227825Stheravenusing ::tanh; 394227825Stheravenusing ::tanhf; 395227825Stheraven 396261272Sdim#ifndef _LIBCPP_MSVCRT 397227825Stheravenusing ::acosh; 398227825Stheravenusing ::acoshf; 399227825Stheravenusing ::asinh; 400227825Stheravenusing ::asinhf; 401227825Stheravenusing ::atanh; 402227825Stheravenusing ::atanhf; 403227825Stheravenusing ::cbrt; 404227825Stheravenusing ::cbrtf; 405227825Stheraven#endif 406227825Stheraven 407227825Stheravenusing ::copysign; 408227825Stheravenusing ::copysignf; 409227825Stheraven 410261272Sdim#ifndef _LIBCPP_MSVCRT 411227825Stheravenusing ::erf; 412227825Stheravenusing ::erff; 413227825Stheravenusing ::erfc; 414227825Stheravenusing ::erfcf; 415227825Stheravenusing ::exp2; 416227825Stheravenusing ::exp2f; 417227825Stheravenusing ::expm1; 418227825Stheravenusing ::expm1f; 419227825Stheravenusing ::fdim; 420227825Stheravenusing ::fdimf; 421276792Sdimusing ::fmaf; 422227825Stheravenusing ::fma; 423227825Stheravenusing ::fmax; 424227825Stheravenusing ::fmaxf; 425227825Stheravenusing ::fmin; 426227825Stheravenusing ::fminf; 427227825Stheravenusing ::hypot; 428227825Stheravenusing ::hypotf; 429227825Stheravenusing ::ilogb; 430227825Stheravenusing ::ilogbf; 431227825Stheravenusing ::lgamma; 432227825Stheravenusing ::lgammaf; 433227825Stheravenusing ::llrint; 434227825Stheravenusing ::llrintf; 435227825Stheravenusing ::llround; 436227825Stheravenusing ::llroundf; 437227825Stheravenusing ::log1p; 438227825Stheravenusing ::log1pf; 439227825Stheravenusing ::log2; 440227825Stheravenusing ::log2f; 441227825Stheravenusing ::logb; 442227825Stheravenusing ::logbf; 443227825Stheravenusing ::lrint; 444227825Stheravenusing ::lrintf; 445227825Stheravenusing ::lround; 446227825Stheravenusing ::lroundf; 447261272Sdim#endif // _LIBCPP_MSVCRT 448261272Sdim#endif // __sun__ 449261272Sdim 450261272Sdim#ifndef _LIBCPP_MSVCRT 451227825Stheravenusing ::nan; 452227825Stheravenusing ::nanf; 453261272Sdim#endif // _LIBCPP_MSVCRT 454261272Sdim 455232924Stheraven#ifndef __sun__ 456261272Sdim#ifndef _LIBCPP_MSVCRT 457227825Stheravenusing ::nearbyint; 458227825Stheravenusing ::nearbyintf; 459227825Stheravenusing ::nextafter; 460227825Stheravenusing ::nextafterf; 461227825Stheravenusing ::nexttoward; 462227825Stheravenusing ::nexttowardf; 463227825Stheravenusing ::remainder; 464227825Stheravenusing ::remainderf; 465227825Stheravenusing ::remquo; 466227825Stheravenusing ::remquof; 467227825Stheravenusing ::rint; 468227825Stheravenusing ::rintf; 469227825Stheravenusing ::round; 470227825Stheravenusing ::roundf; 471227825Stheravenusing ::scalbln; 472227825Stheravenusing ::scalblnf; 473227825Stheravenusing ::scalbn; 474227825Stheravenusing ::scalbnf; 475227825Stheravenusing ::tgamma; 476227825Stheravenusing ::tgammaf; 477227825Stheravenusing ::trunc; 478227825Stheravenusing ::truncf; 479261272Sdim#endif // !_LIBCPP_MSVCRT 480227825Stheraven 481227825Stheravenusing ::acosl; 482227825Stheravenusing ::asinl; 483227825Stheravenusing ::atanl; 484227825Stheravenusing ::atan2l; 485227825Stheravenusing ::ceill; 486227825Stheravenusing ::cosl; 487227825Stheravenusing ::coshl; 488227825Stheravenusing ::expl; 489227825Stheravenusing ::fabsl; 490227825Stheravenusing ::floorl; 491227825Stheravenusing ::fmodl; 492227825Stheravenusing ::frexpl; 493227825Stheravenusing ::ldexpl; 494227825Stheravenusing ::logl; 495227825Stheravenusing ::log10l; 496227825Stheravenusing ::modfl; 497227825Stheravenusing ::powl; 498227825Stheravenusing ::sinl; 499227825Stheravenusing ::sinhl; 500227825Stheravenusing ::sqrtl; 501227825Stheravenusing ::tanl; 502300770Sdim 503261272Sdim#ifndef _LIBCPP_MSVCRT 504227825Stheravenusing ::tanhl; 505227825Stheravenusing ::acoshl; 506227825Stheravenusing ::asinhl; 507227825Stheravenusing ::atanhl; 508227825Stheravenusing ::cbrtl; 509261272Sdim#endif // !_LIBCPP_MSVCRT 510300770Sdim 511227825Stheravenusing ::copysignl; 512300770Sdim 513261272Sdim#ifndef _LIBCPP_MSVCRT 514227825Stheravenusing ::erfl; 515227825Stheravenusing ::erfcl; 516227825Stheravenusing ::exp2l; 517227825Stheravenusing ::expm1l; 518227825Stheravenusing ::fdiml; 519227825Stheravenusing ::fmal; 520227825Stheravenusing ::fmaxl; 521227825Stheravenusing ::fminl; 522227825Stheravenusing ::hypotl; 523227825Stheravenusing ::ilogbl; 524227825Stheravenusing ::lgammal; 525227825Stheravenusing ::llrintl; 526227825Stheravenusing ::llroundl; 527227825Stheravenusing ::log1pl; 528227825Stheravenusing ::log2l; 529227825Stheravenusing ::logbl; 530227825Stheravenusing ::lrintl; 531227825Stheravenusing ::lroundl; 532227825Stheravenusing ::nanl; 533227825Stheravenusing ::nearbyintl; 534227825Stheravenusing ::nextafterl; 535227825Stheravenusing ::nexttowardl; 536227825Stheravenusing ::remainderl; 537227825Stheravenusing ::remquol; 538227825Stheravenusing ::rintl; 539227825Stheravenusing ::roundl; 540227825Stheravenusing ::scalblnl; 541227825Stheravenusing ::scalbnl; 542227825Stheravenusing ::tgammal; 543227825Stheravenusing ::truncl; 544261272Sdim#endif // !_LIBCPP_MSVCRT 545227825Stheraven 546232924Stheraven#else 547232924Stheravenusing ::lgamma; 548232924Stheravenusing ::lgammaf; 549232924Stheraven#endif // __sun__ 550300770Sdim 551227825Stheraven_LIBCPP_END_NAMESPACE_STD 552227825Stheraven 553227825Stheraven#endif // _LIBCPP_CMATH 554