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 #ifndef BZ_NUMTRAIT_H
00028 #define BZ_NUMTRAIT_H
00029
00030 #ifndef BZ_BLITZ_H
00031 #include <blitz/blitz.h>
00032 #endif
00033
00034 BZ_NAMESPACE(blitz)
00035
00036 #ifndef BZ_USE_NUMTRAIT
00037 #define BZ_SUMTYPE(X) X
00038 #define BZ_DIFFTYPE(X) X
00039 #define BZ_FLOATTYPE(X) X
00040 #define BZ_SIGNEDTYPE(X) X
00041 #else
00042
00043 #define BZ_SUMTYPE(X) _bz_typename NumericTypeTraits<X>::T_sumtype
00044 #define BZ_DIFFTYPE(X) _bz_typename NumericTypeTraits<X>::T_difftype
00045 #define BZ_FLOATTYPE(X) _bz_typename NumericTypeTraits<X>::T_floattype
00046 #define BZ_SIGNEDTYPE(X) _bz_typename NumericTypeTraits<X>::T_signedtype
00047
00048 template<typename P_numtype>
00049 class NumericTypeTraits {
00050 public:
00051 typedef P_numtype T_sumtype;
00052 typedef P_numtype T_difftype;
00053 typedef P_numtype T_floattype;
00054
00055 typedef P_numtype T_signedtype;
00056 enum { hasTrivialCtor = 0 };
00057 };
00058
00059 #define BZDECLNUMTRAIT(X,Y,Z,W,U) \
00060 template<> \
00061 class NumericTypeTraits<X> { \
00062 public: \
00063 typedef Y T_sumtype; \
00064 typedef Z T_difftype; \
00065 typedef W T_floattype; \
00066 typedef U T_signedtype; \
00067 enum { hasTrivialCtor = 1 }; \
00068 }
00069
00070 #ifdef BZ_HAVE_BOOL
00071 BZDECLNUMTRAIT(bool,unsigned,int,float,int);
00072 #endif
00073
00074 BZDECLNUMTRAIT(char,int,int,float,char);
00075 BZDECLNUMTRAIT(unsigned char, unsigned, int, float,int);
00076 BZDECLNUMTRAIT(short int, int, int, float, short int);
00077 BZDECLNUMTRAIT(short unsigned int, unsigned int, int, float, int);
00078 BZDECLNUMTRAIT(int, long, int, float, int);
00079 BZDECLNUMTRAIT(unsigned int, unsigned long, int, float, long);
00080 BZDECLNUMTRAIT(long, long, long, double, long);
00081 BZDECLNUMTRAIT(unsigned long, unsigned long, long, double, long);
00082 BZDECLNUMTRAIT(float, double, float, float, float);
00083 BZDECLNUMTRAIT(double, double, double, double, double);
00084
00085 #ifdef BZ_HAVE_COMPLEX
00086
00087
00088 #endif // BZ_HAVE_COMPLEX
00089
00090 #endif // BZ_USE_NUMTRAIT
00091
00092 BZ_NAMESPACE_END
00093
00094 #endif // BZ_NUMTRAIT_H