epoc32/include/stdapis/stlport/stl/_cmath.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     3  *
     4  * Copyright (c) 1999 
     5  * Boris Fomitchev
     6  *
     7  * This material is provided "as is", with absolutely no warranty expressed
     8  * or implied. Any use is at your own risk.
     9  *
    10  * Permission to use or copy this software for any purpose is hereby granted 
    11  * without fee, provided the above notices are retained on all copies.
    12  * Permission to modify the code and to distribute modified code is granted,
    13  * provided the above notices are retained, and a notice that the code was
    14  * modified is included with the above copyright notice.
    15  *
    16  */
    17 
    18 #ifndef _STLP_CMATH_H_HEADER
    19 # define _STLP_CMATH_H_HEADER
    20 
    21 # include <cmath>
    22 
    23 _STLP_BEGIN_NAMESPACE
    24 
    25 # if defined  (_STLP_SAME_FUNCTION_NAME_RESOLUTION_BUG) && (! defined (_STLP_VXWORKS_TORNADO)) 
    26 
    27 // this proxy is needed for some compilers to resolve problems
    28 // calling sqrt() from within sqrt(), etc.
    29 template <class _Tp>
    30 struct _STL_math_proxy {
    31   static inline _Tp _do_abs(const _Tp& __x)     { return _STLP_VENDOR_CSTD::fabs(__x); } 
    32   static inline _Tp _do_acos(const _Tp& __x)    { return _STLP_VENDOR_CSTD::acos(__x); } 
    33   static inline _Tp _do_asin(const _Tp& __x)    { return _STLP_VENDOR_CSTD::asin(__x); } 
    34   static inline _Tp _do_atan(const _Tp& __x)    { return _STLP_VENDOR_CSTD::atan(__x); } 
    35   static inline _Tp _do_atan2(const _Tp& __x, const _Tp& __y)  { return _STLP_VENDOR_CSTD::atan2(__x, __y); } 
    36   static inline _Tp _do_cos(const _Tp& __x)     { return _STLP_VENDOR_CSTD::cos(__x); } 
    37   static inline _Tp _do_cosh(const _Tp& __x)    { return _STLP_VENDOR_CSTD::cosh(__x); } 
    38   static inline _Tp _do_floor(const _Tp& __x)    { return _STLP_VENDOR_CSTD::floor(__x); } 
    39   static inline _Tp _do_ceil(const _Tp& __x)    { return _STLP_VENDOR_CSTD::ceil(__x); } 
    40   static inline _Tp _do_fmod(const _Tp& __x, const _Tp& __y)    { return _STLP_VENDOR_CSTD::fmod(__x, __y); } 
    41   static inline _Tp _do_frexp(const _Tp& __x, int* __y)    { return _STLP_VENDOR_CSTD::frexp(__x, __y); } 
    42   static inline _Tp _do_ldexp(const _Tp& __x, int __y)    { return _STLP_VENDOR_CSTD::ldexp(__x, __y); } 
    43   static inline _Tp _do_modf(const _Tp& __x, double* __y) { return _STLP_VENDOR_CSTD::modf(__x, __y); }
    44   static inline _Tp _do_log(const _Tp& __x)     { return _STLP_VENDOR_CSTD::log(__x); } 
    45   static inline _Tp _do_log10(const _Tp& __x)   { return _STLP_VENDOR_CSTD::log10(__x); } 
    46   static inline _Tp _do_pow(const _Tp& __x, const _Tp& __y)    { return _STLP_VENDOR_CSTD::pow(__x, __y); } 
    47   static inline _Tp _do_pow(const _Tp& __x, int __y)    { return _STLP_VENDOR_CSTD::pow(__x, __y); } 
    48   static inline _Tp _do_sin(const _Tp& __x)     { return _STLP_VENDOR_CSTD::sin(__x); } 
    49   static inline _Tp _do_sinh(const _Tp& __x)    { return _STLP_VENDOR_CSTD::sinh(__x); } 
    50 
    51   static inline _Tp _do_sqrt(const _Tp& __x)    { return _STLP_VENDOR_CSTD::sqrt(__x); } 
    52   static inline _Tp _do_tan(const _Tp& __x)     { return _STLP_VENDOR_CSTD::tan(__x); } 
    53   static inline _Tp _do_tanh(const _Tp& __x)    { return _STLP_VENDOR_CSTD::tanh(__x); } 
    54   static inline _Tp _do_exp(const _Tp& __x)     { return _STLP_VENDOR_CSTD::exp(__x); } 
    55   static inline _Tp _do_hypot(const _Tp& __x, const _Tp& __y)   { return _STLP_VENDOR_CSTD::hypot(__x, __y); } 
    56 };
    57 
    58 #  define _STLP_DO_ABS(_Tp)   _STL_math_proxy<_Tp>::_do_abs
    59 #  define _STLP_DO_ACOS(_Tp)  _STL_math_proxy<_Tp>::_do_acos
    60 #  define _STLP_DO_ASIN(_Tp)  _STL_math_proxy<_Tp>::_do_asin
    61 #  define _STLP_DO_ATAN(_Tp)  _STL_math_proxy<_Tp>::_do_atan
    62 #  define _STLP_DO_ATAN2(_Tp) _STL_math_proxy<_Tp>::_do_atan2
    63 #  define _STLP_DO_COS(_Tp)   _STL_math_proxy<_Tp>::_do_cos
    64 #  define _STLP_DO_COSH(_Tp)  _STL_math_proxy<_Tp>::_do_cosh
    65 #  define _STLP_DO_FLOOR(_Tp) _STL_math_proxy<_Tp>::_do_floor
    66 #  define _STLP_DO_CEIL(_Tp) _STL_math_proxy<_Tp>::_do_ceil
    67 #  define _STLP_DO_FMOD(_Tp) _STL_math_proxy<_Tp>::_do_fmod
    68 #  define _STLP_DO_FREXP(_Tp) _STL_math_proxy<_Tp>::_do_frexp
    69 #  define _STLP_DO_LDEXP(_Tp) _STL_math_proxy<_Tp>::_do_ldexp
    70 #  define _STLP_DO_MODF(_Tp) _STL_math_proxy<_Tp>::_do_modf
    71 #  define _STLP_DO_LOG(_Tp)   _STL_math_proxy<_Tp>::_do_log
    72 #  define _STLP_DO_LOG10(_Tp) _STL_math_proxy<_Tp>::_do_log10
    73 #  define _STLP_DO_POW(_Tp)   _STL_math_proxy<_Tp>::_do_pow
    74 #  define _STLP_DO_SIN(_Tp)   _STL_math_proxy<_Tp>::_do_sin
    75 #  define _STLP_DO_SINH(_Tp)  _STL_math_proxy<_Tp>::_do_sinh
    76 #  define _STLP_DO_SQRT(_Tp)  _STL_math_proxy<_Tp>::_do_sqrt
    77 #  define _STLP_DO_TAN(_Tp)   _STL_math_proxy<_Tp>::_do_tan
    78 #  define _STLP_DO_TANH(_Tp)  _STL_math_proxy<_Tp>::_do_tanh
    79 #  define _STLP_DO_EXP(_Tp)   _STL_math_proxy<_Tp>::_do_exp
    80 #  define _STLP_DO_HYPOT(_Tp) _STL_math_proxy<_Tp>::_do_hypot
    81 # else
    82 #  define _STLP_DO_ABS(_Tp)   _STLP_VENDOR_CSTD::fabs
    83 #  define _STLP_DO_ACOS(_Tp)  _STLP_VENDOR_CSTD::acos
    84 #  define _STLP_DO_ASIN(_Tp)  _STLP_VENDOR_CSTD::asin
    85 #  define _STLP_DO_ATAN(_Tp)  _STLP_VENDOR_CSTD::atan
    86 #  define _STLP_DO_ATAN2(_Tp) _STLP_VENDOR_CSTD::atan2
    87 #  define _STLP_DO_COS(_Tp)   _STLP_VENDOR_CSTD::cos
    88 #  define _STLP_DO_COSH(_Tp)  _STLP_VENDOR_CSTD::cosh
    89 #  define _STLP_DO_FLOOR(_Tp)  _STLP_VENDOR_CSTD::floor
    90 #  define _STLP_DO_CEIL(_Tp)   _STLP_VENDOR_CSTD::ceil
    91 #  define _STLP_DO_FMOD(_Tp)   _STLP_VENDOR_CSTD::fmod
    92 #  define _STLP_DO_FREXP(_Tp) _STLP_VENDOR_CSTD::frexp
    93 #  define _STLP_DO_LDEXP(_Tp) _STLP_VENDOR_CSTD::ldexp
    94 #  define _STLP_DO_MODF(_Tp) _STLP_VENDOR_CSTD::modf
    95 #  define _STLP_DO_LOG(_Tp)   _STLP_VENDOR_CSTD::log
    96 #  define _STLP_DO_LOG10(_Tp) _STLP_VENDOR_CSTD::log10
    97 #  define _STLP_DO_POW(_Tp)   _STLP_VENDOR_CSTD::pow
    98 #  define _STLP_DO_SIN(_Tp)   _STLP_VENDOR_CSTD::sin
    99 #  define _STLP_DO_SINH(_Tp)  _STLP_VENDOR_CSTD::sinh
   100 #  define _STLP_DO_SQRT(_Tp)  _STLP_VENDOR_CSTD::sqrt
   101 #  define _STLP_DO_TAN(_Tp)   _STLP_VENDOR_CSTD::tan
   102 #  define _STLP_DO_TANH(_Tp)  _STLP_VENDOR_CSTD::tanh
   103 #  define _STLP_DO_EXP(_Tp)   _STLP_VENDOR_CSTD::exp
   104 #  define _STLP_DO_HYPOT(_Tp) ::hypot
   105 # endif
   106 
   107 _STLP_END_NAMESPACE
   108 
   109 # if (defined (_STLP_HAS_NO_NEW_C_HEADERS) || defined(_STLP_MSVC) || defined (__ICL)) && !defined (_STLP_HAS_NO_NAMESPACES)
   110 
   111 #if (! defined (_STLP_USE_NEW_C_HEADERS)) && ! defined (_STLP_VXWORKS_TORNADO)
   112 _STLP_BEGIN_NAMESPACE
   113 
   114 #  ifndef _STLP_HAS_NATIVE_FLOAT_ABS
   115 inline double abs(double __x)                 { return _STLP_DO_ABS(double)(__x); }
   116 inline float abs (float __x)                  { return _STLP_DO_ABS(float)(__x); }
   117 #  endif
   118 
   119 #if  ( defined (__SYMBIAN32__) || defined (__WINS__))
   120 inline double pow(double __x, int __y)        { return _STLP_DO_POW(double)(__x, __y); }
   121 inline float acos (float __x)                 { return _STLP_DO_ACOS(float)(__x); }
   122 inline float asin (float __x)                 { return _STLP_DO_ASIN(float)(__x); }
   123 inline float atan (float __x)                 { return _STLP_DO_ATAN(float)(__x); }
   124 inline float atan2(float __x, float __y)      { return _STLP_DO_ATAN2(float)(__x, __y); }
   125 inline float ceil (float __x)                 { return _STLP_DO_CEIL(float)(__x); }
   126 inline float cos (float __x)                  { return _STLP_DO_COS(float)(__x); }
   127 inline float cosh (float __x)                 { return _STLP_DO_COSH(float)(__x); }
   128 inline float exp (float __x)                  { return _STLP_DO_EXP(float)(__x); }
   129 # ifdef _STLP_USE_NAMESPACES
   130 inline float fabs (float __x)                 { return _STLP_DO_ABS(float)(__x); }
   131 # endif
   132 inline float floor(float __x)                 { return _STLP_DO_FLOOR(float)(__x); }
   133 inline float fmod (float __x, float __y)      { return _STLP_DO_FMOD(float)(__x, __y); }
   134 inline float frexp(float __x, int* __y)       { return _STLP_DO_FREXP(float)(__x, __y); }
   135 inline float ldexp(float __x, int __y)        { return _STLP_DO_LDEXP(float)(__x, __y); }
   136 // fbp : float versions are not always available
   137 #if !defined(_STLP_VENDOR_LONG_DOUBLE_MATH)		//*ty 11/25/2001 - 
   138 inline float modf (float __x, float* __y)     { 
   139  #ifndef __SYMBIAN32__
   140   double __dd[2]; 
   141   double __res = _STLP_DO_MODF(double)((double)__x, __dd); 
   142   __y[0] = (float)__dd[0] ; __y[1] = (float)__dd[1]; 
   143   return (float)__res; 
   144 #else
   145   float f = modff(__x, __y);
   146   return f;
   147 #endif    
   148 }
   149 #else		//*ty 11/25/2001 - i.e. for apple SCpp
   150 inline float modf (float __x, float* __y)     { 
   151   long double __dd[2]; 
   152   long double __res = _STLP_DO_MODF(long double)((long double)__x, __dd); 
   153   __y[0] = (float)__dd[0] ; __y[1] = (float)__dd[1]; 
   154   return (float)__res; 
   155 }
   156 #endif		//*ty 11/25/2001 - 
   157 
   158 inline float log (float __x)                  { return _STLP_DO_LOG(float)(__x); }
   159 inline float log10(float __x)                 { return _STLP_DO_LOG10(float)(__x); }
   160 inline float pow (float __x, float __y)       { return _STLP_DO_POW(float)(__x, __y); }
   161 inline float pow (float __x, int __y)         { return _STLP_DO_POW(float)(__x, __y); }
   162 inline float sin (float __x)                  { return _STLP_DO_SIN(float)(__x); }
   163 inline float sinh (float __x)                 { return _STLP_DO_SINH(float)(__x); }
   164 inline float sqrt (float __x)                 { return _STLP_DO_SQRT(float)(__x); }
   165 inline float tan (float __x)                  { return _STLP_DO_TAN(float)(__x); }
   166 inline float tanh (float __x)                 { return _STLP_DO_TANH(float)(__x); }
   167 
   168 #  if ! (defined  (_STLP_NO_LONG_DOUBLE) || defined(_STLP_VENDOR_LONG_DOUBLE_MATH))
   169 
   170 #if !( defined (__MVS__) || defined (_STLP_HAS_NATIVE_FLOAT_ABS))
   171 inline long double abs (long double __x)                  { return _STLP_DO_ABS(long double)((double)__x); }
   172 #endif
   173 inline long double acos (long double __x)                 { return _STLP_DO_ACOS(long double)(__x); }
   174 inline long double asin (long double __x)                 { return _STLP_DO_ASIN(long double)(__x); }
   175 inline long double atan (long double __x)                 { return _STLP_DO_ATAN(long double)(__x); }
   176 inline long double atan2(long double __x, long double __y)      { return _STLP_DO_ATAN2(long double)(__x, __y); }
   177 inline long double ceil (long double __x)                 { return _STLP_DO_CEIL(long double)(__x); }
   178 inline long double cos (long double __x)                  { return _STLP_DO_COS(long double)(__x); }
   179 inline long double cosh (long double __x)                 { return _STLP_DO_COSH(long double)(__x); }
   180 inline long double exp (long double __x)                  { return _STLP_DO_EXP(long double)(__x); }
   181 inline long double fabs (long double __x)                 { return _STLP_DO_ABS(long double)(__x); }
   182 inline long double floor(long double __x)                 { return _STLP_DO_FLOOR(long double)(__x); }
   183 inline long double fmod (long double __x, long double __y)      { return _STLP_DO_FMOD(long double)(__x, __y); }
   184 inline long double frexp(long double __x, int* __y)       { return _STLP_DO_FREXP(long double)(__x, __y); }
   185 inline long double ldexp(long double __x, int __y)        { return _STLP_DO_LDEXP(long double)(__x, __y); }
   186 // fbp : long double versions are not available
   187 inline long double modf (long double __x, long double* __y)     { 
   188   double __dd[2]; 
   189   double __res = _STLP_DO_MODF(double)((double)__x, __dd); 
   190   __y[0] = (long double)__dd[0] ; __y[1] = (long double)__dd[1]; 
   191   return (long double)__res; 
   192 }
   193 inline long double log (long double __x)                  { return _STLP_DO_LOG(long double)(__x); }
   194 inline long double log10(long double __x)                 { return _STLP_DO_LOG10(long double)(__x); }
   195 inline long double pow (long double __x, long double __y)       { return _STLP_DO_POW(long double)(__x, __y); }
   196 inline long double pow (long double __x, int __y)         { return _STLP_DO_POW(long double)(__x, __y); }
   197 inline long double sin (long double __x)                  { return _STLP_DO_SIN(long double)(__x); }
   198 inline long double sinh (long double __x)                 { return _STLP_DO_SINH(long double)(__x); }
   199 inline long double sqrt (long double __x)                 { return _STLP_DO_SQRT(long double)(__x); }
   200 inline long double tan (long double __x)                  { return _STLP_DO_TAN(long double)(__x); }
   201 inline long double tanh (long double __x)                 { return _STLP_DO_TANH(long double)(__x); }
   202 #endif
   203 #endif
   204 
   205 _STLP_END_NAMESPACE
   206 
   207 # endif /* NEW_C_HEADERS */
   208 # endif /* NEW_C_HEADERS */
   209 
   210 #endif /* CMATH_H */