00001 #ifndef __J2K__JComplex_HPP__
00002 #define __J2K__JComplex_HPP__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 // This part is derived from the Complex STL template for double type. //
00015
00016 typedef double CplxDouble;
00017
00018 class JComplex {
00019 public:
00020
00021
00022
00023
00024
00025 inline JComplex( const CplxDouble Real );
00026 inline JComplex( const CplxDouble Real, const CplxDouble Imag );
00027 inline JComplex( const JComplex& c );
00028 inline virtual ~JComplex();
00029
00030
00031
00032
00033
00034
00035 BOOL Compare( const JComplex& c ) const;
00036 inline BOOL operator==( const JComplex& c ) const;
00037 inline BOOL operator!=( const JComplex& c ) const;
00038
00039
00040
00041
00042
00043 BOOL Compare( const CplxDouble r ) const;
00044 inline BOOL operator==( const CplxDouble r ) const;
00045 inline BOOL operator!=( const CplxDouble r ) const;
00046
00047
00048
00049
00050 BOOL Compare( const JComplex& left, const JComplex& right );
00051 inline friend BOOL operator==( const JComplex& left, const JComplex& right );
00052 inline friend BOOL operator!=( const JComplex& left, const JComplex& right );
00053
00054
00055
00056
00057
00058 friend BOOL Compare( const JComplex& l, const CplxDouble x );
00059 inline friend BOOL operator==( const JComplex& left, const CplxDouble x );
00060 inline friend BOOL operator!=( const JComplex& left, const CplxDouble x );
00061 inline friend BOOL operator==( const CplxDouble x, const JComplex& right );
00062 inline friend BOOL operator!=( const CplxDouble x, const JComplex& right );
00063
00064
00065
00066
00067
00068
00069 JComplex& operator=( const JComplex& c );
00070 JComplex& operator=( const CplxDouble& x );
00071
00072
00073
00074
00075 inline friend JComplex operator+( const JComplex& left, const JComplex& right );
00076 inline friend JComplex operator-( const JComplex& left, const JComplex& right );
00077
00078 inline JComplex operator+( const CplxDouble x, const JComplex& right );
00079 inline JComplex operator-( const CplxDouble x, const JComplex& right );
00080
00081 inline JComplex operator+( const JComplex& left, const CplxDouble x );
00082 inline JComplex operator-( const JComplex& left, const CplxDouble x );
00083
00084
00085
00086
00087 inline JComplex& operator+=( const JComplex& c );
00088 inline JComplex& operator-=( const JComplex& c );
00089
00090 inline JComplex& operator+=( const CplxDouble x );
00091 inline JComplex& operator-=( const CplxDouble x );
00092
00093
00094
00095
00096 inline friend JComplex& operator+=( JComplex& x, const JComplex& y ):
00097 inline friend JComplex& operator-=( JComplex& x, const JComplex& y );
00098
00099
00100
00101
00102 inline CplxDouble Real() const;
00103 inline CplxDouble Imag() const;
00104 inline JComplex& Get() const;
00105
00106 inline CplxDouble Real( CplxDouble x );
00107 inline CplxDouble Imag( CplxDouble y );
00108 inline JComplex& Set( JComplex& c );
00109
00110 inline CplxDouble Modulus() const;
00111
00112 inline JComplex getConjugate() const;
00113 inline void Conjugate();
00114
00115
00116
00117
00118 CplxDouble _Infv( CplxDouble x );
00119 BOOL _Isinf( CplxDouble x );
00120 BOOL _Isnan( CplxDouble x );
00121 CplxDouble _Nanv( CplxDouble x );
00122
00123
00124
00125 void operator*=( const JComplex& c );
00126 void operator/=( const JComplex& c );
00127 void operator*=( const CplxDouble Real );
00128 void operator/=( const CplxDouble Real );
00129
00130 friend JComplex operator*( const JComplex& l, const JComplex& r );
00131 friend JComplex operator/( const JComplex& l, const JComplex& r );
00132 friend JComplex operator*( const JComplex& l, const CplxDouble& r );
00133 friend JComplex operator/( const JComplex& l, const CplxDouble& r );
00134
00135
00136
00137
00138 inline JComplex& operator*=( const CplxDouble r );
00139 inline JComplex& operator/=( const CplxDouble r );
00140
00141
00142
00143
00144 JComplex Multiply( JComplex& x, const JComplex& y );
00145 JComplex Divide( JComplex& x, const JComplex& y );
00146
00147 inline void operator*=( const JComplex& c );
00148 inline void operator/=( const JComplex& c );
00149
00150 inline friend JComplex operator*( const JComplex& l, const JComplex& r);
00151 inline friend JComplex operator/( const JComplex& l, const JComplex& r);
00152
00153 protected:
00154
00155 CplxDouble Real;
00156 CplxDouble Imag;
00157 };
00158
00159 #endif