Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_oct_cmplx_h)
00025 #define octave_oct_cmplx_h 1
00026
00027 #include <complex>
00028
00029 typedef std::complex<double> Complex;
00030 typedef std::complex<float> FloatComplex;
00031
00032
00033
00034
00035
00036
00037
00038
00039 #define DEF_COMPLEXR_COMP(OP, OPS) \
00040 template <class T> \
00041 inline bool operator OP (const std::complex<T>& a, const std::complex<T>& b) \
00042 { \
00043 FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \
00044 if (ax == bx) \
00045 { \
00046 FLOAT_TRUNCATE const T ay = std::arg (a), by = std::arg (b); \
00047 return ay OP by; \
00048 } \
00049 else \
00050 return ax OPS bx; \
00051 } \
00052 template <class T> \
00053 inline bool operator OP (const std::complex<T>& a, T b) \
00054 { \
00055 FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \
00056 if (ax == bx) \
00057 { \
00058 FLOAT_TRUNCATE const T ay = std::arg (a); \
00059 return ay OP 0; \
00060 } \
00061 else \
00062 return ax OPS bx; \
00063 } \
00064 template <class T> \
00065 inline bool operator OP (T a, const std::complex<T>& b) \
00066 { \
00067 FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \
00068 if (ax == bx) \
00069 { \
00070 FLOAT_TRUNCATE const T by = std::arg (b); \
00071 return 0 OP by; \
00072 } \
00073 else \
00074 return ax OPS bx; \
00075 }
00076
00077 DEF_COMPLEXR_COMP (>, >)
00078 DEF_COMPLEXR_COMP (<, <)
00079 DEF_COMPLEXR_COMP (<=, <)
00080 DEF_COMPLEXR_COMP (>=, >)
00081
00082 #endif