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