Complex< T > Class Template Reference Math Library

#include <complex.h>

详细描述

template<typename T>
class maxon::Complex< T >

A complex number is a number that can be expressed in the form a + bi, where a and b are real numbers and i is the imaginary unit, that satisfies the equation x2 = -1, that is, i2 = -1.[1] In this expression, a is the real part and b is the imaginary part of the complex number.

Complex numbers extend the concept of the one-dimensional number line to the two-dimensional complex plane by using the horizontal axis for the real part and the vertical axis for the imaginary part. The complex number a + bi can be identified with the point (a, b) in the complex plane. A complex number whose real part is zero is said to be purely imaginary, whereas a complex number whose imaginary part is zero is a real number. In this way, the complex numbers contain the ordinary real numbers while extending them in order to solve problems that cannot be solved with real numbers alone.

Examples for using complex numbers are the famous Mandelbrot set or the Fourier Transform of a signal. In the latter case the imaginary part stores the phase information.

公共成员函数

  Complex ()
MAXON_IMPLICIT   Complex (const T real )
MAXON_IMPLICIT   Complex (const T real , const T imag )
const Complex operator+= (const Complex &c)
const Complex operator-= (const Complex &c)
const Complex operator*= (const Complex &c)
Complex   operator+ (const Complex &c) const
Complex   operator- (const Complex &c) const
Complex   operator* (const Complex &c) const
Complex   operator* (const T s) const
void  SetLength (const T len)
void  SetPhase (const T phase)
void  SetPolar (const T len, const T phase)
void  SetExp (const T x)
GetSquaredLength () const
GetLength () const
GetPhase () const
Complex   GetNormalized () const
Complex   GetConjugate () const
Complex   GetSqrt () const
Result < Complex GetLog () const
Result < Complex GetDivision (const Complex &divisor) const
String   ToString (const FormatStatement *formatStatement=nullptr) const
  MAXON_OPERATOR_EQUALITY_HASHCODE ( Complex , real , imag )

静态公共成员函数

static Result < void >  DescribeIO (const DataSerializeInterface &stream)

Public Attributes

real
imag

Friends

Complex   operator* (const T s, const Complex &c)

构造函数 & 析构函数文档编制

◆  Complex() [1/3]

Complex

Creates a Complex initialized with default values (all components 0.0).

◆  Complex() [2/3]

Complex ( const T  real )

Creates a Complex initialized with given real and default ( = 0.0) imaginary values.

◆  Complex() [3/3]

Complex ( const T  real ,
const T  imag  
)

Creates a Complex initialized with given real and imaginary values.

成员函数文档编制

◆  operator+=()

const Complex < T > & operator+= ( const Complex < T > &  c )

Adds two Complex numbers.

◆  operator-=()

const Complex < T > & operator-= ( const Complex < T > &  c )

Subtracts two Complex numbers.

◆  operator*=()

const Complex < T > & operator*= ( const Complex < T > &  c )

Multiplies two Complex operations.

◆  operator+()

Complex < T > operator+ ( const Complex < T > &  c ) const

Adds two Complex numbers.

◆  operator-()

Complex < T > operator- ( const Complex < T > &  c ) const

Subtracts two Complex numbers.

◆  operator*() [1/2]

Complex < T > operator* ( const Complex < T > &  c ) const

Multiplies two Complex numbers.

◆  operator*() [2/2]

Complex < T > operator* ( const T  s ) const

Scales the Complex .

◆  SetLength()

void SetLength ( const T  len )

Set polar length (magnitude) in the Argand plane.

◆  SetPhase()

void SetPhase ( const T  phase )

Set polar phase (angle) in the Argand plane.

◆  SetPolar()

void SetPolar ( const T  len ,
const T  phase  
)

初始化 Complex number by given polar coordinates.

◆  SetExp()

void SetExp ( const T  x )

set Complex number according to e^(i*x)

◆  GetSquaredLength()

T GetSquaredLength

Computes the squared magnitude/length/norm in the Argand plane.

返回
length

◆  GetLength()

T GetLength

Computes the magnitude/length/norm in the Argand plane.

返回
length

◆  GetPhase()

T GetPhase

Computes the angle of the complex vector in the Argand plane.

返回
phase

◆  GetNormalized()

Complex < T > GetNormalized

Get a complex vector with normalized length in the Argand plane.

返回
normalized complex vector

◆  GetConjugate()

Complex < T > GetConjugate

Get the complex conjugate of a complex vector

返回
complex conjugate

◆  GetSqrt()

Complex < T > GetSqrt

Compute the square root.

返回
square root of vector

◆  GetLog()

Result < Complex < T > > GetLog

Compute the natural logarithm.

返回
Log of complex vector. Returns an error if length of vector is zero

◆  GetDivision()

Result < Complex < T > > GetDivision ( const Complex < T > &  divisor ) const

Divides the complex value by another complex value.

参数
[in] divisor divisor
返回
The divided result. Returns an error if divisor is zero.

◆  ToString()

String ToString ( const FormatStatement formatStatement = nullptr ) const

Returns a readable string of the content.

参数
[in] formatStatement Nullptr or additional formatting instruction. See also Formatting Floating point values .
返回
The converted result.

◆  DescribeIO()

Result < void > DescribeIO ( const DataSerializeInterface stream )
static

Describe all elements of this class for I/O operations.

参数
[in] stream The stream that is used to register the class members.
返回
OK on success.

◆  MAXON_OPERATOR_EQUALITY_HASHCODE()

MAXON_OPERATOR_EQUALITY_HASHCODE ( Complex < T >  ,
real   ,
imag    
)

Friends And Related Function Documentation

◆  operator*

Complex operator* ( const T  s ,
const Complex < T > &  c  
)
friend

Scales the components of a Complex .

Member Data Documentation

◆  real

T real

real part

◆  imag

T imag

imaginary part