Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Beta/Math/Complex/Complex.hpp

Go to the documentation of this file.
00001 #ifndef __J2K__JComplex_HPP__
00002 #define __J2K__JComplex_HPP__
00003 
00004 // Use ref's and polar stuff
00005 // operator~ and operator! ?
00006 // Minus operator ?
00007 
00008 /////////////////////////////////////////////////////////////////////////////
00009 // Since most calculations are done as double,                             //
00010 // why do we need a template to create:  char, int, float, long            //
00011 // Complex class, that will anyway do it as double                         //
00012 // and then rip off the decimal values !                                   //
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 /// Constructors and Destructors                                          ///
00022 /////////////////////////////////////////////////////////////////////////////
00023 /// Defined in:  CpxBuild.cpp                                             ///
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 /// Compare 'THIS' with a Complex                                         ///
00032 /////////////////////////////////////////////////////////////////////////////
00033 /// Defined in:  CplxComp.cpp                                             ///
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 /// Compare 'THIS' with a CplxDouble                                      ///
00041 /// True, if Real only and equal                                          ///
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 /// Compare Left Complex with Right Complex  (Friend functions)           ///
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 /// Compare CplxDouble with a Complex  (Friend functions)                 ///
00056 /// True, if Real only and equal                                          ///
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 /// Assignment operators                                                  ///
00066 /////////////////////////////////////////////////////////////////////////////
00067 /// Defined in:  CplxAdd.cpp                                              ///
00068 /////////////////////////////////////////////////////////////////////////////
00069        JComplex& operator=( const JComplex& c );
00070        JComplex& operator=( const CplxDouble& x );
00071 
00072 /////////////////////////////////////////////////////////////////////////////
00073 /// Addition and Substraction operators                                   ///
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 /// Self-Addition and Self-Substraction operators                         ///
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 /// Does this is really needed ?????                                      ///
00095 /////////////////////////////////////////////////////////////////////////////
00096 inline friend JComplex& operator+=( JComplex& x, const JComplex& y ):
00097 inline friend JComplex& operator-=( JComplex& x, const JComplex& y );
00098 
00099 /////////////////////////////////////////////////////////////////////////////
00100 /// Utilities                                                             ///
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;       // Get |z| = (a^2 + b^2)
00111 
00112 inline JComplex getConjugate() const;    // z' = a - bi
00113 inline void Conjugate();                 
00114 
00115 /////////////////////////////////////////////////////////////////////////////
00116 /// Utilities for BAD DATA                                                ///
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 /// Scaling operations                                                    ///
00137 /////////////////////////////////////////////////////////////////////////////
00138 inline JComplex& operator*=( const CplxDouble r );
00139 inline JComplex& operator/=( const CplxDouble r );
00140 
00141 /////////////////////////////////////////////////////////////////////////////
00142 /// Multiplication and Division operations                                ///
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   // Data members
00155   CplxDouble Real;
00156   CplxDouble Imag;
00157 };
00158 
00159 #endif

Generated on Sun Oct 14 18:46:12 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001