Go to the documentation of this file.00001
00002 #ifndef vnl_complex_traits_h_
00003 #define vnl_complex_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 #include <vcl_complex.h>
00019
00020 #if 0 // The old implementation
00021
00022 enum { isreal = true };
00023
00024
00025 static T conjugate(T x);
00026
00027
00028 static vcl_complex<T> complexify(T x);
00029 #endif
00030
00031 template <class T>
00032 struct vnl_complex_traits;
00033
00034 #define macro(T) \
00035 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<T > \
00036 { \
00037 enum { isreal = true }; \
00038 static T conjugate(T x) { return x; } \
00039 static vcl_complex<T> complexify(T x) { return vcl_complex<T >(x, (T)0); } \
00040 }
00041 #define makro(T) \
00042 macro(signed T); \
00043 macro(unsigned T)
00044 makro(char);
00045 makro(short);
00046 makro(int);
00047 makro(long);
00048 #if VCL_HAS_LONG_LONG
00049 makro(long long);
00050 #endif
00051 #undef makro
00052 #undef macro
00053
00054
00055 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<float>
00056 {
00057 enum { isreal = true };
00058 static float conjugate(float x) { return x; }
00059 static vcl_complex<float> complexify(float x) { return vcl_complex<float>(x, 0.0f); }
00060 };
00061
00062 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<double>
00063 {
00064 enum { isreal = true };
00065 static double conjugate(double x) { return x; }
00066 static vcl_complex<double> complexify(double x) { return vcl_complex<double>(x, 0.0); }
00067 };
00068
00069 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<long double>
00070 {
00071 enum { isreal = true };
00072 static long double conjugate(long double x) { return x; }
00073 static vcl_complex<long double> complexify(long double x) { return vcl_complex<long double>(x, 0.0); }
00074 };
00075
00076 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<vcl_complex<float> >
00077 {
00078 enum { isreal = false };
00079 static vcl_complex<float> conjugate(vcl_complex<float> x) { return vcl_conj(x); }
00080 static vcl_complex<float> complexify(float x) { return x; }
00081 };
00082
00083 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<vcl_complex<double> >
00084 {
00085 enum { isreal = false };
00086 static vcl_complex<double> conjugate(vcl_complex<double> x) { return vcl_conj(x); }
00087 static vcl_complex<double> complexify(double x) { return x; }
00088 };
00089
00090 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<vcl_complex<long double> >
00091 {
00092 enum { isreal = false };
00093 static vcl_complex<long double> conjugate(vcl_complex<long double> x) { return vcl_conj(x); }
00094 static vcl_complex<long double> complexify(long double x) { return x; }
00095 };
00096
00097 #include <vnl/vnl_bignum.h>
00098
00099 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<vnl_bignum>
00100 {
00101 enum { isreal = true };
00102 static vnl_bignum conjugate(vnl_bignum x) { return x; }
00103 static vcl_complex<vnl_bignum> complexify(vnl_bignum x) { return vcl_complex<vnl_bignum>(x,vnl_bignum(0L)); }
00104 };
00105
00106 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<vcl_complex<vnl_bignum> >
00107 {
00108 enum { isreal = false };
00109 static vcl_complex<vnl_bignum> conjugate(vcl_complex<vnl_bignum> x) { return vcl_complex<vnl_bignum>(x.real(),-x.imag()); }
00110 static vcl_complex<vnl_bignum> complexify(vcl_complex<vnl_bignum> x) { return x; }
00111 };
00112
00113 #include <vnl/vnl_rational.h>
00114
00115 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<vnl_rational>
00116 {
00117 enum { isreal = true };
00118 static vnl_rational conjugate(vnl_rational x) { return x; }
00119 static vcl_complex<vnl_rational> complexify(vnl_rational x) { return vcl_complex<vnl_rational>(x, vnl_rational(0,1)); }
00120 };
00121
00122 VCL_DEFINE_SPECIALIZATION struct vnl_complex_traits<vcl_complex<vnl_rational> >
00123 {
00124 enum { isreal = false };
00125 static vcl_complex<vnl_rational> conjugate(vcl_complex<vnl_rational> x) {return vcl_complex<vnl_rational>(x.real(),-x.imag());}
00126 static vcl_complex<vnl_rational> complexify(vcl_complex<vnl_rational> x) { return x; }
00127 };
00128
00129 #endif // vnl_complex_traits_h_