complex Class Reference

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

Public Member Functions

 complex (const complex &)=default
 Copy construct. More...
 
complexoperator= (const complex &)=default
 Copy assignment. More...
 
 complex (complex &&)=default
 Move construct. More...
 
complexoperator= (complex &&)=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
 Real part of complex number - STL naming. More...
 
constexpr scalar imag () const
 Imaginary part of complex number - STL naming. More...
 
void real (scalar val)
 Set real part of complex number - STL naming. More...
 
void imag (scalar val)
 Set imaginary part of complex number - STL naming. More...
 
scalar Re () const
 Real part of complex number. More...
 
scalar Im () const
 Imaginary part of complex number. More...
 
scalar & Re ()
 Real part of complex number. More...
 
scalar & Im ()
 Imaginary part of complex number. More...
 
complex conjugate () const
 Complex conjugate. 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
 

Friends

scalar magSqr (const complex &c)
 
scalar mag (const complex &c)
 
complex sqr (const complex &c)
 
complex sign (const complex &c)
 sgn() https://en.wikipedia.org/wiki/Sign_function#Complex_signum More...
 
scalar csign (const complex &c)
 csgn() https://en.wikipedia.org/wiki/Sign_function#Complex_signum More...
 
const friend complexmin (const complex &c1, const complex &c2)
 
const friend complexmax (const complex &c1, const complex &c2)
 
complex limit (const complex &c1, const complex &c2)
 
const friend complexsum (const complex &c)
 
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 82 of file complex.H.

Constructor & Destructor Documentation

◆ complex() [1/9]

complex ( const complex )
default

Copy construct.

◆ complex() [2/9]

complex ( complex &&  )
default

Move construct.

◆ complex() [3/9]

constexpr complex ( )
inlineconstexprnoexcept

Default construct, as zero-initialized.

Definition at line 31 of file complexI.H.

◆ complex() [4/9]

constexpr complex ( const Foam::zero  )
inlineconstexprnoexcept

Construct zero-initialized from zero class.

Definition at line 38 of file complexI.H.

◆ complex() [5/9]

constexpr complex ( const scalar  r)
inlineexplicitconstexprnoexcept

Construct from real component.

Definition at line 45 of file complexI.H.

◆ complex() [6/9]

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

Construct from real and imaginary parts.

Definition at line 52 of file complexI.H.

◆ complex() [7/9]

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

Implicit construct from std::complex.

Definition at line 59 of file complexI.H.

◆ complex() [8/9]

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

Implicit construct from std::complex.

Definition at line 66 of file complexI.H.

◆ complex() [9/9]

complex ( Istream is)
explicit

Construct from Istream.

Definition at line 68 of file complex.C.

Member Function Documentation

◆ operator=() [1/4]

complex& operator= ( const complex )
default

Copy assignment.

◆ operator=() [2/4]

complex& operator= ( complex &&  )
default

Move assignment.

◆ real() [1/2]

constexpr scalar real ( ) const
inlineconstexpr

Real part of complex number - STL naming.

Definition at line 136 of file complex.H.

◆ imag() [1/2]

constexpr scalar imag ( ) const
inlineconstexpr

Imaginary part of complex number - STL naming.

Definition at line 142 of file complex.H.

◆ real() [2/2]

void real ( scalar  val)
inline

Set real part of complex number - STL naming.

Definition at line 75 of file complexI.H.

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

◆ imag() [2/2]

void imag ( scalar  val)
inline

Set imaginary part of complex number - STL naming.

Definition at line 81 of file complexI.H.

◆ Re() [1/2]

Foam::scalar Re ( ) const
inline

Real part of complex number.

Definition at line 87 of file complexI.H.

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

◆ Im() [1/2]

Foam::scalar Im ( ) const
inline

Imaginary part of complex number.

Definition at line 93 of file complexI.H.

◆ Re() [2/2]

Foam::scalar & Re ( )
inline

Real part of complex number.

Definition at line 99 of file complexI.H.

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

◆ Im() [2/2]

Foam::scalar & Im ( )
inline

Imaginary part of complex number.

Definition at line 105 of file complexI.H.

◆ conjugate()

Foam::complex conjugate ( ) const
inline

Complex conjugate.

Definition at line 111 of file complexI.H.

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

◆ operator std::complex< scalar >()

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

Implicit conversion to std::complex.

Definition at line 181 of file complex.H.

◆ operator=() [3/4]

void operator= ( const Foam::zero  )
inline

Assign zero.

Definition at line 119 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 126 of file complexI.H.

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

◆ operator+=() [1/2]

void operator+= ( const complex c)
inline

Definition at line 133 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 140 of file complexI.H.

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

◆ operator-=() [1/2]

void operator-= ( const complex c)
inline

Definition at line 146 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 153 of file complexI.H.

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

◆ operator*=() [1/2]

void operator*= ( const complex c)
inline

Definition at line 159 of file complexI.H.

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

◆ operator*=() [2/2]

void operator*= ( const scalar  s)
inline

Definition at line 165 of file complexI.H.

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

◆ operator/=() [1/2]

void operator/= ( const complex c)
inline

Definition at line 172 of file complexI.H.

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

◆ operator/=() [2/2]

void operator/= ( const scalar  s)
inline

Definition at line 178 of file complexI.H.

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

◆ operator==()

bool operator== ( const complex c) const
inline

Definition at line 185 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 191 of file complexI.H.

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

Here is the call graph for this function:

Friends And Related Function Documentation

◆ magSqr

scalar magSqr ( const complex c)
friend

Definition at line 210 of file complexI.H.

◆ mag

scalar mag ( const complex c)
friend

Definition at line 216 of file complexI.H.

◆ sqr

complex sqr ( const complex c)
friend

Definition at line 222 of file complexI.H.

◆ sign

complex sign ( const complex c)
friend

◆ csign

scalar csign ( const complex c)
friend

◆ min

const friend complex& min ( const complex c1,
const complex c2 
)
friend

Definition at line 241 of file complexI.H.

◆ max

const friend complex& max ( const complex c1,
const complex c2 
)
friend

Definition at line 252 of file complexI.H.

◆ limit

complex limit ( const complex c1,
const complex c2 
)
friend

Definition at line 263 of file complexI.H.

◆ sum

const friend complex& sum ( const complex c)
friend

Definition at line 269 of file complexI.H.

◆ operator- [1/4]

complex operator- ( const complex c)
friend

Definition at line 285 of file complexI.H.

◆ operator+ [1/3]

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

Definition at line 291 of file complexI.H.

◆ operator+ [2/3]

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

Definition at line 301 of file complexI.H.

◆ operator+ [3/3]

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

Definition at line 307 of file complexI.H.

◆ operator- [2/4]

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

Definition at line 313 of file complexI.H.

◆ operator- [3/4]

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

Definition at line 323 of file complexI.H.

◆ operator- [4/4]

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

Definition at line 329 of file complexI.H.

◆ operator* [1/3]

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

Definition at line 335 of file complexI.H.

◆ operator* [2/3]

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

Definition at line 345 of file complexI.H.

◆ operator* [3/3]

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

Definition at line 351 of file complexI.H.

◆ operator/ [1/3]

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

Definition at line 357 of file complexI.H.

◆ operator/ [2/3]

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

Definition at line 369 of file complexI.H.

◆ operator/ [3/3]

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

Definition at line 375 of file complexI.H.


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