Public Member Functions | Friends | List of all members
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 complexmin (const complex &c1, const complex &c2)
 
const complexmax (const complex &c1, const complex &c2)
 
complex limit (const complex &c1, const complex &c2)
 
const 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 78 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 ( )
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 55 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
inline

Real part of complex number - STL naming.

Definition at line 158 of file complex.H.

◆ imag() [1/2]

constexpr scalar imag ( ) const
inline

Imaginary part of complex number - STL naming.

Definition at line 166 of file complex.H.

◆ real() [2/2]

void real ( scalar  val)
inline

Set real part of complex number - STL naming.

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

◆ Re() [1/2]

Foam::scalar Re ( ) const
inline

Real part of complex number.

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

◆ Re() [2/2]

Foam::scalar & Re ( )
inline

Real part of complex number.

Definition at line 92 of file complexI.H.

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

◆ Im() [2/2]

Foam::scalar & Im ( )
inline

Imaginary part of complex number.

Definition at line 98 of file complexI.H.

◆ conjugate()

Foam::complex conjugate ( ) const
inline

Complex conjugate.

Definition at line 104 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 221 of file complex.H.

◆ operator=() [3/4]

void operator= ( const Foam::zero  )
inline

Assign zero.

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

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

◆ operator+=() [1/2]

void operator+= ( const complex c)
inline

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

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

◆ operator-=() [1/2]

void operator-= ( const complex c)
inline

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

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

◆ operator*=() [1/2]

void operator*= ( const complex c)
inline

Definition at line 152 of file complexI.H.

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

◆ operator*=() [2/2]

void operator*= ( const scalar  s)
inline

Definition at line 158 of file complexI.H.

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

◆ operator/=() [1/2]

void operator/= ( const complex c)
inline

Definition at line 165 of file complexI.H.

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

◆ operator/=() [2/2]

void operator/= ( const scalar  s)
inline

Definition at line 171 of file complexI.H.

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

◆ operator==()

bool operator== ( const complex c) const
inline

Definition at line 178 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 184 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 203 of file complexI.H.

◆ mag

scalar mag ( const complex c)
friend

Definition at line 209 of file complexI.H.

◆ sqr

complex sqr ( const complex c)
friend

Definition at line 215 of file complexI.H.

◆ sign

complex sign ( const complex c)
friend

◆ csign

scalar csign ( const complex c)
friend

◆ min

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

Definition at line 234 of file complexI.H.

◆ max

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

Definition at line 245 of file complexI.H.

◆ limit

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

Definition at line 256 of file complexI.H.

◆ sum

const complex& sum ( const complex c)
friend

Definition at line 262 of file complexI.H.

◆ operator- [1/4]

complex operator- ( const complex c)
friend

Definition at line 278 of file complexI.H.

◆ operator+ [1/3]

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

Definition at line 284 of file complexI.H.

◆ operator+ [2/3]

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

Definition at line 294 of file complexI.H.

◆ operator+ [3/3]

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

Definition at line 300 of file complexI.H.

◆ operator- [2/4]

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

Definition at line 306 of file complexI.H.

◆ operator- [3/4]

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

Definition at line 316 of file complexI.H.

◆ operator- [4/4]

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

Definition at line 322 of file complexI.H.

◆ operator* [1/3]

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

Definition at line 328 of file complexI.H.

◆ operator* [2/3]

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

Definition at line 338 of file complexI.H.

◆ operator* [3/3]

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

Definition at line 344 of file complexI.H.

◆ operator/ [1/3]

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

Definition at line 350 of file complexI.H.

◆ operator/ [2/3]

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

Definition at line 362 of file complexI.H.

◆ operator/ [3/3]

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

Definition at line 368 of file complexI.H.


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