_cmath.h

00001 /*
00002  * Copyright (c) 1999 
00003  * Boris Fomitchev
00004  *
00005  * This material is provided "as is", with absolutely no warranty expressed
00006  * or implied. Any use is at your own risk.
00007  *
00008  * Permission to use or copy this software for any purpose is hereby granted 
00009  * without fee, provided the above notices are retained on all copies.
00010  * Permission to modify the code and to distribute modified code is granted,
00011  * provided the above notices are retained, and a notice that the code was
00012  * modified is included with the above copyright notice.
00013  *
00014  */
00015 
00016 #ifndef _STLP_CMATH_H_HEADER
00017 # define _STLP_CMATH_H_HEADER
00018 
00019 
00020 
00021 _STLP_BEGIN_NAMESPACE
00022 
00023 # ifdef _STLP_SAME_FUNCTION_NAME_RESOLUTION_BUG
00024 
00025 // this proxy is needed for some compilers to resolve problems
00026 // calling sqrt() from within sqrt(), etc.
00027 template <class _Tp>
00028 struct _STL_math_proxy {
00029   static inline _Tp _do_abs(const _Tp& __x)     { return _STLP_VENDOR_CSTD::fabs(__x); } 
00030   static inline _Tp _do_acos(const _Tp& __x)    { return _STLP_VENDOR_CSTD::acos(__x); } 
00031   static inline _Tp _do_asin(const _Tp& __x)    { return _STLP_VENDOR_CSTD::asin(__x); } 
00032   static inline _Tp _do_atan(const _Tp& __x)    { return _STLP_VENDOR_CSTD::atan(__x); } 
00033   static inline _Tp _do_atan2(const _Tp& __x, const _Tp& __y)  { return _STLP_VENDOR_CSTD::atan2(__x, __y); } 
00034   static inline _Tp _do_cos(const _Tp& __x)     { return _STLP_VENDOR_CSTD::cos(__x); } 
00035   static inline _Tp _do_cosh(const _Tp& __x)    { return _STLP_VENDOR_CSTD::cosh(__x); } 
00036   static inline _Tp _do_floor(const _Tp& __x)    { return _STLP_VENDOR_CSTD::floor(__x); } 
00037   static inline _Tp _do_ceil(const _Tp& __x)    { return _STLP_VENDOR_CSTD::ceil(__x); } 
00038   static inline _Tp _do_fmod(const _Tp& __x, const _Tp& __y)    { return _STLP_VENDOR_CSTD::fmod(__x, __y); } 
00039   static inline _Tp _do_frexp(const _Tp& __x, int* __y)    { return _STLP_VENDOR_CSTD::frexp(__x, __y); } 
00040   static inline _Tp _do_ldexp(const _Tp& __x, int __y)    { return _STLP_VENDOR_CSTD::ldexp(__x, __y); } 
00041   static inline _Tp _do_modf(const _Tp& __x, double* __y) { return _STLP_VENDOR_CSTD::modf(__x, __y); }
00042   static inline _Tp _do_log(const _Tp& __x)     { return _STLP_VENDOR_CSTD::log(__x); } 
00043   static inline _Tp _do_log10(const _Tp& __x)   { return _STLP_VENDOR_CSTD::log10(__x); } 
00044   static inline _Tp _do_pow(const _Tp& __x, const _Tp& __y)    { return _STLP_VENDOR_CSTD::pow(__x, __y); } 
00045   static inline _Tp _do_pow(const _Tp& __x, int __y)    { return _STLP_VENDOR_CSTD::pow(__x, __y); } 
00046   static inline _Tp _do_sin(const _Tp& __x)     { return _STLP_VENDOR_CSTD::sin(__x); } 
00047   static inline _Tp _do_sinh(const _Tp& __x)    { return _STLP_VENDOR_CSTD::sinh(__x); } 
00048 
00049   static inline _Tp _do_sqrt(const _Tp& __x)    { return _STLP_VENDOR_CSTD::sqrt(__x); } 
00050   static inline _Tp _do_tan(const _Tp& __x)     { return _STLP_VENDOR_CSTD::tan(__x); } 
00051   static inline _Tp _do_tanh(const _Tp& __x)    { return _STLP_VENDOR_CSTD::tanh(__x); } 
00052   static inline _Tp _do_exp(const _Tp& __x)     { return _STLP_VENDOR_CSTD::exp(__x); } 
00053   static inline _Tp _do_hypot(const _Tp& __x, const _Tp& __y)   { return _STLP_VENDOR_CSTD::hypot(__x, __y); } 
00054 };
00055 
00056 #  define _STLP_DO_ABS(_Tp)   _STL_math_proxy<_Tp>::_do_abs
00057 #  define _STLP_DO_ACOS(_Tp)  _STL_math_proxy<_Tp>::_do_acos
00058 #  define _STLP_DO_ASIN(_Tp)  _STL_math_proxy<_Tp>::_do_asin
00059 #  define _STLP_DO_ATAN(_Tp)  _STL_math_proxy<_Tp>::_do_atan
00060 #  define _STLP_DO_ATAN2(_Tp) _STL_math_proxy<_Tp>::_do_atan2
00061 #  define _STLP_DO_COS(_Tp)   _STL_math_proxy<_Tp>::_do_cos
00062 #  define _STLP_DO_COSH(_Tp)  _STL_math_proxy<_Tp>::_do_cosh
00063 #  define _STLP_DO_FLOOR(_Tp) _STL_math_proxy<_Tp>::_do_floor
00064 #  define _STLP_DO_CEIL(_Tp) _STL_math_proxy<_Tp>::_do_ceil
00065 #  define _STLP_DO_FMOD(_Tp) _STL_math_proxy<_Tp>::_do_fmod
00066 #  define _STLP_DO_FREXP(_Tp) _STL_math_proxy<_Tp>::_do_frexp
00067 #  define _STLP_DO_LDEXP(_Tp) _STL_math_proxy<_Tp>::_do_ldexp
00068 #  define _STLP_DO_MODF(_Tp) _STL_math_proxy<_Tp>::_do_modf
00069 #  define _STLP_DO_LOG(_Tp)   _STL_math_proxy<_Tp>::_do_log
00070 #  define _STLP_DO_LOG10(_Tp) _STL_math_proxy<_Tp>::_do_log10
00071 #  define _STLP_DO_POW(_Tp)   _STL_math_proxy<_Tp>::_do_pow
00072 #  define _STLP_DO_SIN(_Tp)   _STL_math_proxy<_Tp>::_do_sin
00073 #  define _STLP_DO_SINH(_Tp)  _STL_math_proxy<_Tp>::_do_sinh
00074 #  define _STLP_DO_SQRT(_Tp)  _STL_math_proxy<_Tp>::_do_sqrt
00075 #  define _STLP_DO_TAN(_Tp)   _STL_math_proxy<_Tp>::_do_tan
00076 #  define _STLP_DO_TANH(_Tp)  _STL_math_proxy<_Tp>::_do_tanh
00077 #  define _STLP_DO_EXP(_Tp)   _STL_math_proxy<_Tp>::_do_exp
00078 #  define _STLP_DO_HYPOT(_Tp) _STL_math_proxy<_Tp>::_do_hypot
00079 # else
00080 
00081 #  define _STLP_DO_ABS(_Tp)   _STLP_VENDOR_CSTD::fabs
00082 #  define _STLP_DO_ACOS(_Tp)  _STLP_VENDOR_CSTD::acos
00083 #  define _STLP_DO_ASIN(_Tp)  _STLP_VENDOR_CSTD::asin
00084 #  define _STLP_DO_ATAN(_Tp)  _STLP_VENDOR_CSTD::atan
00085 #  define _STLP_DO_ATAN2(_Tp) _STLP_VENDOR_CSTD::atan2
00086 #  define _STLP_DO_COS(_Tp)   _STLP_VENDOR_CSTD::cos
00087 #  define _STLP_DO_COSH(_Tp)  _STLP_VENDOR_CSTD::cosh
00088 #  define _STLP_DO_FLOOR(_Tp)  _STLP_VENDOR_CSTD::floor
00089 #  define _STLP_DO_CEIL(_Tp)   _STLP_VENDOR_CSTD::ceil
00090 #  define _STLP_DO_FMOD(_Tp)   _STLP_VENDOR_CSTD::fmod
00091 #  define _STLP_DO_FREXP(_Tp) _STLP_VENDOR_CSTD::frexp
00092 #  define _STLP_DO_LDEXP(_Tp) _STLP_VENDOR_CSTD::ldexp
00093 #  define _STLP_DO_MODF(_Tp) _STLP_VENDOR_CSTD::modf
00094 #  define _STLP_DO_LOG(_Tp)   _STLP_VENDOR_CSTD::log
00095 #  define _STLP_DO_LOG10(_Tp) _STLP_VENDOR_CSTD::log10
00096 #  define _STLP_DO_POW(_Tp)   _STLP_VENDOR_CSTD::pow
00097 #  define _STLP_DO_SIN(_Tp)   _STLP_VENDOR_CSTD::sin
00098 #  define _STLP_DO_SINH(_Tp)  _STLP_VENDOR_CSTD::sinh
00099 #  define _STLP_DO_SQRT(_Tp)  _STLP_VENDOR_CSTD::sqrt
00100 #  define _STLP_DO_TAN(_Tp)   _STLP_VENDOR_CSTD::tan
00101 #  define _STLP_DO_TANH(_Tp)  _STLP_VENDOR_CSTD::tanh
00102 #  define _STLP_DO_EXP(_Tp)   _STLP_VENDOR_CSTD::exp
00103 # if (defined (__GNUC__) && !defined (__SYMBIAN32__)) || defined ( __IBMCPP__ ) || defined (__SUNPRO_CC)
00104 #  define _STLP_DO_HYPOT(_Tp) ::hypot
00105 # else
00106 #  define _STLP_DO_HYPOT(_Tp) _STLP_VENDOR_CSTD::hypot
00107 # endif
00108 
00109 # endif
00110 
00111 _STLP_END_NAMESPACE
00112 
00113 # if defined (_STLP_HAS_NO_NEW_C_HEADERS) || defined(_STLP_MSVC) || defined (__ICL)
00114 
00115 #if ! defined (_STLP_USE_NEW_C_HEADERS) 
00116 
00117 _STLP_BEGIN_NAMESPACE
00118 
00119 #  ifndef _STLP_HAS_NATIVE_FLOAT_ABS
00120 inline double abs(double __x)                 { return _STLP_DO_ABS(double)(__x); }
00121 inline float abs (float __x)                  { return _STLP_DO_ABS(float)(__x); }
00122 #  endif
00123 
00124 inline double pow(double __x, int __y)        { return _STLP_DO_POW(double)(__x, __y); }
00125 inline float acos (float __x)                 { return _STLP_DO_ACOS(float)(__x); }
00126 inline float asin (float __x)                 { return _STLP_DO_ASIN(float)(__x); }
00127 inline float atan (float __x)                 { return _STLP_DO_ATAN(float)(__x); }
00128 inline float atan2(float __x, float __y)      { return _STLP_DO_ATAN2(float)(__x, __y); }
00129 inline float ceil (float __x)                 { return _STLP_DO_CEIL(float)(__x); }
00130 inline float cos (float __x)                  { return _STLP_DO_COS(float)(__x); }
00131 inline float cosh (float __x)                 { return _STLP_DO_COSH(float)(__x); }
00132 inline float exp (float __x)                  { return _STLP_DO_EXP(float)(__x); }
00133 # ifdef _STLP_USE_NAMESPACES
00134 inline float fabs (float __x)                 { return _STLP_DO_ABS(float)(__x); }
00135 # endif
00136 inline float floor(float __x)                 { return _STLP_DO_FLOOR(float)(__x); }
00137 inline float fmod (float __x, float __y)      { return _STLP_DO_FMOD(float)(__x, __y); }
00138 inline float frexp(float __x, int* __y)       { return _STLP_DO_FREXP(float)(__x, __y); }
00139 inline float ldexp(float __x, int __y)        { return _STLP_DO_LDEXP(float)(__x, __y); }
00140 // fbp : float versions are not always available
00141 inline float modf (float __x, float* __y)     { 
00142   double __dd[2]; 
00143   double __res = _STLP_DO_MODF(double)((double)__x, __dd); 
00144   __y[0] = (float)__dd[0] ; __y[1] = (float)__dd[1]; 
00145   return (float)__res; 
00146 }
00147 
00148 inline float log (float __x)                  { return _STLP_DO_LOG(float)(__x); }
00149 inline float log10(float __x)                 { return _STLP_DO_LOG10(float)(__x); }
00150 inline float pow (float __x, float __y)       { return _STLP_DO_POW(float)(__x, __y); }
00151 inline float pow (float __x, int __y)         { return _STLP_DO_POW(float)(__x, __y); }
00152 inline float sin (float __x)                  { return _STLP_DO_SIN(float)(__x); }
00153 inline float sinh (float __x)                 { return _STLP_DO_SINH(float)(__x); }
00154 inline float sqrt (float __x)                 { return _STLP_DO_SQRT(float)(__x); }
00155 inline float tan (float __x)                  { return _STLP_DO_TAN(float)(__x); }
00156 inline float tanh (float __x)                 { return _STLP_DO_TANH(float)(__x); }
00157 
00158 #  if ! (defined  (_STLP_NO_LONG_DOUBLE) || defined(_STLP_VENDOR_LONG_DOUBLE_MATH))
00159 
00160 #if !defined (__MVS__)
00161 inline long double abs (long double __x)                  { return _STLP_DO_ABS(long double)((double)__x); }
00162 #endif
00163 inline long double acos (long double __x)                 { return _STLP_DO_ACOS(long double)(__x); }
00164 inline long double asin (long double __x)                 { return _STLP_DO_ASIN(long double)(__x); }
00165 inline long double atan (long double __x)                 { return _STLP_DO_ATAN(long double)(__x); }
00166 inline long double atan2(long double __x, long double __y)      { return _STLP_DO_ATAN2(long double)(__x, __y); }
00167 inline long double ceil (long double __x)                 { return _STLP_DO_CEIL(long double)(__x); }
00168 inline long double cos (long double __x)                  { return _STLP_DO_COS(long double)(__x); }
00169 inline long double cosh (long double __x)                 { return _STLP_DO_COSH(long double)(__x); }
00170 inline long double exp (long double __x)                  { return _STLP_DO_EXP(long double)(__x); }
00171 inline long double fabs (long double __x)                 { return _STLP_DO_ABS(long double)(__x); }
00172 inline long double floor(long double __x)                 { return _STLP_DO_FLOOR(long double)(__x); }
00173 inline long double fmod (long double __x, long double __y)      { return _STLP_DO_FMOD(long double)(__x, __y); }
00174 inline long double frexp(long double __x, int* __y)       { return _STLP_DO_FREXP(long double)(__x, __y); }
00175 inline long double ldexp(long double __x, int __y)        { return _STLP_DO_LDEXP(long double)(__x, __y); }
00176 // fbp : long double versions are not available
00177 inline long double modf (long double __x, long double* __y)     { 
00178   double __dd[2]; 
00179   double __res = _STLP_DO_MODF(double)((double)__x, __dd); 
00180   __y[0] = (long double)__dd[0] ; __y[1] = (long double)__dd[1]; 
00181   return (long double)__res; 
00182 }
00183 inline long double log (long double __x)                  { return _STLP_DO_LOG(long double)(__x); }
00184 inline long double log10(long double __x)                 { return _STLP_DO_LOG10(long double)(__x); }
00185 inline long double pow (long double __x, long double __y)       { return _STLP_DO_POW(long double)(__x, __y); }
00186 inline long double pow (long double __x, int __y)         { return _STLP_DO_POW(long double)(__x, __y); }
00187 inline long double sin (long double __x)                  { return _STLP_DO_SIN(long double)(__x); }
00188 inline long double sinh (long double __x)                 { return _STLP_DO_SINH(long double)(__x); }
00189 inline long double sqrt (long double __x)                 { return _STLP_DO_SQRT(long double)(__x); }
00190 inline long double tan (long double __x)                  { return _STLP_DO_TAN(long double)(__x); }
00191 inline long double tanh (long double __x)                 { return _STLP_DO_TANH(long double)(__x); }
00192 #  endif
00193 
00194 _STLP_END_NAMESPACE
00195 
00196 # endif /* NEW_C_HEADERS */
00197 # endif /* NEW_C_HEADERS */
00198 
00199 #endif /* CMATH_H */

Generated on Mon Jun 5 10:20:45 2006 for Intelligence.kdevelop by  doxygen 1.4.6