complex Class Reference

A complex number, similar to the C++ complex type. More...

Public Member Functions

 complex (const complex &) noexcept=default
 Copy construct. More...
 
complexoperator= (const complex &) noexcept=default
 Copy assignment. More...
 
 complex (complex &&) noexcept=default
 Move construct. More...
 
complexoperator= (complex &&) noexcept=default
 Move assignment. More...
 
constexpr complex () noexcept
 Default construct, as zero-initialized. More...
 
constexpr complex (const Foam::zero) noexcept
 Construct zero-initialized from zero class. More...
 
constexpr complex (const scalar r) noexcept
 Construct from real component. More...
 
constexpr complex (const scalar r, const scalar i) noexcept
 Construct from real and imaginary parts. More...
 
 complex (const std::complex< float > &c)
 Implicit construct from std::complex. More...
 
 complex (const std::complex< double > &c)
 Implicit construct from std::complex. More...
 
 complex (Istream &is)
 Construct from Istream. More...
 
constexpr scalar real () const noexcept
 Real part of complex number - STL naming. More...
 
constexpr scalar imag () const noexcept
 Imaginary part of complex number - STL naming. More...
 
void real (scalar val) noexcept
 Set real part of complex number - STL naming. More...
 
void imag (scalar val) noexcept
 Set imaginary part of complex number - STL naming. More...
 
complex conjugate () const
 Complex conjugate. More...
 
scalar magnitude () const
 The magnitude (L2-norm) of complex. Called magnitude() instead mag(), which looks too much like imag() More...
 
scalar magSqr () const
 The L2-norm squared of complex. More...
 
scalar cmptSum () const noexcept
 The sum of real/imag components. More...
 
 operator std::complex< scalar > () const
 Implicit conversion to std::complex. More...
 
void operator= (const Foam::zero)
 Assign zero. More...
 
void operator= (const scalar s)
 Assign scalar (imag = zero) More...
 
void operator+= (const complex &c)
 
void operator+= (const scalar s)
 
void operator-= (const complex &c)
 
void operator-= (const scalar s)
 
void operator*= (const complex &c)
 
void operator*= (const scalar s)
 
void operator/= (const complex &c)
 
void operator/= (const scalar s)
 
bool operator== (const complex &c) const
 
bool operator!= (const complex &c) const
 
scalar Re () const noexcept
 Get real part of complex number. Same as real() More...
 
scalar Im () const noexcept
 Get imaginary part of complex number. Same as imag() More...
 
scalar & Re () noexcept
 Non-const access to real part. Prefer real() setter method. More...
 
scalar & Im () noexcept
 Non-const access to imaginary part. Prefer imag() setter method. More...
 

Friends

complex operator- (const complex &c)
 
complex operator+ (const complex &c1, const complex &c2)
 
complex operator+ (const complex &c, const scalar s)
 
complex operator+ (const scalar s, const complex &c)
 
complex operator- (const complex &c1, const complex &c2)
 
complex operator- (const complex &c, const scalar s)
 
complex operator- (const scalar s, const complex &c)
 
complex operator* (const complex &c1, const complex &c2)
 
complex operator* (const complex &c, const scalar s)
 
complex operator* (const scalar s, const complex &c)
 
complex operator/ (const complex &c1, const complex &c2)
 
complex operator/ (const complex &c, const scalar s)
 
complex operator/ (const scalar s, const complex &c)
 

Detailed Description

A complex number, similar to the C++ complex type.

Source files

Definition at line 70 of file complex.H.

Constructor & Destructor Documentation

◆ complex() [1/9]

complex ( const complex )
defaultnoexcept

Copy construct.

◆ complex() [2/9]

complex ( complex &&  )
defaultnoexcept

Move construct.

◆ complex() [3/9]

constexpr complex ( )
inlinenoexcept

Default construct, as zero-initialized.

Definition at line 24 of file complexI.H.

◆ complex() [4/9]

constexpr complex ( const Foam::zero  )
inlinenoexcept

Construct zero-initialized from zero class.

Definition at line 31 of file complexI.H.

◆ complex() [5/9]

constexpr complex ( const scalar  r)
inlineexplicitnoexcept

Construct from real component.

Definition at line 38 of file complexI.H.

◆ complex() [6/9]

constexpr complex ( const scalar  r,
const scalar  i 
)
inlinenoexcept

Construct from real and imaginary parts.

Definition at line 45 of file complexI.H.

◆ complex() [7/9]

complex ( const std::complex< float > &  c)
inline

Implicit construct from std::complex.

Definition at line 52 of file complexI.H.

◆ complex() [8/9]

complex ( const std::complex< double > &  c)
inline

Implicit construct from std::complex.

Definition at line 59 of file complexI.H.

◆ complex() [9/9]

complex ( Istream is)
explicit

Construct from Istream.

Definition at line 56 of file complex.C.

Member Function Documentation

◆ operator=() [1/4]

complex& operator= ( const complex )
defaultnoexcept

Copy assignment.

◆ operator=() [2/4]

complex& operator= ( complex &&  )
defaultnoexcept

Move assignment.

◆ real() [1/2]

constexpr scalar real ( ) const
inlinenoexcept

Real part of complex number - STL naming.

Definition at line 150 of file complex.H.

Referenced by Foam::lerp().

Here is the caller graph for this function:

◆ imag() [1/2]

constexpr scalar imag ( ) const
inlinenoexcept

Imaginary part of complex number - STL naming.

Definition at line 155 of file complex.H.

Referenced by Foam::lerp().

Here is the caller graph for this function:

◆ real() [2/2]

void real ( scalar  val)
inlinenoexcept

Set real part of complex number - STL naming.

Definition at line 160 of file complex.H.

◆ imag() [2/2]

void imag ( scalar  val)
inlinenoexcept

Set imaginary part of complex number - STL naming.

Definition at line 165 of file complex.H.

◆ conjugate()

Foam::complex conjugate ( ) const
inline

Complex conjugate.

Definition at line 68 of file complexI.H.

References Foam::roots::complex, and Foam::constant::atomic::re.

◆ magnitude()

Foam::scalar magnitude ( ) const
inline

The magnitude (L2-norm) of complex. Called magnitude() instead mag(), which looks too much like imag()

Definition at line 74 of file complexI.H.

References Foam::hypot(), and Foam::constant::atomic::re.

Here is the call graph for this function:

◆ magSqr()

Foam::scalar magSqr ( ) const
inline

The L2-norm squared of complex.

Definition at line 80 of file complexI.H.

References Foam::constant::atomic::re.

◆ cmptSum()

Foam::scalar cmptSum ( ) const
inlinenoexcept

The sum of real/imag components.

Definition at line 86 of file complexI.H.

References Foam::constant::atomic::re.

◆ operator std::complex< scalar >()

operator std::complex< scalar > ( ) const
inline

Implicit conversion to std::complex.

Definition at line 197 of file complex.H.

◆ operator=() [3/4]

void operator= ( const Foam::zero  )
inline

Assign zero.

Definition at line 94 of file complexI.H.

References Foam::constant::atomic::re.

◆ operator=() [4/4]

void operator= ( const scalar  s)
inline

Assign scalar (imag = zero)

Definition at line 101 of file complexI.H.

References Foam::constant::atomic::re, and s.

◆ operator+=() [1/2]

void operator+= ( const complex c)
inline

Definition at line 108 of file complexI.H.

References Foam::constant::universal::c, and Foam::constant::atomic::re.

◆ operator+=() [2/2]

void operator+= ( const scalar  s)
inline

Definition at line 115 of file complexI.H.

References Foam::constant::atomic::re, and s.

◆ operator-=() [1/2]

void operator-= ( const complex c)
inline

Definition at line 121 of file complexI.H.

References Foam::constant::universal::c, and Foam::constant::atomic::re.

◆ operator-=() [2/2]

void operator-= ( const scalar  s)
inline

Definition at line 128 of file complexI.H.

References Foam::constant::atomic::re, and s.

◆ operator*=() [1/2]

void operator*= ( const complex c)
inline

Definition at line 134 of file complexI.H.

References Foam::constant::universal::c.

◆ operator*=() [2/2]

void operator*= ( const scalar  s)
inline

Definition at line 140 of file complexI.H.

References Foam::constant::atomic::re, and s.

◆ operator/=() [1/2]

void operator/= ( const complex c)
inline

Definition at line 147 of file complexI.H.

References Foam::constant::universal::c.

◆ operator/=() [2/2]

void operator/= ( const scalar  s)
inline

Definition at line 153 of file complexI.H.

References Foam::constant::atomic::re, and s.

◆ operator==()

bool operator== ( const complex c) const
inline

Definition at line 160 of file complexI.H.

References Foam::constant::universal::c, Foam::equal(), and Foam::constant::atomic::re.

Here is the call graph for this function:

◆ operator!=()

bool operator!= ( const complex c) const
inline

Definition at line 166 of file complexI.H.

References Foam::constant::universal::c, and Foam::operator==().

Here is the call graph for this function:

◆ Re() [1/2]

scalar Re ( ) const
inlinenoexcept

Get real part of complex number. Same as real()

Definition at line 255 of file complex.H.

◆ Im() [1/2]

scalar Im ( ) const
inlinenoexcept

Get imaginary part of complex number. Same as imag()

Definition at line 260 of file complex.H.

◆ Re() [2/2]

scalar& Re ( )
inlinenoexcept

Non-const access to real part. Prefer real() setter method.

Definition at line 265 of file complex.H.

◆ Im() [2/2]

scalar& Im ( )
inlinenoexcept

Non-const access to imaginary part. Prefer imag() setter method.

Definition at line 270 of file complex.H.

Friends And Related Function Documentation

◆ operator- [1/4]

complex operator- ( const complex c)
friend

Definition at line 279 of file complexI.H.

◆ operator+ [1/3]

complex operator+ ( const complex c1,
const complex c2 
)
friend

Definition at line 285 of file complexI.H.

◆ operator+ [2/3]

complex operator+ ( const complex c,
const scalar  s 
)
friend

Definition at line 295 of file complexI.H.

◆ operator+ [3/3]

complex operator+ ( const scalar  s,
const complex c 
)
friend

Definition at line 301 of file complexI.H.

◆ operator- [2/4]

complex operator- ( const complex c1,
const complex c2 
)
friend

Definition at line 307 of file complexI.H.

◆ operator- [3/4]

complex operator- ( const complex c,
const scalar  s 
)
friend

Definition at line 317 of file complexI.H.

◆ operator- [4/4]

complex operator- ( const scalar  s,
const complex c 
)
friend

Definition at line 323 of file complexI.H.

◆ operator* [1/3]

complex operator* ( const complex c1,
const complex c2 
)
friend

Definition at line 329 of file complexI.H.

◆ operator* [2/3]

complex operator* ( const complex c,
const scalar  s 
)
friend

Definition at line 339 of file complexI.H.

◆ operator* [3/3]

complex operator* ( const scalar  s,
const complex c 
)
friend

Definition at line 345 of file complexI.H.

◆ operator/ [1/3]

complex operator/ ( const complex c1,
const complex c2 
)
friend

Definition at line 351 of file complexI.H.

◆ operator/ [2/3]

complex operator/ ( const complex c,
const scalar  s 
)
friend

Definition at line 363 of file complexI.H.

◆ operator/ [3/3]

complex operator/ ( const scalar  s,
const complex c 
)
friend

Definition at line 369 of file complexI.H.


The documentation for this class was generated from the following files: