48 FXComplexd&
set(FXdouble r){ re=r; im=0.0;
return *
this; }
51 FXComplexd&
set(FXdouble r,FXdouble i){ re=r; im=i;
return *
this;}
57 FXbool
operator!()
const {
return (re==0.0) && (im==0.0); }
60 FXdouble&
real(){
return re; }
61 const FXdouble& real()
const {
return re; }
64 FXdouble&
imag(){
return im; }
65 const FXdouble& imag()
const {
return im; }
68 FXdouble
modulus2()
const {
return re*re+im*im; }
71 FXdouble
modulus()
const {
return Math::sqrt(modulus2()); }
74 FXdouble
argument()
const {
return Math::atan2(im,re); }
80 const FXdouble&
operator[](FXint i)
const {
return (&re)[i]; }
94 FXComplexd& operator-=(FXdouble r){ re-=r;
return *
this; }
95 FXComplexd& operator*=(FXdouble r){ re*=r; im*=r;
return *
this; }
96 FXComplexd& operator/=(FXdouble r){ re/=r; im/=r;
return *
this; }
101 FXComplexd& operator*=(
const FXComplexd& c){
return set(re*c.re-im*c.im,re*c.im+im*c.re); }
102 FXComplexd& operator/=(
const FXComplexd& c){ FXdouble m=c.re*c.re+c.im*c.im;
return set((re*c.re+im*c.im)/m,(im*c.re-re*c.im)/m); }
110 static inline FXComplexd conj(
const FXComplexd& c){
return FXComplexd(c.real(),-c.imag()); }
113 static inline FXComplexd polar(FXdouble mod,FXdouble arg){
return FXComplexd(Math::cos(arg)*mod,Math::sin(arg)*mod); }
116 static inline FXdouble norm(
const FXComplexd& c){
return c.real()*c.real()+c.imag()*c.imag(); }
119 static inline FXdouble abs(
const FXComplexd& c){
return Math::sqrt(norm(c)); }
122 static inline FXdouble arg(
const FXComplexd& c){
return Math::atan2(c.imag(),c.real()); }
125 static inline FXComplexd exp(
const FXComplexd& c){
return polar(Math::exp(c.real()),c.imag()); }
128 static inline FXComplexd log(
const FXComplexd& c){
return FXComplexd(Math::log(abs(c)),arg(c)); }
132 static inline FXbool operator==(
const FXComplexd& c,FXdouble r){
return c.real()==r && c.imag()==0.0; }
133 static inline FXbool operator!=(
const FXComplexd& c,FXdouble r){
return c.real()!=r || c.imag()!=0.0; }
136 static inline FXbool operator==(FXdouble r,
const FXComplexd& c){
return r==c.real() && c.imag()==0.0; }
137 static inline FXbool operator!=(FXdouble r,
const FXComplexd& c){
return r!=c.real() || c.imag()!=0.0; }
140 static inline FXbool operator==(
const FXComplexd& a,
const FXComplexd& b){
return a.real()==b.real() && a.imag()==b.imag(); }
141 static inline FXbool operator!=(
const FXComplexd& a,
const FXComplexd& b){
return a.real()!=b.real() || a.imag()!=b.imag(); }
144 static inline FXComplexd operator+(
const FXComplexd& a,FXdouble b){
return FXComplexd(a.real()+b,a.imag()); }
145 static inline FXComplexd operator-(
const FXComplexd& a,FXdouble b){
return FXComplexd(a.real()-b,a.imag()); }
146 static inline FXComplexd operator*(
const FXComplexd& a,FXdouble b){
return FXComplexd(a.real()*b,a.imag()*b); }
147 static inline FXComplexd operator/(
const FXComplexd& a,FXdouble b){
return FXComplexd(a.real()/b,a.imag()/b); }
150 static inline FXComplexd operator+(FXdouble a,
const FXComplexd& b){
return FXComplexd(a+b.real(),b.imag()); }
151 static inline FXComplexd operator-(FXdouble a,
const FXComplexd& b){
return FXComplexd(a-b.real(),-b.imag()); }
152 static inline FXComplexd operator*(FXdouble a,
const FXComplexd& b){
return FXComplexd(a*b.real(),a*b.imag()); }
153 static inline FXComplexd operator/(FXdouble a,
const FXComplexd& b){ FXdouble m=norm(b);
return FXComplexd((a*b.real())/m,(-a*b.imag())/m); }
156 static inline FXComplexd operator+(
const FXComplexd& a,
const FXComplexd& b){
return FXComplexd(a.real()+b.real(),a.imag()+b.imag()); }
157 static inline FXComplexd operator-(
const FXComplexd& a,
const FXComplexd& b){
return FXComplexd(a.real()-b.real(),a.imag()-b.imag()); }
158 static inline FXComplexd operator*(
const FXComplexd& a,
const FXComplexd& b){
return FXComplexd(a.real()*b.real()-a.imag()*b.imag(),a.real()*b.imag()+a.imag()*b.real()); }
159 static inline FXComplexd operator/(
const FXComplexd& a,
const FXComplexd& b){ FXdouble m=norm(b);
return FXComplexd((a.real()*b.real()+a.imag()*b.imag())/m,(a.imag()*b.real()-a.real()*b.imag())/m); }
162 static inline FXComplexd lerp(
const FXComplexd& u,
const FXComplexd& v,FXdouble f){
return (v-u)*f+u; }
165 extern FXAPI FXComplexd csqrt(
const FXComplexd& c);
168 extern FXAPI FXComplexd csin(
const FXComplexd& c);
171 extern FXAPI FXComplexd ccos(
const FXComplexd& c);
174 extern FXAPI FXComplexd ctan(
const FXComplexd& c);
177 extern FXAPI FXComplexd csinh(
const FXComplexd& c);
180 extern FXAPI FXComplexd ccosh(
const FXComplexd& c);
183 extern FXAPI FXComplexd ctanh(
const FXComplexd& c);
186 extern FXAPI FXStream& operator<<(FXStream& store,
const FXComplexd& c);
189 extern FXAPI FXStream& operator>>(FXStream& store,FXComplexd& c);
FXComplexd(FXdouble r, FXdouble i)
Construct from components.
Definition: FXComplexd.h:42
FXComplexd(const FXComplexd &c)
Initialize from another complex.
Definition: FXComplexd.h:45
FXComplexd & operator=(const FXdouble r)
Assignment from real.
Definition: FXComplexd.h:87
FXComplexd & operator+=(const FXComplexd &c)
Assigning operators with another complex.
Definition: FXComplexd.h:99
FXComplexd operator+() const
Unary.
Definition: FXComplexd.h:83
FXdouble & imag()
Access imaginary part.
Definition: FXComplexd.h:64
~FXComplexd()
Destructor.
Definition: FXComplexd.h:105
FXdouble modulus() const
Modulus or absolute value of complex.
Definition: FXComplexd.h:71
FXComplexd()
Default constructor; value is not initialized.
Definition: FXComplexd.h:36
Definition: FX4Splitter.h:28
FXbool operator!() const
Test if zero.
Definition: FXComplexd.h:57
const FXdouble & operator[](FXint i) const
Return a const reference to the ith element.
Definition: FXComplexd.h:80
FXdouble argument() const
Argument of complex.
Definition: FXComplexd.h:74
FXComplexd(FXdouble r)
Construct from real.
Definition: FXComplexd.h:39
FXdouble modulus2() const
Squared modulus.
Definition: FXComplexd.h:68
FXdouble & operator[](FXint i)
Return a non-const reference to the ith element.
Definition: FXComplexd.h:77
FXComplexd & operator=(const FXComplexd &c)
Assignment from another complex.
Definition: FXComplexd.h:90
FXComplexd & operator+=(FXdouble r)
Assigning operators with real.
Definition: FXComplexd.h:93
FXdouble & real()
Access real part.
Definition: FXComplexd.h:60
Double-precision complex.
Definition: FXComplexd.h:29