00001
00002 #ifndef GAUDIKERNEL_CBRT_H
00003 #define GAUDIKERNEL_CBRT_H
00004
00005
00006
00007
00008
00009 #include <cmath>
00010
00020
00021 #ifndef __GNUC__
00022 inline double cbrt( double __x ){
00023 return ::pow( __x, static_cast<double>(1.0/3.0) );
00024 }
00025 #endif
00026
00027
00028 inline float cbrt( float __x ) {
00029 #ifdef __GNUC__
00030 return ::cbrtf( __x );
00031 #else
00032 return ::pow( __x, static_cast<float>(1.0/3.0) );
00033 #endif
00034 }
00035
00036
00037 inline long double cbrt( long double __x ) {
00038 #ifdef __GNUC__
00039 return ::cbrtl( __x );
00040 #else
00041 return ::pow( __x, static_cast<long double>(1.0/3.0) );
00042 #endif
00043 }
00044
00045
00046 #define cbrt_for_int_type(t) \
00047 inline double cbrt( t __x ) { return cbrt ( static_cast<double>(__x) ); }
00048
00049 cbrt_for_int_type(int)
00050 cbrt_for_int_type(long)
00051 cbrt_for_int_type(long long)
00052 cbrt_for_int_type(unsigned int)
00053 cbrt_for_int_type(unsigned long)
00054 cbrt_for_int_type(unsigned long long)
00055
00056 #undef cbrt_for_int_type
00057
00058 #endif
00059