11 #ifndef _CH_COMPLEX_H_ 12 #define _CH_COMPLEX_H_ 32 class Complex :
public complex<Real>
40 inline Complex(
const complex<Real>& a_arg):complex<Real>(a_arg)
45 inline Complex(
const Real& re,
const Real& im):complex<Real>(re, im)
53 inline Real re()
const 62 inline Real im()
const 67 inline Complex& operator=(
const Complex& rhs)
69 reinterpret_cast<Real(&)[2]
>(*this)[0] =
reinterpret_cast<const Real(&)[2]
>(rhs)[0];
70 reinterpret_cast<Real(&)[2]
>(*this)[1] =
reinterpret_cast<const Real(&)[2]
>(rhs)[1];
75 inline Complex& operator*=(
Real s)
77 reinterpret_cast<Real(&)[2]
>(*this)[0] *=s;
78 reinterpret_cast<Real(&)[2]
>(*this)[1] *=s;
82 inline Complex& operator*=(
const Complex& in)
84 Real a =
reinterpret_cast<const Real(&)[2]
>(in)[0];
85 Real b =
reinterpret_cast<const Real(&)[2]
>(in)[1];
86 Real c =
reinterpret_cast<const Real(&)[2]
>(*this)[0];
87 Real d =
reinterpret_cast<const Real(&)[2]
>(*this)[1];
88 reinterpret_cast<Real(&)[2]
>(*this)[0] = a*c - b*d;
89 reinterpret_cast<Real(&)[2]
>(*this)[1] = a*b + b*c;
93 inline Complex
operator*(
const Complex& in)
const 96 Real a =
reinterpret_cast<const Real(&)[2]
>(in)[0];
97 Real b =
reinterpret_cast<const Real(&)[2]
>(in)[1];
98 Real c =
reinterpret_cast<const Real(&)[2]
>(*this)[0];
99 Real d =
reinterpret_cast<const Real(&)[2]
>(*this)[1];
100 reinterpret_cast<Real(&)[2]
>(rtn)[0] = a*c - b*d;
101 reinterpret_cast<Real(&)[2]
>(rtn)[1] = a*b + b*c;
104 static inline Complex Zero() {
return Complex(0,0);}
116 inline Real & Complex::re()
118 return (((
Real*)
this)[0]);
121 inline Real & Complex::im()
123 return (((
Real*)
this)[1]);
131 #endif //CH_USE_COMPLEX 132 #endif //_CH_COMPLEX_H_
double Real
Definition: REAL.H:33
C::self_type operator*(const C &, const C &)
Definition: GenericArithmeticI.H:128