num_traits.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #include "num_common.h"
00046
00047 #include "num_traits.h"
00048 #include "interval.h"
00049 #include <climits>
00050 #include <cfloat>
00051
00052 #ifdef LASS_CHAR_IS_SIGNED
00053 # pragma LASS_NOTE("char is configured as signed char")
00054 #endif
00055
00056
00057 #define LASS_NUM_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067
00058 #define LASS_NUM_E 2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427
00059 #define LASS_NUM_SQRT_2 1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641572
00060 #define LASS_NUM_SQRT_PI 1.772453850905516027298167483341145
00061
00062 namespace lass
00063 {
00064 namespace num
00065 {
00066
00067
00068
00069
00070
00071
00072
00073
00074 template <> struct LASS_DLL NumTraits<float>;
00075 const size_t NumTraits<float>::memorySize = sizeof(float);
00076 const size_t NumTraits<float>::mantisseSize = std::numeric_limits<float>::digits;
00077 const float NumTraits<float>::one = 1.f;
00078 const float NumTraits<float>::zero = 0.f;
00079 const float NumTraits<float>::qNaN = std::numeric_limits<float>::quiet_NaN();
00080 const float NumTraits<float>::sNaN = std::numeric_limits<float>::signaling_NaN();
00081 const float NumTraits<float>::infinity = std::numeric_limits<float>::infinity();
00082 const float NumTraits<float>::epsilon = FLT_EPSILON;
00083 const float NumTraits<float>::min = -FLT_MAX;
00084 const float NumTraits<float>::max = FLT_MAX;
00085 const float NumTraits<float>::minStrictPositive = FLT_MIN;
00086 const float NumTraits<float>::pi = float(LASS_NUM_PI);
00087 const float NumTraits<float>::e = float(LASS_NUM_E);
00088 const float NumTraits<float>::sqrt2 = float(LASS_NUM_SQRT_2);
00089 const float NumTraits<float>::sqrtPi = float(LASS_NUM_SQRT_PI);
00090
00091
00092 template <> struct LASS_DLL NumTraits< std::complex<float> >;
00093 const size_t NumTraits<std::complex<float> >::memorySize = sizeof(std::complex<float>);
00094 const std::complex<float> NumTraits<std::complex<float> >::one = std::complex<float>(1.f, 0.f);
00095 const std::complex<float> NumTraits<std::complex<float> >::zero = std::complex<float>(0.f, 0.f);
00096 const std::complex<float> NumTraits<std::complex<float> >::pi = float(LASS_NUM_PI);
00097 const std::complex<float> NumTraits<std::complex<float> >::e = float(LASS_NUM_E);
00098 const std::complex<float> NumTraits<std::complex<float> >::sqrt2 = float(LASS_NUM_SQRT_2);
00099 const std::complex<float> NumTraits<std::complex<float> >::sqrtPi = float(LASS_NUM_SQRT_PI);
00100
00101
00102
00103
00104 template <> struct LASS_DLL NumTraits<double>;
00105 const size_t NumTraits<double>::memorySize = sizeof(double);
00106 const size_t NumTraits<double>::mantisseSize = std::numeric_limits<double>::digits;
00107 const double NumTraits<double>::one = 1.0;
00108 const double NumTraits<double>::zero= 0.0;
00109 const double NumTraits<double>::qNaN = std::numeric_limits<double>::quiet_NaN();
00110 const double NumTraits<double>::sNaN = std::numeric_limits<double>::signaling_NaN();
00111 const double NumTraits<double>::infinity = std::numeric_limits<double>::infinity();
00112 const double NumTraits<double>::epsilon = DBL_EPSILON;
00113 const double NumTraits<double>::min = -DBL_MAX;
00114 const double NumTraits<double>::max = DBL_MAX;
00115 const double NumTraits<double>::minStrictPositive = DBL_MIN;
00116 const double NumTraits<double>::pi = LASS_NUM_PI;
00117 const double NumTraits<double>::e = LASS_NUM_E;
00118 const double NumTraits<double>::sqrt2 = LASS_NUM_SQRT_2;
00119 const double NumTraits<double>::sqrtPi = LASS_NUM_SQRT_PI;
00120
00121
00122 template <> struct LASS_DLL NumTraits< std::complex<double> >;
00123 const size_t NumTraits<std::complex<double> >::memorySize = sizeof(std::complex<double>);
00124 const std::complex<double> NumTraits<std::complex<double> >::one = std::complex<double>(1.0, 0.0);
00125 const std::complex<double> NumTraits<std::complex<double> >::zero = std::complex<double>(0.0, 0.0);
00126 const std::complex<double> NumTraits<std::complex<double> >::pi = LASS_NUM_PI;
00127 const std::complex<double> NumTraits<std::complex<double> >::e = LASS_NUM_E;
00128 const std::complex<double> NumTraits<std::complex<double> >::sqrt2 = LASS_NUM_SQRT_2;
00129 const std::complex<double> NumTraits<std::complex<double> >::sqrtPi = LASS_NUM_SQRT_PI;
00130
00131
00132
00133
00134 template <> struct LASS_DLL NumTraits<long double>;
00135 const size_t NumTraits<long double>::memorySize = sizeof(long double);
00136 const size_t NumTraits<long double>::mantisseSize = std::numeric_limits<long double>::digits;
00137 const long double NumTraits<long double>::one = 1.0;
00138 const long double NumTraits<long double>::zero= 0.0;
00139 const long double NumTraits<long double>::qNaN = std::numeric_limits<long double>::quiet_NaN();
00140 const long double NumTraits<long double>::sNaN = std::numeric_limits<long double>::signaling_NaN();
00141 const long double NumTraits<long double>::infinity = std::numeric_limits<long double>::infinity();
00142 const long double NumTraits<long double>::epsilon = LDBL_EPSILON;
00143 const long double NumTraits<long double>::min = -LDBL_MAX;
00144 const long double NumTraits<long double>::max = LDBL_MAX;
00145 const long double NumTraits<long double>::minStrictPositive = LDBL_MIN;
00146 const long double NumTraits<long double>::pi = LASS_NUM_PI;
00147 const long double NumTraits<long double>::e = LASS_NUM_E;
00148 const long double NumTraits<long double>::sqrt2 = LASS_NUM_SQRT_2;
00149 const long double NumTraits<long double>::sqrtPi = LASS_NUM_SQRT_PI;
00150
00151
00152 template <> struct LASS_DLL NumTraits< std::complex<long double> >;
00153 const size_t NumTraits<std::complex<long double> >::memorySize = sizeof(std::complex<long double>);
00154 const std::complex<long double> NumTraits<std::complex<long double> >::one = std::complex<long double>(1.0, 0.0);
00155 const std::complex<long double> NumTraits<std::complex<long double> >::zero = std::complex<long double>(0.0, 0.0);
00156 const std::complex<long double> NumTraits<std::complex<long double> >::pi = LASS_NUM_PI;
00157 const std::complex<long double> NumTraits<std::complex<long double> >::e = LASS_NUM_E;
00158 const std::complex<long double> NumTraits<std::complex<long double> >::sqrt2 = LASS_NUM_SQRT_2;
00159 const std::complex<long double> NumTraits<std::complex<long double> >::sqrtPi = LASS_NUM_SQRT_PI;
00160
00161
00162
00163
00164
00165
00166 #define LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( t_type, v_min, v_max ) \
00167 template <> struct LASS_DLL NumTraits<t_type>;\
00168 const size_t NumTraits<t_type>::memorySize = sizeof(t_type);\
00169 const size_t NumTraits<t_type>::mantisseSize = 0;\
00170 const t_type NumTraits<t_type>::one = 1;\
00171 const t_type NumTraits<t_type>::zero= 0;\
00172 const t_type NumTraits<t_type>::epsilon = 1;\
00173 const t_type NumTraits<t_type>::min = v_min;\
00174 const t_type NumTraits<t_type>::max = v_max;\
00175 const t_type NumTraits<t_type>::minStrictPositive = 1;\
00176
00177 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( char, CHAR_MIN , CHAR_MAX )
00178 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( unsigned char, 0 , UCHAR_MAX)
00179 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( signed char, SCHAR_MIN , SCHAR_MAX )
00180 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( unsigned short, 0 , USHRT_MAX)
00181 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( signed short, SHRT_MIN , SHRT_MAX )
00182 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( unsigned int, 0 , UINT_MAX )
00183 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( signed int, INT_MIN , INT_MAX )
00184 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( unsigned long, 0 , ULONG_MAX )
00185 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( signed long, LONG_MIN , LONG_MAX )
00186 #if LASS_PLATFORM_TYPE == LASS_PLATFORM_TYPE_WIN32
00187 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( unsigned __int64, 0 , ULLONG_MAX )
00188 LASS_NUM_TRAITS_INTEGRAL_TEMPLATE_SPEC( signed __int64, LLONG_MIN, LLONG_MAX )
00189 #endif
00190
00191 }
00192 }