HILA
Loading...
Searching...
No Matches
Imaginary_t< T > Class Template Reference

Imaginary type, used to represent purely imaginary numbers. More...

#include <cmplx.h>

Inheritance diagram for Imaginary_t< T >:
Collaboration diagram for Imaginary_t< T >:

Public Member Functions

real () const
 Real part of Complex number.
 
imag () const
 Imaginary part of Complex number.
 
squarenorm () const
 Compute square norm of Complex number.
 
abs () const
 Compute absolute value of Complex number.
 
arg () const
 Compute argument of Complex number.
 
Complex< T > conj () const
 Compute conjugate of Complex number.
 
Complex< T > dagger () const
 Compute dagger of Complex number.
 
Complex< T > polar (const T r, const T theta)
 Stores and returns Complex number given in polar coordinates.
 
Complex< T > & random ()
 Assign random values to Complex real and imaginary part.
 
Complex< T > & gaussian_random (double width=1.0)
 Produces complex gaussian random values.
 
template<typename A >
Complex< T > & operator+= (const Complex< A > &lhs) &
 += addition assignment operator
 
template<typename A >
Complex< T > & operator-= (const Complex< A > &lhs) &
 -= subtraction assignment operator
 
template<typename A >
Complex< T > & operator*= (const Complex< A > &lhs) &
 *= multiply assignment operator
 
template<typename A >
Complex< T > & operator/= (const Complex< A > &lhs) &
 /= divide assignment operator
 
Complex< T > & operator++ ()
 ++ increment operator
 
Complex< T > & operator-- ()
 – decrement operator
 
template<typename A >
Complex< T > conj_mul (const Complex< A > &b) const
 Conjugate multiply method.
 
template<typename A >
Complex< T > mul_conj (const Complex< A > &b) const
 Multiply conjugate method.
 

Detailed Description

template<typename T>
class Imaginary_t< T >

Imaginary type, used to represent purely imaginary numbers.

Useful for reducing multiply operations in im * complex or im * real -ops Derived from Complex class, so generic complex ops should remain valid Defines only operators * and /, others go via Complex class

Note: Imaginary_t should NOT be used in Field variables

Template Parameters
Ttype of imaginary (float/double)

Definition at line 1307 of file cmplx.h.

Member Function Documentation

◆ abs()

template<typename T >
T Complex< T >::abs ( ) const
inlineinherited

Compute absolute value of Complex number.

Essentially sqrt(squarenorm(z)):

\begin{align} |z| = \sqrt{\Re(z)^2 + \Im(z)^2}\end{align}

Returns
T

Definition at line 259 of file cmplx.h.

◆ arg()

template<typename T >
T Complex< T >::arg ( ) const
inlineinherited

Compute argument of Complex number.

\begin{align} \arg(z) = \arctan2(\Im(z)),\Re(z)\end{align}

Returns
T

Definition at line 270 of file cmplx.h.

◆ conj()

template<typename T >
Complex< T > Complex< T >::conj ( ) const
inlineinherited

Compute conjugate of Complex number.

\begin{align} z &= x + i\cdot y \\ \Rightarrow z^* &= x - i\cdot y\end{align}

Returns
Complex<T>

Definition at line 282 of file cmplx.h.

◆ conj_mul()

template<typename T >
template<typename A >
Complex< T > Complex< T >::conj_mul ( const Complex< A > &  b) const
inlineinherited

Conjugate multiply method.

Conjugate a (*this) and multiply with give argument b: a.conj_mul(b) \( \equiv a^* \cdot b\)

Template Parameters
AType for Complex number b
Parameters
bnumber to multiply with
Returns
Complex<T>

Definition at line 611 of file cmplx.h.

◆ dagger()

template<typename T >
Complex< T > Complex< T >::dagger ( ) const
inlineinherited

Compute dagger of Complex number.

Alias to Complex::conj

\begin{align} z^* = z^\dagger \end{align}

Returns
Complex<T>

Definition at line 293 of file cmplx.h.

◆ gaussian_random()

template<typename T >
Complex< T > & Complex< T >::gaussian_random ( double  width = 1.0)
inlineinherited

Produces complex gaussian random values.

Uses hila::gaussrand2 for both real and imaignary part Assigns same random value for both real and imaginary part

Parameters
widthgaussian_random
Returns
Complex<T>&

Definition at line 338 of file cmplx.h.

◆ imag()

template<typename T >
T Complex< T >::imag ( ) const
inlineinherited

Imaginary part of Complex number.

Overloads exist for pass by value and pass by reference for when Complex is defined as non-const or const

Returns
T Imaginary part

Definition at line 177 of file cmplx.h.

◆ mul_conj()

template<typename T >
template<typename A >
Complex< T > Complex< T >::mul_conj ( const Complex< A > &  b) const
inlineinherited

Multiply conjugate method.

Multiply a (*this) with conjugate of given argument b: a.mul_conj(b) \( \equiv a \cdot b^*\)

Template Parameters
AType for Complex number b
Parameters
bnumber to conjugate and multiply withv
Returns
Complex<T>

Definition at line 627 of file cmplx.h.

◆ operator*=()

template<typename T >
template<typename A >
Complex< T > & Complex< T >::operator*= ( const Complex< A > &  lhs) &
inlineinherited

*= multiply assignment operator

Multiply assignment for Complex numbers can be performed in the following ways

Complex multiply assign:

Standard Complex number multiplication

\begin{align}z &= x + iy, w = x' + iy' \\ z w &= (x + iy)(x' + iy') = (xx'-yy') + i(xy' + yx')\end{align}

//
// z,w get values
//
z*=w; // z = zw as defined above
Complex definition.
Definition cmplx.h:56

Real multiply assign:

Multiply assign by real number to both components of Complex number

z *= 2; // z.re = 2, z.im = 2

Definition at line 475 of file cmplx.h.

◆ operator++()

template<typename T >
Complex< T > & Complex< T >::operator++ ( )
inlineinherited

++ increment operator

Increments real part of Complex number

z++; // z.re = 2, z.im = 1
Returns
Complex<T>&

Definition at line 557 of file cmplx.h.

◆ operator+=()

template<typename T >
template<typename A >
Complex< T > & Complex< T >::operator+= ( const Complex< A > &  lhs) &
inlineinherited

+= addition assignment operator

Addition assignment for Complex numbers can be performed in the following ways

Complex addition assignment:

z += w; // z.re = 1, z.im = 1

Real addition assignment:

Add assign only to real part of Complex number

z += 1; // z.re = 1, z.im = 0

Definition at line 391 of file cmplx.h.

◆ operator--()

template<typename T >
Complex< T > & Complex< T >::operator-- ( )
inlineinherited

– decrement operator

Decrement real part of Complex number

z--; // z.re = 0, z.im = 1
Returns
Complex<T>&

Definition at line 574 of file cmplx.h.

◆ operator-=()

template<typename T >
template<typename A >
Complex< T > & Complex< T >::operator-= ( const Complex< A > &  lhs) &
inlineinherited

-= subtraction assignment operator

Subtraction assignment for Complex numbers can be performed in the following ways

Complex subtract assign:

z -= w; // z.re = -1, z.im = -1

Real subtract assign:

Subtract assign only to real part of Complex number

z -= 1; // z.re = -1, z.im = 0

Definition at line 427 of file cmplx.h.

◆ operator/=()

template<typename T >
template<typename A >
Complex< T > & Complex< T >::operator/= ( const Complex< A > &  lhs) &
inlineinherited

/= divide assignment operator

Divide assignment for Complex numbers can be performed in the following ways

Complex divide assign:

Standard Complex number division

\begin{align}z &= x + iy, w = x' + iy' \\ \frac{z}{w} &= \frac{x + iy}{x' + iy'} = \frac{(xx'+ yy') + i( yx' - xy')}{|w|^2}\end{align}

//
// z,w get values
//
z/=w; // z = z/w as defined above

Real divide assign:

Divide assign by real number to both components of Complex number

z /= 2; // z.re = 1, z.im = 1

Definition at line 527 of file cmplx.h.

◆ polar()

template<typename T >
Complex< T > Complex< T >::polar ( const T  r,
const T  theta 
)
inlineinherited

Stores and returns Complex number given in polar coordinates.

\begin{align} z = r\cdot e^{i\theta} \end{align}

double r = 1;
double theta = 3.14159265358979/2; // pi/2
c.polar(r,theta); // c.re = 0, c.im = 1
Complex< T > polar(const T r, const T theta)
Stores and returns Complex number given in polar coordinates.
Definition cmplx.h:313
Parameters
rRadius of Complex number
thetaAngle of complex number in radians
Returns
Complex<T> Complex number

Definition at line 313 of file cmplx.h.

◆ random()

template<typename T >
Complex< T > & Complex< T >::random ( )
inlineinherited

Assign random values to Complex real and imaginary part.

Uses hila::random for both real and imaginary part

Returns
Complex<T>&

Definition at line 325 of file cmplx.h.

◆ real()

template<typename T >
T Complex< T >::real ( ) const
inlineinherited

Real part of Complex number.

Overloads exist for pass by value and pass by reference for when Complex is defined as non-const or const

Returns
T Real part

Definition at line 165 of file cmplx.h.

◆ squarenorm()

template<typename T >
T Complex< T >::squarenorm ( ) const
inlineinherited

Compute square norm of Complex number.

\begin{align} |z|^2 = \Re(z)^2 + \Im(z)^2\end{align}

Returns
T Squared norm

Definition at line 248 of file cmplx.h.


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