complex Class Reference

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

Public Member Functions

constexpr complex () noexcept
 Construct null as zero-initialized. More...
 
 complex (const complex &)=default
 Default copy constructor. 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)
 Construct from std::complex. More...
 
 complex (const std::complex< double > &c)
 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
 Conversion to std::complex. More...
 
void operator= (const complex &c)
 Copy assignment. 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/8]

constexpr complex ( )
inlineconstexprnoexcept

Construct null as zero-initialized.

Definition at line 31 of file complexI.H.

◆ complex() [2/8]

complex ( const complex )
default

Default copy constructor.

◆ complex() [3/8]

constexpr complex ( const Foam::zero  )
inlineconstexprnoexcept

Construct zero-initialized from zero class.

Definition at line 38 of file complexI.H.

◆ complex() [4/8]

constexpr complex ( const scalar  r)
inlineexplicitconstexprnoexcept

Construct from real component.

Definition at line 45 of file complexI.H.

◆ complex() [5/8]

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

Construct from real and imaginary parts.

Definition at line 52 of file complexI.H.

◆ complex() [6/8]

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

Construct from std::complex.

Definition at line 59 of file complexI.H.

◆ complex() [7/8]

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

Construct from std::complex.

Definition at line 66 of file complexI.H.

◆ complex() [8/8]

complex ( Istream is)
explicit

Construct from Istream.

Definition at line 68 of file complex.C.

Member Function Documentation

◆ real() [1/2]

constexpr scalar real ( ) const
inlineconstexpr

Real part of complex number - STL naming.

Definition at line 124 of file complex.H.

◆ imag() [1/2]

constexpr scalar imag ( ) const
inlineconstexpr

Imaginary part of complex number - STL naming.

Definition at line 130 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, and Foam::val.

◆ imag() [2/2]

void imag ( scalar  val)
inline

Set imaginary part of complex number - STL naming.

Definition at line 81 of file complexI.H.

References Foam::val.

◆ 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

Conversion to std::complex.

Definition at line 169 of file complex.H.

◆ operator=() [1/3]

void operator= ( const complex c)
inline

Copy assignment.

Definition at line 119 of file complexI.H.

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

◆ operator=() [2/3]

void operator= ( const Foam::zero  )
inline

Assign zero.

Definition at line 126 of file complexI.H.

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

◆ operator=() [3/3]

void operator= ( const scalar  s)
inline

Assign scalar (imag = zero)

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 140 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 147 of file complexI.H.

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

◆ operator-=() [1/2]

void operator-= ( const complex c)
inline

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

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

◆ operator*=() [1/2]

void operator*= ( const complex c)
inline

Definition at line 166 of file complexI.H.

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

◆ operator*=() [2/2]

void operator*= ( const scalar  s)
inline

Definition at line 172 of file complexI.H.

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

◆ operator/=() [1/2]

void operator/= ( const complex c)
inline

Definition at line 179 of file complexI.H.

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

◆ operator/=() [2/2]

void operator/= ( const scalar  s)
inline

Definition at line 185 of file complexI.H.

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

◆ operator==()

bool operator== ( const complex c) const
inline

Definition at line 192 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 198 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 217 of file complexI.H.

◆ mag

scalar mag ( const complex c)
friend

Definition at line 223 of file complexI.H.

◆ sqr

complex sqr ( const complex c)
friend

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

◆ max

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

Definition at line 259 of file complexI.H.

◆ limit

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

Definition at line 270 of file complexI.H.

◆ sum

const friend complex& sum ( const complex c)
friend

Definition at line 276 of file complexI.H.

◆ operator- [1/4]

complex operator- ( const complex c)
friend

Definition at line 292 of file complexI.H.

◆ operator+ [1/3]

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

Definition at line 298 of file complexI.H.

◆ operator+ [2/3]

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

Definition at line 308 of file complexI.H.

◆ operator+ [3/3]

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

Definition at line 314 of file complexI.H.

◆ operator- [2/4]

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

Definition at line 320 of file complexI.H.

◆ operator- [3/4]

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

Definition at line 330 of file complexI.H.

◆ operator- [4/4]

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

Definition at line 336 of file complexI.H.

◆ operator* [1/3]

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

Definition at line 342 of file complexI.H.

◆ operator* [2/3]

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

Definition at line 352 of file complexI.H.

◆ operator* [3/3]

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

Definition at line 358 of file complexI.H.

◆ operator/ [1/3]

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

Definition at line 364 of file complexI.H.

◆ operator/ [2/3]

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

Definition at line 376 of file complexI.H.

◆ operator/ [3/3]

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

Definition at line 382 of file complexI.H.


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