Go to the documentation of this file.00001
00002 #ifndef vnl_numeric_traits_h_
00003 #define vnl_numeric_traits_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <vxl_config.h>
00030 #include <vcl_complex.h>
00031
00032
00033
00034 #if !defined(VCL_VC)
00035 template <class T>
00036 class vnl_numeric_traits;
00037 #else
00038
00039
00040
00041
00042
00043 class vnl_numeric_traits_not_a_valid_type { };
00044 template <class T>
00045 class vnl_numeric_traits
00046 {
00047 public:
00048
00049 static const vnl_numeric_traits_not_a_valid_type zero;
00050
00051
00052 static const vnl_numeric_traits_not_a_valid_type one;
00053
00054
00055 static const vnl_numeric_traits_not_a_valid_type maxval;
00056
00057
00058 typedef vnl_numeric_traits_not_a_valid_type abs_t;
00059
00060
00061 typedef vnl_numeric_traits_not_a_valid_type double_t;
00062
00063
00064 typedef vnl_numeric_traits_not_a_valid_type real_t;
00065 };
00066 #endif
00067
00068 #ifndef NO_STD_BOOL
00069 VCL_DEFINE_SPECIALIZATION
00070 class vnl_numeric_traits<bool>
00071 {
00072 public:
00073
00074 static const bool zero VCL_STATIC_CONST_INIT_INT_DECL(false);
00075
00076 static const bool one VCL_STATIC_CONST_INIT_INT_DECL(true);
00077
00078 static const bool maxval VCL_STATIC_CONST_INIT_INT_DECL(true);
00079
00080 typedef unsigned int abs_t;
00081
00082 typedef unsigned int double_t;
00083
00084 typedef double real_t;
00085 };
00086
00087 #if !VCL_CANNOT_SPECIALIZE_CV
00088 VCL_DEFINE_SPECIALIZATION
00089 class vnl_numeric_traits<bool const> : public vnl_numeric_traits<bool> {};
00090 #endif
00091 #endif
00092
00093 VCL_DEFINE_SPECIALIZATION
00094 class vnl_numeric_traits<char>
00095 {
00096 public:
00097
00098 static const char zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00099
00100 static const char one VCL_STATIC_CONST_INIT_INT_DECL(1);
00101
00102
00103 #ifdef _MSC_VER
00104 #ifdef _CHAR_UNSIGNED
00105 static const char maxval VCL_STATIC_CONST_INIT_INT_DECL(255);
00106 #else
00107 static const char maxval VCL_STATIC_CONST_INIT_INT_DECL(127);
00108 #endif
00109 #else
00110 static const char maxval VCL_STATIC_CONST_INIT_INT_DECL(char(255)<0?127:255);
00111 #endif
00112
00113 typedef unsigned char abs_t;
00114
00115 typedef short double_t;
00116
00117 typedef double real_t;
00118 };
00119
00120 #if !VCL_CANNOT_SPECIALIZE_CV
00121 VCL_DEFINE_SPECIALIZATION
00122 class vnl_numeric_traits<char const> : public vnl_numeric_traits<char> {};
00123 #endif
00124
00125 VCL_DEFINE_SPECIALIZATION
00126 class vnl_numeric_traits<unsigned char>
00127 {
00128 public:
00129
00130 static const unsigned char zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00131
00132 static const unsigned char one VCL_STATIC_CONST_INIT_INT_DECL(1);
00133
00134 static const unsigned char maxval VCL_STATIC_CONST_INIT_INT_DECL(255);
00135
00136 typedef unsigned char abs_t;
00137
00138 typedef unsigned short double_t;
00139
00140 typedef double real_t;
00141 };
00142
00143 #if !VCL_CANNOT_SPECIALIZE_CV
00144 VCL_DEFINE_SPECIALIZATION
00145 class vnl_numeric_traits<unsigned char const> : public vnl_numeric_traits<unsigned char> {};
00146 #endif
00147
00148 VCL_DEFINE_SPECIALIZATION
00149 class vnl_numeric_traits<signed char>
00150 {
00151 public:
00152
00153 static const signed char zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00154
00155 static const signed char one VCL_STATIC_CONST_INIT_INT_DECL(1);
00156
00157 static const signed char maxval VCL_STATIC_CONST_INIT_INT_DECL(127);
00158
00159 typedef unsigned char abs_t;
00160
00161 typedef signed short double_t;
00162
00163 typedef double real_t;
00164 };
00165
00166 #if !VCL_CANNOT_SPECIALIZE_CV
00167 VCL_DEFINE_SPECIALIZATION
00168 class vnl_numeric_traits<signed char const> : public vnl_numeric_traits<signed char> {};
00169 #endif
00170
00171 VCL_DEFINE_SPECIALIZATION
00172 class vnl_numeric_traits<short>
00173 {
00174 public:
00175
00176 static const short zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00177
00178 static const short one VCL_STATIC_CONST_INIT_INT_DECL(1);
00179
00180 static const short maxval;
00181
00182 typedef unsigned short abs_t;
00183
00184 typedef int double_t;
00185
00186 typedef double real_t;
00187 };
00188
00189 #if !VCL_CANNOT_SPECIALIZE_CV
00190 VCL_DEFINE_SPECIALIZATION
00191 class vnl_numeric_traits<short const> : public vnl_numeric_traits<short> {};
00192 #endif
00193
00194 VCL_DEFINE_SPECIALIZATION
00195 class vnl_numeric_traits<unsigned short>
00196 {
00197 public:
00198
00199 static const unsigned short zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00200
00201 static const unsigned short one VCL_STATIC_CONST_INIT_INT_DECL(1);
00202
00203 static const unsigned short maxval;
00204
00205 typedef unsigned short abs_t;
00206
00207 typedef unsigned int double_t;
00208
00209 typedef double real_t;
00210 };
00211
00212 #if !VCL_CANNOT_SPECIALIZE_CV
00213 VCL_DEFINE_SPECIALIZATION
00214 class vnl_numeric_traits<unsigned short const> : public vnl_numeric_traits<unsigned short> {};
00215 #endif
00216
00217 VCL_DEFINE_SPECIALIZATION
00218 class vnl_numeric_traits<int>
00219 {
00220 public:
00221
00222 static const int zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00223
00224 static const int one VCL_STATIC_CONST_INIT_INT_DECL(1);
00225
00226 static const int maxval;
00227
00228 typedef unsigned int abs_t;
00229
00230 typedef long double_t;
00231
00232 typedef double real_t;
00233 };
00234
00235 #if !VCL_CANNOT_SPECIALIZE_CV
00236 VCL_DEFINE_SPECIALIZATION
00237 class vnl_numeric_traits<int const> : public vnl_numeric_traits<int> {};
00238 #endif
00239
00240 VCL_DEFINE_SPECIALIZATION
00241 class vnl_numeric_traits<unsigned int>
00242 {
00243 public:
00244
00245 static const unsigned int zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00246
00247 static const unsigned int one VCL_STATIC_CONST_INIT_INT_DECL(1);
00248
00249 static const unsigned int maxval;
00250
00251 typedef unsigned int abs_t;
00252
00253 typedef unsigned long double_t;
00254
00255 typedef double real_t;
00256 };
00257
00258 #if !VCL_CANNOT_SPECIALIZE_CV
00259 VCL_DEFINE_SPECIALIZATION
00260 class vnl_numeric_traits<unsigned int const> : public vnl_numeric_traits<unsigned int> {};
00261 #endif
00262
00263 VCL_DEFINE_SPECIALIZATION
00264 class vnl_numeric_traits<long>
00265 {
00266 public:
00267
00268 static const long zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00269
00270 static const long one VCL_STATIC_CONST_INIT_INT_DECL(1);
00271
00272 static const long maxval;
00273
00274 typedef unsigned long abs_t;
00275
00276 typedef vxl_sint_64 double_t;
00277
00278 typedef double real_t;
00279 };
00280
00281 #if !VCL_CANNOT_SPECIALIZE_CV
00282 VCL_DEFINE_SPECIALIZATION
00283 class vnl_numeric_traits<long const> : public vnl_numeric_traits<long > {};
00284 #endif
00285
00286 VCL_DEFINE_SPECIALIZATION
00287 class vnl_numeric_traits<unsigned long>
00288 {
00289 public:
00290
00291 static const unsigned long zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00292
00293 static const unsigned long one VCL_STATIC_CONST_INIT_INT_DECL(1);
00294
00295 static const unsigned long maxval;
00296
00297 typedef unsigned long abs_t;
00298
00299 typedef vxl_uint_64 double_t;
00300
00301 typedef double real_t;
00302 };
00303
00304 #if !VCL_CANNOT_SPECIALIZE_CV
00305 VCL_DEFINE_SPECIALIZATION
00306 class vnl_numeric_traits<unsigned long const> : public vnl_numeric_traits<unsigned long> {};
00307 #endif
00308
00309 #if defined(_WIN64) && !VCL_HAS_LONG_LONG
00310 VCL_DEFINE_SPECIALIZATION
00311 class vnl_numeric_traits<size_t>
00312 {
00313 public:
00314
00315 static const size_t zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00316
00317 static const size_t one VCL_STATIC_CONST_INIT_INT_DECL(1);
00318
00319 static const size_t maxval;
00320
00321 typedef size_t abs_t;
00322
00323 typedef size_t double_t;
00324
00325 typedef double real_t;
00326 };
00327
00328 #if !VCL_CANNOT_SPECIALIZE_CV
00329 VCL_DEFINE_SPECIALIZATION
00330 class vnl_numeric_traits<size_t const> : public vnl_numeric_traits<size_t> {};
00331 #endif
00332 #endif
00333
00334 #if VCL_HAS_LONG_LONG
00335 VCL_DEFINE_SPECIALIZATION
00336 class vnl_numeric_traits<long long>
00337 {
00338 public:
00339
00340 static const long long zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00341
00342 static const long long one VCL_STATIC_CONST_INIT_INT_DECL(1);
00343
00344 static const long long maxval;
00345
00346 typedef unsigned long long abs_t;
00347
00348 typedef long long double_t;
00349
00350 typedef double real_t;
00351 };
00352
00353 #if !VCL_CANNOT_SPECIALIZE_CV
00354 VCL_DEFINE_SPECIALIZATION
00355 class vnl_numeric_traits<long long const> : public vnl_numeric_traits<long long> {};
00356 #endif
00357
00358 VCL_DEFINE_SPECIALIZATION
00359 class vnl_numeric_traits<unsigned long long>
00360 {
00361 public:
00362
00363 static const unsigned long long zero VCL_STATIC_CONST_INIT_INT_DECL(0);
00364
00365 static const unsigned long long one VCL_STATIC_CONST_INIT_INT_DECL(1);
00366
00367 static const unsigned long long maxval;
00368
00369 typedef unsigned long long abs_t;
00370
00371 typedef unsigned long long double_t;
00372
00373 typedef double real_t;
00374 };
00375
00376 #if !VCL_CANNOT_SPECIALIZE_CV
00377 VCL_DEFINE_SPECIALIZATION
00378 class vnl_numeric_traits<unsigned long long const> : public vnl_numeric_traits<unsigned long long> {};
00379 #endif
00380 #endif
00381
00382 VCL_DEFINE_SPECIALIZATION
00383 class vnl_numeric_traits<float>
00384 {
00385 public:
00386
00387 static const float zero VCL_STATIC_CONST_INIT_FLOAT_DECL(0.0F);
00388
00389 static const float one VCL_STATIC_CONST_INIT_FLOAT_DECL(1.0F);
00390
00391 static const float maxval VCL_STATIC_CONST_INIT_FLOAT_DECL(3.40282346638528860e+38F);
00392
00393 typedef float abs_t;
00394
00395 typedef double double_t;
00396
00397 typedef double real_t;
00398 };
00399
00400 #if !VCL_CANNOT_SPECIALIZE_CV
00401 VCL_DEFINE_SPECIALIZATION
00402 class vnl_numeric_traits<float const> : public vnl_numeric_traits<float> {};
00403 #endif
00404
00405 VCL_DEFINE_SPECIALIZATION
00406 class vnl_numeric_traits<double>
00407 {
00408 public:
00409
00410 static const double zero VCL_STATIC_CONST_INIT_FLOAT_DECL(0.0);
00411
00412 static const double one VCL_STATIC_CONST_INIT_FLOAT_DECL(1.0);
00413
00414 static const double maxval VCL_STATIC_CONST_INIT_FLOAT_DECL(1.7976931348623157E+308);
00415
00416 typedef double abs_t;
00417
00418 typedef long double double_t;
00419
00420 typedef double real_t;
00421 };
00422
00423 #if !VCL_CANNOT_SPECIALIZE_CV
00424 VCL_DEFINE_SPECIALIZATION
00425 class vnl_numeric_traits<double const> : public vnl_numeric_traits<double> {};
00426 #endif
00427
00428 VCL_DEFINE_SPECIALIZATION
00429 class vnl_numeric_traits<long double>
00430 {
00431 public:
00432
00433 static const long double zero VCL_STATIC_CONST_INIT_FLOAT_DECL(0.0);
00434
00435 static const long double one VCL_STATIC_CONST_INIT_FLOAT_DECL(1.0);
00436
00437 static const long double maxval VCL_STATIC_CONST_INIT_FLOAT_DECL(1.7976931348623157E+308);
00438
00439 typedef long double abs_t;
00440
00441 typedef long double double_t;
00442
00443 typedef long double real_t;
00444 };
00445
00446 #if !VCL_CANNOT_SPECIALIZE_CV
00447 VCL_DEFINE_SPECIALIZATION
00448 class vnl_numeric_traits<long double const> : public vnl_numeric_traits<long double> {};
00449 #endif
00450
00451 VCL_DEFINE_SPECIALIZATION
00452 class vnl_numeric_traits< vcl_complex<float> >
00453 {
00454 public:
00455
00456 static const vcl_complex<float> zero;
00457
00458 static const vcl_complex<float> one;
00459
00460
00461
00462
00463 typedef float abs_t;
00464
00465 typedef vcl_complex<vnl_numeric_traits<float>::double_t> double_t;
00466
00467 typedef vcl_complex<float> real_t;
00468 };
00469
00470 #if !VCL_CANNOT_SPECIALIZE_CV
00471 VCL_DEFINE_SPECIALIZATION
00472 class vnl_numeric_traits<vcl_complex<float> const> : public vnl_numeric_traits<vcl_complex<float> > {};
00473 #endif
00474
00475 VCL_DEFINE_SPECIALIZATION
00476 class vnl_numeric_traits< vcl_complex<double> >
00477 {
00478 public:
00479
00480 static const vcl_complex<double> zero;
00481
00482 static const vcl_complex<double> one;
00483
00484
00485
00486
00487 typedef double abs_t;
00488
00489 typedef vcl_complex<vnl_numeric_traits<double>::double_t> double_t;
00490
00491 typedef vcl_complex<double> real_t;
00492 };
00493
00494 #if !VCL_CANNOT_SPECIALIZE_CV
00495 VCL_DEFINE_SPECIALIZATION
00496 class vnl_numeric_traits<vcl_complex<double> const> : public vnl_numeric_traits<vcl_complex<double> > {};
00497 #endif
00498
00499 VCL_DEFINE_SPECIALIZATION
00500 class vnl_numeric_traits< vcl_complex<long double> >
00501 {
00502 public:
00503
00504 static const vcl_complex<long double> zero;
00505
00506 static const vcl_complex<long double> one;
00507
00508
00509
00510
00511 typedef long double abs_t;
00512
00513 typedef vcl_complex<vnl_numeric_traits<long double>::double_t> double_t;
00514
00515 typedef vcl_complex<long double> real_t;
00516 };
00517
00518 #if !VCL_CANNOT_SPECIALIZE_CV
00519 VCL_DEFINE_SPECIALIZATION
00520 class vnl_numeric_traits<vcl_complex<long double> const> : public vnl_numeric_traits<vcl_complex<long double> > {};
00521 #endif
00522
00523 #endif // vnl_numeric_traits_h_