00001 #ifndef _CTBtraits_HXX
00002 #define _CTBtraits_HXX 1
00003
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <limits.h>
00019 #include <float.h>
00020
00021 #ifndef _CTBcomplex_HXX
00022 template <class T> class CTBcomplex;
00023 #endif
00024
00025 template <class T>
00026 class CTBtraits {
00027 public:
00028 typedef T Sum_t;
00029 typedef T Sumq_t;
00030 typedef T Mag_t;
00031 static const bool IsIntegral = false;
00032 static const bool IsFloating = false;
00033 static const bool IsComplex = false;
00034 };
00035
00036 class CTBtraits<char> {
00037 public:
00038 typedef char T;
00039 typedef long Sum_t;
00040 typedef long Sumq_t;
00041 typedef T Mag_t;
00042 static const bool IsIntegral = true;
00043 static const bool IsFloating = false;
00044 static const bool IsComplex = false;
00045 static const int NBit = CHAR_BIT;
00046 static inline T Min() { return CHAR_MIN; }
00047 static inline T Max() { return CHAR_MAX; }
00048 };
00049
00050 class CTBtraits<signed char> {
00051 public:
00052 typedef signed char T;
00053 typedef long Sum_t;
00054 typedef long Sumq_t;
00055 typedef T Mag_t;
00056 static const bool IsIntegral = true;
00057 static const bool IsFloating = false;
00058 static const bool IsComplex = false;
00059 static const int NBit = CHAR_BIT;
00060 static inline T Min() { return SCHAR_MIN; }
00061 static inline T Max() { return SCHAR_MAX; }
00062 };
00063
00064 class CTBtraits<unsigned char> {
00065 public:
00066 typedef unsigned char T;
00067 typedef long Sum_t;
00068 typedef long Sumq_t;
00069 typedef T Mag_t;
00070 static const bool IsIntegral = true;
00071 static const bool IsFloating = false;
00072 static const bool IsComplex = false;
00073 static const int NBit = CHAR_BIT;
00074 static inline T Min() { return 0; }
00075 static inline T Max() { return UCHAR_MAX; }
00076 };
00077
00078 class CTBtraits<short> {
00079 public:
00080 typedef short T;
00081 typedef long Sum_t;
00082 typedef long Sumq_t;
00083 typedef T Mag_t;
00084 static const bool IsIntegral = true;
00085 static const bool IsFloating = false;
00086 static const bool IsComplex = false;
00087 static const int NBit = CHAR_BIT * sizeof (T);
00088 static inline T Min() { return SHRT_MIN; }
00089 static inline T Max() { return SHRT_MAX; }
00090 };
00091
00092 class CTBtraits<unsigned short> {
00093 public:
00094 typedef unsigned short T;
00095 typedef long Sum_t;
00096 typedef long Sumq_t;
00097 typedef T Mag_t;
00098 static const bool IsIntegral = true;
00099 static const bool IsFloating = false;
00100 static const bool IsComplex = false;
00101 static const int NBit = CHAR_BIT * sizeof (T);
00102 static inline T Min() { return 0; }
00103 static inline T Max() { return USHRT_MAX; }
00104 };
00105
00106 class CTBtraits<int> {
00107 public:
00108 typedef int T;
00109 typedef long Sum_t;
00110 typedef long Sumq_t;
00111 typedef T Mag_t;
00112 static const bool IsIntegral = true;
00113 static const bool IsFloating = false;
00114 static const bool IsComplex = false;
00115 static const int NBit = CHAR_BIT * sizeof (T);
00116 static inline T Min() { return INT_MIN; }
00117 static inline T Max() { return INT_MAX; }
00118 };
00119
00120 class CTBtraits<unsigned int> {
00121 public:
00122 typedef unsigned int T;
00123 typedef unsigned long Sum_t;
00124 typedef unsigned long Sumq_t;
00125 typedef T Mag_t;
00126 static const bool IsIntegral = true;
00127 static const bool IsFloating = false;
00128 static const bool IsComplex = false;
00129 static const int NBit = CHAR_BIT * sizeof (T);
00130 static inline T Min() { return 0; }
00131 static inline T Max() { return UINT_MAX; }
00132 };
00133
00134 class CTBtraits<long> {
00135 public:
00136 typedef long T;
00137 typedef long Sum_t;
00138 typedef long Sumq_t;
00139 typedef T Mag_t;
00140 static const bool IsIntegral = true;
00141 static const bool IsFloating = false;
00142 static const bool IsComplex = false;
00143 static const int NBit = CHAR_BIT * sizeof (T);
00144 static inline T Min() { return LONG_MIN; }
00145 static inline T Max() { return LONG_MAX; }
00146 };
00147
00148 class CTBtraits<unsigned long> {
00149 public:
00150 typedef unsigned long T;
00151 typedef unsigned long Sum_t;
00152 typedef unsigned long Sumq_t;
00153 typedef T Mag_t;
00154 static const bool IsIntegral = true;
00155 static const bool IsFloating = false;
00156 static const bool IsComplex = false;
00157 static const int NBit = CHAR_BIT * sizeof (T);
00158 static inline T Min() { return 0; }
00159 static inline T Max() { return ULONG_MAX; }
00160 };
00161
00162 class CTBtraits<float> {
00163 public:
00164 typedef float T;
00165 typedef double Sum_t;
00166 typedef double Sumq_t;
00167 typedef T Mag_t;
00168 static const bool IsIntegral = false;
00169 static const bool IsFloating = true;
00170 static const bool IsComplex = false;
00171 static const int NBit = CHAR_BIT * sizeof (T);
00172 static inline T Min() { return FLT_MIN; }
00173 static inline T Max() { return FLT_MAX; }
00174 static inline T Epsilon() { return FLT_EPSILON; }
00175 static inline T Tiny() { return 1.08E-19F; }
00176 };
00177
00178 class CTBtraits<double> {
00179 public:
00180 typedef double T;
00181 typedef double Sum_t;
00182 #ifndef CTB__noLongDouble
00183 typedef long double Sumq_t;
00184 #else
00185 typedef double Sumq_t;
00186 #endif
00187 typedef T Mag_t;
00188 static const bool IsIntegral = false;
00189 static const bool IsFloating = true;
00190 static const bool IsComplex = false;
00191 static const int NBit = CHAR_BIT * sizeof (T);
00192 static inline T Min() { return DBL_MIN; }
00193 static inline T Max() { return DBL_MAX; }
00194 static inline T Epsilon() { return DBL_EPSILON; }
00195 static inline T Tiny() { return 1.33E-154; }
00196 };
00197
00198 #ifndef CTB__noLongDouble
00199 class CTBtraits<long double> {
00200 public:
00201 typedef long double T;
00202 typedef long double Sum_t;
00203 typedef long double Sumq_t;
00204 typedef T Mag_t;
00205 static const bool IsIntegral = false;
00206 static const bool IsFloating = true;
00207 static const bool IsComplex = false;
00208 static const int NBit = CHAR_BIT * sizeof (T);
00209 static inline T Min() { return LDBL_MIN; }
00210 static inline T Max() { return LDBL_MAX; }
00211 static inline T Epsilon() { return LDBL_EPSILON; }
00212 static inline T Tiny() { return 1.E-2000L; }
00213 };
00214 #endif
00215
00216 template <class T>
00217 class CTBtraits<CTBcomplex<T> > {
00218 public:
00219 typedef CTBcomplex<T> Sum_t;
00220 typedef CTBcomplex<T> Sumq_t;
00221 typedef T Mag_t;
00222 static const bool IsIntegral = false;
00223 static const bool IsFloating = true;
00224 static const bool IsComplex = true;
00225 static const int NBit = CHAR_BIT * sizeof (T);
00226 static inline T Min() { return CTBtraits<T>::Min(); }
00227 static inline T Max() { return CTBtraits<T>::Max(); }
00228 static inline T Epsilon() { return CTBtraits<T>::Epsilon(); }
00229 static inline T Tiny() { return CTBtraits<T>::Tiny(); }
00230 };
00231
00232 #endif