Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

vnl_numeric_traits.h

Go to the documentation of this file.
00001 #ifndef vnl_numeric_traits_h_
00002 #define vnl_numeric_traits_h_
00003 // This is vxl/vnl/vnl_numeric_traits.h
00004 
00005 //: \file
00006 //  \brief Templated zero/one/precision
00007 //  \author Andrew W. Fitzgibbon, Oxford RRG, 04 Sep 96
00008 //  To allow templated numerical algorithms to determine appropriate
00009 //    values for zero, one, maxval, and types for double precision,
00010 //    maximum product etc.
00011 
00012 //     Modifications:
00013 //     980212 AWF Initial version.
00014 //     AWF 010498 Moved to math
00015 //     LSB (Manchester) 23/3/01 Documentation tidied 
00016 //
00017 //-----------------------------------------------------------------------------
00018 
00019 #include <vcl_complex_fwd.h>
00020 
00021 // this is an empty class template.
00022 // only the specializations make sense.
00023 template <class T>
00024 class vnl_numeric_traits
00025 {
00026 public:
00027   static const T zero VCL_STATIC_CONST_INIT_FLOAT(0.0);
00028   static const T one VCL_STATIC_CONST_INIT_FLOAT(1.0);
00029   typedef T abs_t;
00030   typedef T double_t;
00031   typedef T real_t;
00032 };
00033 
00035 //  static const T zero;
00036 //
00038 //  static const T one;
00039 //
00041 //  typedef T abs_t;
00042 //
00044 //  typedef /* long */ double double_t;
00045 //
00047 //  typedef double real_t;
00048 
00049 #if 0 // if anyone uses these, he or she should be shot -- fsm.
00050 #if defined(i386)
00051 // 16 bit int
00052 typedef short long_char;
00053 typedef long int long_short;
00054 typedef long int long_int;
00055 typedef unsigned short long_uchar;
00056 typedef unsigned long int long_ushort;
00057 typedef unsigned long long long_uint;
00058 #else
00059 // 32 bit
00060 typedef short long_char;
00061 typedef int long_short;
00062 typedef long long_int;
00063 typedef unsigned short long_uchar;
00064 typedef unsigned int long_ushort;
00065 typedef unsigned long long_uint;
00066 #endif
00067 #endif
00068 
00069 #ifndef NO_STD_BOOL
00070 VCL_DEFINE_SPECIALIZATION
00071 class vnl_numeric_traits<bool> {
00072 public:
00073   static const bool zero VCL_STATIC_CONST_INIT_INT(0);
00074   static const bool one VCL_STATIC_CONST_INIT_INT(1);
00075   typedef unsigned int abs_t;
00076   typedef unsigned int double_t;
00077   typedef double real_t;
00078 };
00079 #endif
00080 
00081 VCL_DEFINE_SPECIALIZATION
00082 class vnl_numeric_traits<unsigned char> {
00083 public:
00084   static const unsigned char zero VCL_STATIC_CONST_INIT_INT(0);
00085   static const unsigned char one VCL_STATIC_CONST_INIT_INT(1);
00086   typedef unsigned char abs_t;
00087   typedef unsigned short double_t;
00088   typedef double real_t;
00089 };
00090 
00091 VCL_DEFINE_SPECIALIZATION
00092 class vnl_numeric_traits<signed char> {
00093 public:
00094   static const signed char zero VCL_STATIC_CONST_INIT_INT(0);
00095   static const signed char one VCL_STATIC_CONST_INIT_INT(1);
00096   typedef unsigned char abs_t;
00097   typedef signed short double_t;
00098   typedef double real_t;
00099 };
00100 
00101 VCL_DEFINE_SPECIALIZATION
00102 class vnl_numeric_traits<unsigned short> {
00103 public:
00104   static const unsigned short zero VCL_STATIC_CONST_INIT_INT(0);
00105   static const unsigned short one VCL_STATIC_CONST_INIT_INT(1);
00106   typedef unsigned short abs_t;
00107   typedef unsigned int double_t;
00108   typedef double real_t;
00109 };
00110 
00111 VCL_DEFINE_SPECIALIZATION
00112 class vnl_numeric_traits<short> {
00113 public:
00114   static const short zero VCL_STATIC_CONST_INIT_INT(0);
00115   static const short one VCL_STATIC_CONST_INIT_INT(1);
00116   typedef unsigned short abs_t;
00117   typedef signed int double_t;
00118   typedef double real_t;
00119 };
00120 
00121 VCL_DEFINE_SPECIALIZATION
00122 class vnl_numeric_traits<unsigned int> {
00123 public:
00124   static const unsigned int zero VCL_STATIC_CONST_INIT_INT(0);
00125   static const unsigned int one VCL_STATIC_CONST_INIT_INT(1);
00126   typedef unsigned int abs_t;
00127   typedef unsigned int double_t;
00128   typedef double real_t;
00129 };
00130 
00131 VCL_DEFINE_SPECIALIZATION
00132 class vnl_numeric_traits<int> {
00133 public:
00134   static const int zero VCL_STATIC_CONST_INIT_INT(0);
00135   static const int one VCL_STATIC_CONST_INIT_INT(1);
00136   typedef unsigned int abs_t;
00137   typedef signed int double_t;
00138   typedef double real_t;
00139 };
00140 
00141 VCL_DEFINE_SPECIALIZATION
00142 class vnl_numeric_traits<long> {
00143 public:
00144   static const long zero VCL_STATIC_CONST_INIT_INT(0);
00145   static const long one VCL_STATIC_CONST_INIT_INT(1);
00146   typedef unsigned long abs_t;
00147   typedef long double_t;
00148   typedef double real_t;
00149 };
00150 
00151 VCL_DEFINE_SPECIALIZATION
00152 class vnl_numeric_traits<unsigned long> {
00153 public:
00154   static const unsigned long zero VCL_STATIC_CONST_INIT_INT(0);
00155   static const unsigned long one VCL_STATIC_CONST_INIT_INT(1);
00156   typedef unsigned long abs_t;
00157   typedef unsigned long double_t;
00158   typedef double real_t;
00159 };
00160 
00161 VCL_DEFINE_SPECIALIZATION
00162 class vnl_numeric_traits<float> {
00163 public:
00164   static const float zero VCL_STATIC_CONST_INIT_FLOAT(0.0F);
00165   static const float one VCL_STATIC_CONST_INIT_FLOAT(1.0F);
00166   typedef float abs_t;
00167   typedef double double_t;
00168   typedef double real_t;
00169 };
00170 
00171 VCL_DEFINE_SPECIALIZATION
00172 class vnl_numeric_traits<double> {
00173 public:
00174   static const double zero VCL_STATIC_CONST_INIT_FLOAT(0.0);
00175   static const double one VCL_STATIC_CONST_INIT_FLOAT(1.0);
00176   typedef double abs_t;
00177   typedef long double double_t;
00178   typedef double real_t;
00179 };
00180 
00181 VCL_DEFINE_SPECIALIZATION
00182 class vnl_numeric_traits<long double> {
00183 public:
00184   static const long double zero VCL_STATIC_CONST_INIT_FLOAT(0.0);
00185   static const long double one VCL_STATIC_CONST_INIT_FLOAT(1.0);
00186   typedef long double abs_t;
00187   typedef long double double_t; // ahem
00188   typedef long double real_t;
00189 };
00190 
00191 VCL_DEFINE_SPECIALIZATION
00192 class vnl_numeric_traits< vcl_complex<float> > {
00193 public:
00194   static const vcl_complex<float> zero;
00195   static const vcl_complex<float> one;
00196   typedef float abs_t;
00197   typedef vcl_complex<vnl_numeric_traits<float>::double_t> double_t;
00198   typedef vcl_complex<float> real_t;
00199 };
00200 
00201 VCL_DEFINE_SPECIALIZATION
00202 class vnl_numeric_traits< vcl_complex<double> > {
00203 public:
00204   static const vcl_complex<double> zero;
00205   static const vcl_complex<double> one;
00206   typedef double abs_t;
00207   typedef vcl_complex<vnl_numeric_traits<double>::double_t> double_t;
00208   typedef vcl_complex<double> real_t;
00209 };
00210 
00211 VCL_DEFINE_SPECIALIZATION
00212 class vnl_numeric_traits< vcl_complex<long double> > {
00213 public:
00214   static const vcl_complex<long double> zero;
00215   static const vcl_complex<long double> one;
00216   typedef long double abs_t;
00217   typedef vcl_complex<vnl_numeric_traits<long double>::double_t> double_t;
00218   typedef vcl_complex<long double> real_t;
00219 };
00220 
00221 #endif // vnl_numeric_traits_h_

Generated at Wed Mar 12 01:13:15 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000