16#ifndef _STLP_INTERNAL_CMATH
17#define _STLP_INTERNAL_CMATH
23#if defined (__GNUC__) && defined (_STLP_USE_NEW_C_HEADERS)
24# if defined (_STLP_HAS_INCLUDE_NEXT)
25# include_next <cstdlib>
27# include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
31#if defined (_STLP_USE_NEW_C_HEADERS)
32# if defined (_STLP_HAS_NO_NAMESPACES) && !defined (exception)
33# define exception __math_exception
35# if defined (_STLP_HAS_INCLUDE_NEXT)
38# include _STLP_NATIVE_CPP_C_HEADER(cmath)
40# if defined (_STLP_HAS_NO_NAMESPACES)
47#if (defined (__SUNPRO_CC) && (__SUNPRO_CC > 0x500)) || \
48 !(defined (__IBMCPP__) && (__IBMCPP__ >= 500) || !(defined(__HP_aCC) && (__HP_aCC >= 30000) ))
49# if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(__SUNPRO_CC)
53extern "C" double hypot(
double x,
double y);
54# if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(__SUNPRO_CC)
60#if defined (__sun) && defined (__GNUC__)
62 float __cosf(
float v);
63 float __sinf(
float v);
64 float __atan2f(
float,
float);
65 float __coshf(
float v);
66 float __sinhf(
float v);
67 float __sqrtf(
float v);
68 float __expf(
float v);
69 float __logf(
float v);
70 float __log10f(
float v);
72 long double __cosl(
long double v);
73 long double __sinl(
long double v);
74 long double __atan2l(
long double,
long double);
75 long double __coshl(
long double v);
76 long double __sinhl(
long double v);
77 long double __sqrtl(
long double v);
78 long double __expl(
long double v);
79 long double __logl(
long double v);
80 long double __log10l(
long double v);
84 inline float cosf(
float v) {
return __cosf(
v); }
85 inline float sinf(
float v) {
return __sinf(
v); }
86 inline float atan2f(
float v1,
float v2) {
return __atan2f(
v1,
v2); }
87 inline float coshf(
float v) {
return __coshf(
v); }
88 inline float sinhf(
float v) {
return __sinhf(
v); }
89 inline float sqrtf(
float v) {
return __sqrtf(
v); }
90 inline float expf(
float v) {
return __expf(
v); }
91 inline float logf(
float v) {
return __logf(
v); }
92 inline float log10f(
float v) {
return __log10f(
v); }
94 inline long double cosl(
long double v) {
return __cosl(
v); }
95 inline long double sinl(
long double v) {
return __sinl(
v); }
96 inline long double atan2l(
long double v1,
long double v2) {
return __atan2l(
v1,
v2); }
97 inline long double coshl(
long double v) {
return __coshl(
v); }
98 inline long double sinhl(
long double v) {
return __sinhl(
v); }
99 inline long double sqrtl(
long double v) {
return __sqrtl(
v); }
100 inline long double expl(
long double v) {
return __expl(
v); }
101 inline long double logl(
long double v) {
return __logl(
v); }
102 inline long double log10l(
long double v) {
return __log10l(
v); }
108extern float __acosf(
float);
109extern float __asinf(
float);
110extern float __atanf(
float);
111extern float __atan2f(
float,
float);
112extern float __ceilf(
float);
113extern float __cosf(
float);
114extern float __coshf(
float);
115extern float __expf(
float);
116extern float __fabsf(
float);
117extern float __floorf(
float);
118extern float __fmodf(
float,
float);
119extern float __frexpf(
float,
int *);
120extern float __ldexpf(
float,
int);
121extern float __logf(
float);
122extern float __log10f(
float);
123extern float __modff(
float,
float *);
124extern float __powf(
float,
float);
125extern float __sinf(
float);
126extern float __sinhf(
float);
127extern float __sqrtf(
float);
128extern float __tanf(
float);
129extern float __tanhf(
float);
131extern long double __acosl(
long double);
132extern long double __asinl(
long double);
133extern long double __atanl(
long double);
134extern long double __atan2l(
long double,
long double);
135extern long double __ceill(
long double);
136extern long double __cosl(
long double);
137extern long double __coshl(
long double);
138extern long double __expl(
long double);
139extern long double __fabsl(
long double);
140extern long double __floorl(
long double);
141extern long double __fmodl(
long double,
long double);
142extern long double __frexpl(
long double,
int *);
143extern long double __ldexpl(
long double,
int);
144extern long double __logl(
long double);
145extern long double __log10l(
long double);
146extern long double __modfl(
long double,
long double *);
147extern long double __powl(
long double,
long double);
148extern long double __sinl(
long double);
149extern long double __sinhl(
long double);
150extern long double __sqrtl(
long double);
151extern long double __tanl(
long double);
152extern long double __tanhl(
long double);
156#if defined (__BORLANDC__)
157# define _STLP_CMATH_FUNC_NAMESPACE _STLP_VENDOR_CSTD
159# define _STLP_CMATH_FUNC_NAMESPACE
162#if !defined (__sun) || defined (__GNUC__)
163# define _STLP_MATH_INLINE(float_type, func, cfunc) \
164 inline float_type func (float_type x) { return _STLP_CMATH_FUNC_NAMESPACE::cfunc(x); }
165# define _STLP_MATH_INLINE2(float_type, type, func, cfunc) \
166 inline float_type func (float_type x, type y) { return _STLP_CMATH_FUNC_NAMESPACE::cfunc(x, y); }
167# define _STLP_MATH_INLINE_D(float_type, func, cfunc)
168# define _STLP_MATH_INLINE2_D(float_type, type, func, cfunc)
171# define _STLP_MATH_INLINE(float_type, func, cfunc) \
172 inline float_type func (float_type x) { return _STLP_VENDOR_CSTD::__##cfunc(x); }
173# define _STLP_MATH_INLINE_D(float_type, func, cfunc) \
174 inline float_type func (float_type x) { return _STLP_VENDOR_CSTD::cfunc(x); }
175# define _STLP_MATH_INLINE2(float_type, type, func, cfunc) \
176 inline float_type func (float_type x, type y) { return _STLP_VENDOR_CSTD::__##cfunc(x,y); }
177# define _STLP_MATH_INLINE2_D(float_type, type, func, cfunc) \
178 inline float_type func (float_type x, type y) { return _STLP_VENDOR_CSTD::cfunc(x,y); }
180# error Unknown compiler for the Sun platform
188#define _STLP_MATH_INLINEX(__type,func,cfunc) \
189 inline __type func (__type x) \
190 { return __STATIC_CAST(__type, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x)); }
191#define _STLP_MATH_INLINE2X(__type1,__type2,func,cfunc) \
192 inline __type1 func (__type1 x, __type2 y) \
193 { return __STATIC_CAST(__type1, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x, y)); }
194#define _STLP_MATH_INLINE2PX(__type,func,cfunc) \
195 inline __type func (__type x, __type *y) { \
197 tmp1 = _STLP_CMATH_FUNC_NAMESPACE::cfunc(__STATIC_CAST(double, x), &tmp2); \
198 *y = __STATIC_CAST(__type, tmp2); \
199 return __STATIC_CAST(__type, tmp1); \
201#define _STLP_MATH_INLINE2XX(__type,func,cfunc) \
202 inline __type func (__type x, __type y) \
203 { return __STATIC_CAST(__type, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x, (double)y)); }
228#if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_NO_VENDOR_MATH_L) && !defined (_STLP_NO_VENDOR_MATH_F)
231# define _STLP_DEF_MATH_INLINE(func,cf) \
232 _STLP_MATH_INLINE(float,func,cf##f) \
233 _STLP_MATH_INLINE_D(double,func,cf) \
234 _STLP_MATH_INLINE(long double,func,cf##l)
235# define _STLP_DEF_MATH_INLINE2(func,cf) \
236 _STLP_MATH_INLINE2(float,float,func,cf##f) \
237 _STLP_MATH_INLINE2_D(double,double,func,cf) \
238 _STLP_MATH_INLINE2(long double,long double,func,cf##l)
239# define _STLP_DEF_MATH_INLINE2P(func,cf) \
240 _STLP_MATH_INLINE2(float,float *,func,cf##f) \
241 _STLP_MATH_INLINE2_D(double,double *,func,cf) \
242 _STLP_MATH_INLINE2(long double,long double *,func,cf##l)
243# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
244 _STLP_MATH_INLINE2(float,int *,func,cf##f) \
245 _STLP_MATH_INLINE2_D(double,int *,func,cf) \
246 _STLP_MATH_INLINE2(long double,int *,func,cf##l)
247# define _STLP_DEF_MATH_INLINE2I(func,cf) \
248 _STLP_MATH_INLINE2(float,int,func,cf##f) \
249 _STLP_MATH_INLINE2_D(double,int,func,cf) \
250 _STLP_MATH_INLINE2(long double,int,func,cf##l)
252# if !defined (_STLP_NO_LONG_DOUBLE)
253# if !defined (_STLP_NO_VENDOR_MATH_F)
255# define _STLP_DEF_MATH_INLINE(func,cf) \
256 _STLP_MATH_INLINE(float,func,cf##f) \
257 _STLP_MATH_INLINEX(long double,func,cf)
258# define _STLP_DEF_MATH_INLINE2(func,cf) \
259 _STLP_MATH_INLINE2(float,float,func,cf##f) \
260 _STLP_MATH_INLINE2XX(long double,func,cf)
261# define _STLP_DEF_MATH_INLINE2P(func,cf) \
262 _STLP_MATH_INLINE2(float,float *,func,cf##f) \
263 _STLP_MATH_INLINE2PX(long double,func,cf)
264# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
265 _STLP_MATH_INLINE2(float,int *,func,cf##f) \
266 _STLP_MATH_INLINE2X(long double,int *,func,cf)
267# define _STLP_DEF_MATH_INLINE2I(func,cf) \
268 _STLP_MATH_INLINE2(float,int,func,cf##f) \
269 _STLP_MATH_INLINE2X(long double,int,func,cf)
270# elif !defined (_STLP_NO_VENDOR_MATH_L)
272# define _STLP_DEF_MATH_INLINE(func,cf) \
273 _STLP_MATH_INLINEX(float,func,cf) \
274 _STLP_MATH_INLINE(long double,func,cf##l)
275# define _STLP_DEF_MATH_INLINE2(func,cf) \
276 _STLP_MATH_INLINE2XX(float,func,cf) \
277 _STLP_MATH_INLINE2(long double,long double,func,cf##l)
278# define _STLP_DEF_MATH_INLINE2P(func,cf) \
279 _STLP_MATH_INLINE2PX(float,func,cf) \
280 _STLP_MATH_INLINE2(long double,long double *,func,cf##l)
281# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
282 _STLP_MATH_INLINE2X(float,int *,func,cf) \
283 _STLP_MATH_INLINE2(long double,int *,func,cf##l)
284# define _STLP_DEF_MATH_INLINE2I(func,cf) \
285 _STLP_MATH_INLINE2X(float,int,func,cf) \
286 _STLP_MATH_INLINE2(long double,int,func,cf##l)
288# define _STLP_DEF_MATH_INLINE(func,cf) \
289 _STLP_MATH_INLINEX(float,func,cf) \
290 _STLP_MATH_INLINEX(long double,func,cf)
291# define _STLP_DEF_MATH_INLINE2(func,cf) \
292 _STLP_MATH_INLINE2XX(float,func,cf) \
293 _STLP_MATH_INLINE2XX(long double,func,cf)
294# define _STLP_DEF_MATH_INLINE2P(func,cf) \
295 _STLP_MATH_INLINE2PX(float,func,cf) \
296 _STLP_MATH_INLINE2PX(long double,func,cf)
297# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
298 _STLP_MATH_INLINE2X(float,int *,func,cf) \
299 _STLP_MATH_INLINE2X(long double,int *,func,cf)
300# define _STLP_DEF_MATH_INLINE2I(func,cf) \
301 _STLP_MATH_INLINE2X(float,int,func,cf) \
302 _STLP_MATH_INLINE2X(long double,int,func,cf)
305# if !defined (_STLP_NO_VENDOR_MATH_F)
306# define _STLP_DEF_MATH_INLINE(func,cf) \
307 _STLP_MATH_INLINE(float,func,cf##f)
308# define _STLP_DEF_MATH_INLINE2(func,cf) \
309 _STLP_MATH_INLINE2(float,float,func,cf##f)
310# define _STLP_DEF_MATH_INLINE2P(func,cf) \
311 _STLP_MATH_INLINE2(float,float *,func,cf##f)
312# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
313 _STLP_MATH_INLINE2(float,int *,func,cf##f)
314# define _STLP_DEF_MATH_INLINE2I(func,cf) \
315 _STLP_MATH_INLINE2(float,int,func,cf##f)
318# define _STLP_DEF_MATH_INLINE(func,cf) \
319 _STLP_MATH_INLINEX(float,func,cf)
320# define _STLP_DEF_MATH_INLINE2(func,cf) \
321 _STLP_MATH_INLINE2XX(float,func,cf)
322# define _STLP_DEF_MATH_INLINE2P(func,cf) \
323 _STLP_MATH_INLINE2PX(float,func,cf)
324# define _STLP_DEF_MATH_INLINE2PI(func,cf) \
325 _STLP_MATH_INLINE2X(float,int *,func,cf)
326# define _STLP_DEF_MATH_INLINE2I(func,cf) \
327 _STLP_MATH_INLINE2X(float,int,func,cf)
332#if defined (_STLP_WCE) || \
333 (defined(_STLP_MSVC) && (_STLP_MSVC <= 1300) && defined (_MSC_EXTENSIONS) )
342# pragma warning(push)
343# pragma warning(disable: 4162)
344# pragma warning(disable: 4163)
345# pragma function (abs, acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, sqrt, tan, tanh)
346# if defined (_STLP_WCE)
347# pragma function (ceil, floor)
349# define _STLP_RESTORE_FUNCTION_INTRINSIC
352#if (defined (__BORLANDC__) || defined (__WATCOMC__)) && defined (_STLP_USE_NEW_C_HEADERS)
358# define _STLP_DMATH_INLINE(func) _STLP_MATH_INLINE(double, func, func)
359# define _STLP_DMATH_INLINE2(func) _STLP_MATH_INLINE2(double, double, func, func)
361_STLP_DMATH_INLINE(
acos)
362_STLP_DMATH_INLINE(
asin)
363_STLP_DMATH_INLINE(
atan)
364_STLP_DMATH_INLINE2(
atan2)
365_STLP_DMATH_INLINE(
ceil)
366_STLP_DMATH_INLINE(
cos)
367_STLP_DMATH_INLINE(
cosh)
368_STLP_DMATH_INLINE(
exp)
369_STLP_DMATH_INLINE(
fabs)
370_STLP_DMATH_INLINE(
floor)
371_STLP_DMATH_INLINE2(
fmod)
374_STLP_DMATH_INLINE(
log)
375_STLP_DMATH_INLINE(
log10)
377_STLP_DMATH_INLINE(
sin)
378_STLP_DMATH_INLINE(
sinh)
379_STLP_DMATH_INLINE(
sqrt)
380_STLP_DMATH_INLINE(
tan)
381_STLP_DMATH_INLINE(
tanh)
382_STLP_DMATH_INLINE2(
pow)
383_STLP_DMATH_INLINE2(
hypot)
385# undef _STLP_DMATH_INLINE
386# undef _STLP_DMATH_INLINE2
391inline double __stlp_fabs(
double __x) {
return fabs(__x); }
393inline double fabs(
double __x) {
return __stlp_fabs(__x); }
396inline double __stlp_cos(
double __x) {
return cos(__x); }
398inline double cos(
double __x) {
return __stlp_cos(__x); }
401inline double __stlp_sin(
double __x) {
return sin(__x); }
403inline double sin(
double __x) {
return __stlp_sin(__x); }
406inline double __stlp_sqrt(
double __x) {
return sqrt(__x); }
408inline double sqrt(
double __x) {
return __stlp_sqrt(__x); }
411inline double __stlp_ldexp(
double __x,
int __y) {
return ldexp(__x, __y); }
413inline double ldexp(
double __x,
int __y) {
return __stlp_ldexp(__x, __y); }
421#if (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined(UNDER_CE)) && \
422 (!defined (__HP_aCC) || (__HP_aCC < 30000)) && \
423 !defined (__WATCOMC__)
424inline double abs(
double __x)
425{ return ::fabs(__x); }
426# if !defined (__MVS__)
429inline float abs(
float __x) { return ::fabsf(__x); }
455# if !defined(_STLP_MSVC) || defined(_STLP_WCE) || !defined (_MSC_EXTENSIONS)
456# ifndef _STLP_NO_VENDOR_MATH_F
458inline float pow(
float __x,
int __y) {
return _STLP_CMATH_FUNC_NAMESPACE::powf(__x,
__STATIC_CAST(
float,__y)); }
460inline float pow(
float __x,
int __y) { return ::__powf(__x,
__STATIC_CAST(
float,__y)); }
465inline double pow(
double __x,
int __y) {
return _STLP_CMATH_FUNC_NAMESPACE::pow(__x,
__STATIC_CAST(
double,__y)); }
466# if !defined (_STLP_NO_LONG_DOUBLE)
467# if !defined(_STLP_NO_VENDOR_MATH_L)
469inline long double pow(
long double __x,
int __y) {
return _STLP_CMATH_FUNC_NAMESPACE::powl(__x,
__STATIC_CAST(
long double,__y)); }
472inline long double pow(
long double __x,
int __y) { return ::__powl(__x,
__STATIC_CAST(
long double,__y)); }
474inline long double pow(
long double __x,
int __y) {
return _STLP_VENDOR_CSTD::__powl(__x,
__STATIC_CAST(
long double,__y)); }
478inline long double pow(
long double __x,
int __y) {
return __STATIC_CAST(
long double, _STLP_CMATH_FUNC_NAMESPACE::pow(__x,
__STATIC_CAST(
long double,__y))); }
486inline double pow(
double __x,
int __y) {
return (_Pow_int(__x, __y)); }
487inline float pow(
float __x,
int __y) {
return (_Pow_int(__x, __y)); }
488inline long double pow(
long double __x,
int __y) {
return (_Pow_int(__x, __y)); }
492#if (defined (_STLP_MSVC) && !defined (_STLP_WCE)) || defined (__ICL) || defined (__sun)
493# if defined (_STLP_MSVC) && (_STLP_MSVC >= 1400)
494# pragma warning (push)
495# pragma warning (disable : 4996)
498inline long double hypot(
long double x,
long double y) {
return sqrt(
x *
x +
y *
y); }
499# if defined (_STLP_MSVC) && (_STLP_MSVC >= 1400)
500# pragma warning (pop)
503# if defined (_STLP_USE_UCLIBC)
506# elif defined (_STLP_WCE)
508inline double hypot(
double __x,
double __y) {
return _hypot(__x,__y); }
513#if defined (_STLP_RESTORE_FUNCTION_INTRINSIC)
515# pragma intrinsic (abs, acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, sqrt, tan, tanh)
516# if defined (_STLP_WCE)
517# pragma intrinsic (ceil, floor)
520# undef _STLP_RESTORE_FUNCTION_INTRINSIC
529#ifndef _STLP_INTERNAL_CSTDLIB
533#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
555#if !(defined(__HP_aCC) && defined(_STLP_DEBUG))
569# if defined (__BORLANDC__) && (__BORLANDC__ >= 0x560) && !defined (__linux__)
570using _STLP_VENDOR_CSTD::_ecvt;
571using _STLP_VENDOR_CSTD::_fcvt;
#define _STLP_MATH_INLINE2X(__type1, __type2, func, cfunc)
#define _STLP_DEF_MATH_INLINE2(func, cf)
#define _STLP_MATH_INLINE2XX(__type, func, cfunc)
#define _STLP_DEF_MATH_INLINE2P(func, cf)
#define _STLP_MATH_INLINE2PX(__type, func, cfunc)
#define _STLP_DEF_MATH_INLINE(func, cf)
#define _STLP_DEF_MATH_INLINE2I(func, cf)
float pow(float __x, int __y)
#define _STLP_DEF_MATH_INLINE2PI(func, cf)
_STLP_DECLSPEC complex< float > _STLP_CALL sinh(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL tan(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL cosh(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL tanh(const complex< float > &)
valarray< _Tp > acos(const valarray< _Tp > &__x)
valarray< _Tp > atan(const valarray< _Tp > &__x)
valarray< _Tp > asin(const valarray< _Tp > &__x)
valarray< _Tp > atan2(const valarray< _Tp > &__x, const valarray< _Tp > &__y)
#define __STATIC_CAST(__x, __y)
#define _STLP_BEGIN_NAMESPACE
#define _STLP_END_NAMESPACE
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLfloat GLfloat GLfloat v2
_Check_return_ __CRT_INLINE long double coshl(_In_ long double x)
_Check_return_ __CRT_INLINE long double sinhl(_In_ long double x)
_Check_return_ __CRT_INLINE long double atan2l(_In_ long double y, _In_ long double x)
_Check_return_ _CRTIMP double __cdecl frexp(_In_ double x, _Out_ int *y)
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
_Check_return_ float __cdecl logf(_In_ float x)
_Check_return_ _CRTIMP double __cdecl ldexp(_In_ double x, _In_ int y)
_Check_return_ float __cdecl expf(_In_ float x)
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)
_Check_return_ __CRT_INLINE long double cosl(_In_ long double x)
_Check_return_ __CRT_INLINE long double log10l(_In_ long double x)
_Check_return_ float __cdecl cosf(_In_ float x)
_Check_return_ _CRTIMP double __cdecl _hypot(_In_ double x, _In_ double y)
_Check_return_ double __cdecl fmod(_In_ double x, _In_ double y)
_Check_return_ float __cdecl log10f(_In_ float x)
_Check_return_ __CRT_INLINE double hypot(_In_ double x, _In_ double y)
_Check_return_ __CRT_INLINE long double expl(_In_ long double x)
_Check_return_ __CRT_INLINE long double sqrtl(_In_ long double x)
_Check_return_ float __cdecl coshf(_In_ float x)
_Check_return_ __CRT_INLINE long double logl(_In_ long double x)
_Check_return_ float __cdecl sinhf(_In_ float x)
_Check_return_ __CRT_INLINE long double sinl(_In_ long double x)
_Check_return_ float __cdecl atan2f(_In_ float x, _In_ float y)
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
_Check_return_ _CRTIMP double __cdecl ceil(_In_ double x)
_Check_return_ float __cdecl sinf(_In_ float x)