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 #if !defined (octave_oct_cmplx_h)
00026 #define octave_oct_cmplx_h 1
00027
00028 #include <complex>
00029
00030 typedef std::complex<double> Complex;
00031 typedef std::complex<float> FloatComplex;
00032
00033
00034
00035
00036
00037
00038
00039
00040 #define DEF_COMPLEXR_COMP(OP, OPS) \
00041 template <class T> \
00042 inline bool operator OP (const std::complex<T>& a, const std::complex<T>& b) \
00043 { \
00044 FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \
00045 if (ax == bx) \
00046 { \
00047 FLOAT_TRUNCATE const T ay = std::arg (a), by = std::arg (b); \
00048 return ay OP by; \
00049 } \
00050 else \
00051 return ax OPS bx; \
00052 } \
00053 template <class T> \
00054 inline bool operator OP (const std::complex<T>& a, T b) \
00055 { \
00056 FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \
00057 if (ax == bx) \
00058 { \
00059 FLOAT_TRUNCATE const T ay = std::arg (a); \
00060 return ay OP 0; \
00061 } \
00062 else \
00063 return ax OPS bx; \
00064 } \
00065 template <class T> \
00066 inline bool operator OP (T a, const std::complex<T>& b) \
00067 { \
00068 FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \
00069 if (ax == bx) \
00070 { \
00071 FLOAT_TRUNCATE const T by = std::arg (b); \
00072 return 0 OP by; \
00073 } \
00074 else \
00075 return ax OPS bx; \
00076 }
00077
00078 DEF_COMPLEXR_COMP (>, >)
00079 DEF_COMPLEXR_COMP (<, <)
00080 DEF_COMPLEXR_COMP (<=, <)
00081 DEF_COMPLEXR_COMP (>=, >)
00082
00083 #endif
00084
00085
00086
00087
00088
00089