00001 #ifndef __J2K__JComplex_Addition_Substraction_CPP__
00002 #define __J2K__JComplex_Addition_Substraction_CPP__
00003
00004
00005
00006
00007 JComplex& JComplex::operator=( const CplxDouble& x ) {
00008 Real = x;
00009 Imag = 0;
00010 return (*this);
00011 }
00012
00013 JComplex& JComplex::operator=( const JComplex& c ) {
00014 Real = c.Real;
00015 Imag = c.Imag;
00016 return (*this);
00017 }
00018
00019
00020
00021
00022 inline JComplex JComplex::operator+( const JComplex& left,
00023 const JComplex& right )
00024 {
00025 return JComplex( (left.Real + right.Real), (left.Imag + right.Imag) );
00026 }
00027
00028 inline JComplex JComplex::operator-( const JComplex& left,
00029 const JComplex& right )
00030 {
00031 return JComplex( (left.Real - right.Real), (left.Imag - right.Imag) );
00032 }
00033
00034 inline JComplex JComplex::operator+( const CplxDouble x,
00035 const JComplex& right )
00036 {
00037 return JComplex( (x + right.Real), (right.Imag) );
00038 }
00039
00040 inline JComplex JComplex::operator-( const CplxDouble x,
00041 const JComplex& right )
00042 {
00043 return JComplex( (x - right.Real), (right.Imag) );
00044 }
00045
00046 inline JComplex JComplex::operator+( const JComplex& left,
00047 const CplxDouble x )
00048 {
00049 return JComplex( (left.Real + x), (left.Imag) );
00050 }
00051
00052 inline JComplex JComplex::operator-( const JComplex& left,
00053 const CplxDouble x )
00054 {
00055 return JComplex( (left.Real - x), (left.Imag) );
00056 }
00057
00058
00059
00060
00061 inline JComplex& JComplex::operator+=( const JComplex& c ) {
00062 Real = Real + c.Real;
00063 Imag = Imag + c.Imag;
00064 return (*this);
00065 }
00066
00067 inline JComplex& JComplex::operator-=( const JComplex& c ) {
00068 Real = Real - c.Real;
00069 Imag = Imag - c.Imag;
00070 return (*this);
00071 }
00072
00073 inline JComplex& JComplex::operator+=( const CplxDouble x ) {
00074 Real = Real + x;
00075 return (*this);
00076 }
00077
00078 inline JComplex& JComplex::operator-=( const CplxDouble x ) {
00079 Real = Real - x;
00080 return (*this);
00081 }
00082
00083
00084
00085
00086 inline friend JComplex& JComplex::operator+=( JComplex& x, const JComplex& y ) {
00087 x.Real = x.Real + y.Real;
00088 x.Imag = x.Imag + y.Imag;
00089 return (x);
00090 }
00091
00092 inline friend JComplex& JComplex::operator-=( JComplex& x, const JComplex& y ) {
00093 x.Real = x.Real - y.Real;
00094 x.Imag = x.Imag - y.Imag;
00095 return (x);
00096 }
00097
00098 #endif