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

abs () const
 Compute absolute value of Complex number.
 
arg () const
 Compute argument of Complex number.
 
Complex< T > conj () const
 Compute conjugate of Complex number.
 
template<typename A >
Complex< T > conj_mul (const Complex< A > &b) const
 Conjugate multiply method.
 
Complex< T > dagger () const
 Compute dagger of Complex number.
 
Complex< T > & gaussian_random (double width=1.0)
 Produces complex gaussian random values.
 
T & imag ()
 Imaginary part of Complex number.
 
imag () const
 Imaginary part of Complex number.
 
template<typename T >
Complex< T > mul_add (const Complex< T > &a, const Complex< T > &b, const Complex< T > &c)
 Multiply add with Complex numbers.
 
template<typename A >
Complex< T > mul_conj (const Complex< A > &b) const
 Multiply conjugate method.
 
template<typename A , typename B , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
bool operator!= (const A a, const Complex< B > &b)
 Compare non-equality of Scalar and Complex number.
 
template<typename A , typename B , std::enable_if_t< hila::is_arithmetic< B >::value, int > = 0>
bool operator!= (const Complex< A > &a, const B b)
 Compare non-equality of Complex number and Scalar.
 
template<typename A , typename B >
bool operator!= (const Complex< A > &a, const Complex< B > &b)
 Compare non-equality of two complex numbers.
 
template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator* (const A &a, const Complex< T > &c)
 Multiplication operator Scalar * Complex.
 
template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator* (const Complex< T > &c, const A &a)
 Multiplication operator Complex * Scalar.
 
template<typename T1 , typename T2 , typename Tr = hila::type_mul<T1, T2>>
Complex< Tr > operator* (const Complex< T1 > &a, const Complex< T2 > &b)
 Multiplication operator Complex * Complex.
 
template<typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
Complex< T > & operator*= (const A a)
 Real multiply assign operator.
 
template<typename A >
Complex< T > & operator*= (const Complex< A > &lhs)
 Complex multiply assignment operator.
 
template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator+ (const A &a, const Complex< T > &c)
 Addition operator Scalar + Complex.
 
template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator+ (const Complex< T > &c, const A &a)
 Addition operator Complex + Scalar.
 
template<typename T1 , typename T2 , typename Tr = hila::type_plus<T1, T2>>
Complex< Tr > operator+ (const Complex< T1 > &a, const Complex< T2 > &b)
 Addition operator Complex + Complex.
 
Complex< T > & operator++ ()
 Single increment operator.
 
Complex< T > operator++ (int)
 Multiple increment operator.
 
template<typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
Complex< T > & operator+= (const A &a)
 Real addition assignment operator.
 
template<typename A >
Complex< T > & operator+= (const Complex< A > &lhs)
 Complex addition assignment operator.
 
template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator- (const A &a, const Complex< T > &c)
 Subtraction operator Scalar - Complex.
 
template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator- (const Complex< T > &c, const A &a)
 Subtraction operator Complex - Scalar.
 
template<typename T1 , typename T2 , typename Tr = hila::type_plus<T1, T2>>
Complex< Tr > operator- (const Complex< T1 > &a, const Complex< T2 > &b)
 Subtraction operator Complex - Complex.
 
Complex< T > & operator-- ()
 Single decrement operator.
 
Complex< T > operator-- (int)
 Multiple decrement operator.
 
template<typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
Complex< T > & operator-= (const A &a)
 Real subtraction assignment operator Subtract assign only to real part of Complex number.
 
template<typename A >
Complex< T > & operator-= (const Complex< A > &lhs)
 Complex subtraction assignment operator.
 
template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator/ (const A &a, const Complex< T > &c)
 Division operator Scalar / Complex.
 
template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator/ (const Complex< T > &c, const A &a)
 Division operator Complex / Scalar.
 
template<typename T1 , typename T2 , typename Tr = hila::type_mul<T1, T2>>
Complex< Tr > operator/ (const Complex< T1 > &a, const Complex< T2 > &b)
 Division operator Complex / Complex.
 
template<typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
Complex< T > & operator/= (const A &a)
 Real divide assignment operator.
 
template<typename A >
Complex< T > & operator/= (const Complex< A > &lhs)
 Complex divide assignment operator.
 
template<typename A , typename B , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
bool operator== (const A a, const Complex< B > &b)
 Compare equality of Scalar and Complex.
 
template<typename A , typename B , std::enable_if_t< hila::is_arithmetic< B >::value, int > = 0>
bool operator== (const Complex< A > &a, const B b)
 Compare equality of Complex and scalar.
 
template<typename A , typename B >
bool operator== (const Complex< A > &a, const Complex< B > &b)
 Compare equality of two complex numbersTwo numbers are equal, if the real and imaginary components are respectively equal.
 
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.
 
T & real ()
 Real part of Complex number.
 
real () const
 Real part of Complex number.
 
squarenorm () const
 Compute square norm of Complex number.
 

Related Symbols

(Note that these are not member symbols.)

constexpr Imaginary_t< double > operator""_i (long double a)
 
Mathematical functions
Returns
Complex T
template<typename T >
Complex< T > exp (const Complex< T > z)
 \(\exp(z)\)
 
template<typename T >
Complex< T > exp (const Imaginary_t< T > im)
 \(\exp(\Im(z))\)
 
template<typename T , std::enable_if_t< hila::is_arithmetic< T >::value, int > = 0>
Complex< T > expi (T a)
 \(\exp(i\cdot x)\)
 
template<typename T >
Complex< T > log (Complex< T > z)
 \(\log{z}\)
 
template<typename T >
Complex< T > sqrt (Complex< T > z)
 \(\sqrt{z}\)
 
template<typename T >
Complex< T > cbrt (Complex< T > z)
 \(\sqrt[3]{z}\)
 
template<typename A , typename B >
auto pow (Complex< A > z, Complex< B > p)
 pow(z.p) = \(z^p\) = \(exp(p*log(z))\)
 
template<typename T , typename S , std::enable_if_t< hila::is_arithmetic< S >::value, int > = 0>
Complex< T > pow (Complex< T > z, S p)
 pow(z.p) with scalar power
 
template<typename T , typename S , std::enable_if_t< hila::is_arithmetic< S >::value, int > = 0>
Complex< T > pow (S z, Complex< T > p)
 pow(z.p) with scalar base
 
template<typename T >
Complex< T > sin (Complex< T > z)
 
template<typename T >
Complex< T > cos (Complex< T > z)
 
template<typename T >
Complex< T > tan (Complex< T > z)
 \(\tan(z) = \frac{\sin(z)}{\cos(z)}\) - rely on optimizer to simplify
 
template<typename T >
Complex< T > sinh (Complex< T > z)
 
template<typename T >
Complex< T > cosh (Complex< T > z)
 
template<typename T >
Complex< T > tanh (Complex< T > z)
 \(\tanh(z)\)
 
template<typename T >
Complex< T > atan (Complex< T > z)
 \(\arctan(z)\)
 
template<typename T >
Complex< T > asin (Complex< T > z)
 \(\arcsin(z)\)
 
template<typename T >
Complex< T > acos (Complex< T > z)
 \(\arccos(z)\)
 
template<typename T >
Complex< T > atanh (Complex< T > z)
 \(\text{artanh}(z)\)
 
template<typename T >
Complex< T > asinh (Complex< T > z)
 \(\text{arsinh}(z)\)
 
template<typename T >
Complex< T > acosh (Complex< T > z)
 \(\text{arcosh}(z)\)
 

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 be used in Field variables

Template Parameters
Ttype of imaginary (float/double)

Definition at line 1442 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 292 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 303 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 315 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 698 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 326 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 371 of file cmplx.h.

◆ imag() [1/2]

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

Imaginary part of Complex number.

Pass by reference

Returns
T & Imaginary part

Definition at line 194 of file cmplx.h.

◆ imag() [2/2]

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

Imaginary part of Complex number.

Pass by value if Complex number is defined as const

Returns
T Imaginary part

Definition at line 175 of file cmplx.h.

◆ mul_add()

template<typename T >
Complex< T > mul_add ( const Complex< T > &  a,
const Complex< T > &  b,
const Complex< T > &  c 
)
inlineinherited

Multiply add with Complex numbers.

Defined as

mul_add(a,b,c) = a*b + c;
Complex< T > mul_add(const Complex< T > &a, const Complex< T > &b, const Complex< T > &c)
Multiply add with Complex numbers.
Definition cmplx.h:1184
Template Parameters
TArithmetic type of a,b and c
Parameters
aComplex number to multiply
bComplex number to multiply
cComplex number to add to result of multiplication
Returns
Complex<T>

Definition at line 1184 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 714 of file cmplx.h.

◆ operator!=() [1/3]

template<typename A , typename B , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
bool operator!= ( const A  a,
const Complex< B > &  b 
)
inlineinherited

Compare non-equality of Scalar and Complex number.

Negation of operator==()

Template Parameters
AArithmetic type of a
BArithmetic type of b
Parameters
aScalar to compare
bComplex number to compare
Returns
true if values are not arithmetically equal

Definition at line 1293 of file cmplx.h.

◆ operator!=() [2/3]

template<typename A , typename B , std::enable_if_t< hila::is_arithmetic< B >::value, int > = 0>
bool operator!= ( const Complex< A > &  a,
const B  b 
)
inlineinherited

Compare non-equality of Complex number and Scalar.

Negation of operator==()

Template Parameters
AArithmetic type of a
BArithmetic type of b
Parameters
aComplex number to compare
bScalar to compare
Returns
true if values are not arithmetically equal

Definition at line 1277 of file cmplx.h.

◆ operator!=() [3/3]

template<typename A , typename B >
bool operator!= ( const Complex< A > &  a,
const Complex< B > &  b 
)
inlineinherited

Compare non-equality of two complex numbers.

Negation of operator==()

Template Parameters
AArithmetic type of a
BArithmetic type of b
Parameters
aComplex number to compare
bComplex number to compare
Returns
true if values are not arithmetically equal

Definition at line 1261 of file cmplx.h.

◆ operator*() [1/3]

template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator* ( const A &  a,
const Complex< T > &  c 
)
inlineinherited

Multiplication operator Scalar * Complex.

Multiplication between Complex and scalar is defined in the usual way

\begin{align}z,z_1 &= x + iy \in \mathbb{C}, a \in \mathbb{R} \\ z * a &= (x\cdot a + iy\cdot a)\end{align}

z = a * z_1;
Template Parameters
TArithmetic type of c
AArithmetic type of a
Parameters
cComplex number to multiply
aScalar to multiply
Returns
auto

Definition at line 1094 of file cmplx.h.

◆ operator*() [2/3]

template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator* ( const Complex< T > &  c,
const A &  a 
)
inlineinherited

Multiplication operator Complex * Scalar.

Multiplication between Complex and scalar is defined in the usual way

\begin{align}z,z_1 &= x + iy \in \mathbb{C}, a \in \mathbb{R} \\ z_1 * a &= (x\cdot a + iy\cdot a)\end{align}

z = z_1 * a;
Template Parameters
TArithmetic type of c
AArithmetic type of a
Parameters
cComplex number to multiply
aScalar to multiply
Returns
auto

Definition at line 1074 of file cmplx.h.

◆ operator*() [3/3]

template<typename T1 , typename T2 , typename Tr = hila::type_mul<T1, T2>>
Complex< Tr > operator* ( const Complex< T1 > &  a,
const Complex< T2 > &  b 
)
inlineinherited

Multiplication operator Complex * Complex.

Defined in the usual way

\begin{align}z, z_1 &= x + iy, z_2 = x' + iy' \in \mathbb{C} \\ z_1 z_2 &= (x + iy)(x' + iy') = (xx'-yy') + i(xy' + yx')\end{align}

z = z_1 * z_2;
Template Parameters
T1Arithmetic type of a
T2Arithmetic type of b
TrResulting type after multiplication
Parameters
a
b
Returns
Complex<Tr>

Definition at line 1054 of file cmplx.h.

◆ operator*=() [1/2]

template<typename T >
template<typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
Complex< T > & Complex< T >::operator*= ( const A  a)
inlineinherited

Real multiply assign operator.

Multiply assign by real number to both components of Complex number

z *= 2; // z.re = 2, z.im = 2
Complex definition.
Definition cmplx.h:50
Template Parameters
AType for real value a
Parameters
aReal value to multiply
Returns
Complex<T>&

Definition at line 541 of file cmplx.h.

◆ operator*=() [2/2]

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

Complex multiply assignment operator.

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
Template Parameters
AType for Complex number multiply
Parameters
lhsComplex number to multiply
Returns
Complex<T>&

Definition at line 521 of file cmplx.h.

◆ operator+() [1/3]

template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator+ ( const A &  a,
const Complex< T > &  c 
)
inlineinherited

Addition operator Scalar + Complex.

Defined in the usual way. \(z,z_1 \in \mathbb{C}, a \in \mathbb{R}\)

z = a + z_1;
Template Parameters
TArithmetic type of c
AArithmetic type of a
Parameters
aScalar to sum
cComplex number to sum
Returns
auto

Definition at line 973 of file cmplx.h.

◆ operator+() [2/3]

template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator+ ( const Complex< T > &  c,
const A &  a 
)
inlineinherited

Addition operator Complex + Scalar.

Defined in the usual way. \(z,z_1 \in \mathbb{C}, a \in \mathbb{R}\)

z = z_1 + a;
Template Parameters
TArithmetic type of c
AArithmetic type of a
Parameters
cComplex number to sum
aScalar to sum
Returns
auto

Definition at line 955 of file cmplx.h.

◆ operator+() [3/3]

template<typename T1 , typename T2 , typename Tr = hila::type_plus<T1, T2>>
Complex< Tr > operator+ ( const Complex< T1 > &  a,
const Complex< T2 > &  b 
)
inlineinherited

Addition operator Complex + Complex.

Addition between Complex numbers is defined in the usual way:

\begin{align} z_1, z_2 &\in \mathbf{C} \\ z_1 + z_2 &= \Re(z_1) + \Re(z_2) + [\Im(z_1) + \Im(z_2)]i \end{align}

z = z_1 + z_2;
Template Parameters
T1Type for first complex number
T2Type for second complex number
TrConversion type between T1 and T2
Parameters
aFirst complex number
bSecond complex number
Returns
Complex<Tr>

Definition at line 936 of file cmplx.h.

◆ operator++() [1/2]

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

Single increment operator.

Increments real part of Complex number

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

Definition at line 619 of file cmplx.h.

◆ operator++() [2/2]

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

Multiple increment operator.

Increments real part of Complex number

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

Definition at line 653 of file cmplx.h.

◆ operator+=() [1/2]

template<typename T >
template<typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
Complex< T > & Complex< T >::operator+= ( const A &  a)
inlineinherited

Real addition assignment operator.

Add assign only to real part of Complex number

z += 1; // z.re = 1, z.im = 0
Template Parameters
AType for real value a
Parameters
aReal value to add
Returns
Complex<T>&

Definition at line 447 of file cmplx.h.

◆ operator+=() [2/2]

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

Complex addition assignment operator.

z += w; // z.re = 1, z.im = 1
Template Parameters
ATyppe of Complex number to add
Parameters
lhsComplex number to add
Returns
Complex<T>&

Definition at line 426 of file cmplx.h.

◆ operator-() [1/3]

template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator- ( const A &  a,
const Complex< T > &  c 
)
inlineinherited

Subtraction operator Scalar - Complex.

Defined in the usual way. \(z,z_1 \in \mathbb{C}, a \in \mathbb{R}\)

z = a - z_1;
Template Parameters
TArithmetic type of c
AArithmetic type of a
Parameters
aScalar
cComplex number to subtract
Returns
auto

Definition at line 1032 of file cmplx.h.

◆ operator-() [2/3]

template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator- ( const Complex< T > &  c,
const A &  a 
)
inlineinherited

Subtraction operator Complex - Scalar.

Defined in the usual way. \(z,z_1 \in \mathbb{C}, a \in \mathbb{R}\)

z = z_1 - a;
Template Parameters
TArithmetic type of c
AArithmetic type of a
Parameters
cComplex number
aScalar to subtract
Returns
auto

Definition at line 1014 of file cmplx.h.

◆ operator-() [3/3]

template<typename T1 , typename T2 , typename Tr = hila::type_plus<T1, T2>>
Complex< Tr > operator- ( const Complex< T1 > &  a,
const Complex< T2 > &  b 
)
inlineinherited

Subtraction operator Complex - Complex.

Subtraction between Complex numbers is defined in the usual way

\begin{align} z_1, z_2 &\in \mathbf{C} \\ z_1 - z_2 &= \Re(z_1) - \Re(z_2) + [\Im(z_1) - \Im(z_2)]i\end{align}

z = z_1 - z_2;
Template Parameters
T1Arithmetic type of a
T2Arithmetic type of b
TrResulting type after subtraction
Parameters
aFirst complex number
bSecond complex number to subtract
Returns
Complex<Tr>

Definition at line 996 of file cmplx.h.

◆ operator--() [1/2]

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

Single decrement operator.

Decrement real part of Complex number

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

Definition at line 636 of file cmplx.h.

◆ operator--() [2/2]

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

Multiple decrement operator.

Decrement real part of Complex number

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

Definition at line 672 of file cmplx.h.

◆ operator-=() [1/2]

template<typename T >
template<typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
Complex< T > & Complex< T >::operator-= ( const A &  a)
inlineinherited

Real subtraction assignment operator Subtract assign only to real part of Complex number.

z -= 1; // z.re = -1, z.im = 0
Template Parameters
AType for real value a
Parameters
aReal value to subtract
Returns
Complex<T>&

Definition at line 487 of file cmplx.h.

◆ operator-=() [2/2]

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

Complex subtraction assignment operator.

z -= w; // z.re = -1, z.im = -1
Template Parameters
AType for complex number to subtract
Parameters
lhsComplex number to subtract
Returns
Complex<T>&

Definition at line 467 of file cmplx.h.

◆ operator/() [1/3]

template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator/ ( const A &  a,
const Complex< T > &  c 
)
inlineinherited

Division operator Scalar / Complex.

Defined in the usual way

\begin{align} z,z_1=x + iy &\in \mathbb{C}, a \in \mathbb{R} \\ \frac{a}{z_1} &= \frac{az^*}{|z|^2} \end{align}

z = a / z_1;
Template Parameters
TArithmetic type of c
AArithmetic type of a
Parameters
cComplex number to divide
aScalar to divide with
Returns
auto

Definition at line 1164 of file cmplx.h.

◆ operator/() [2/3]

template<typename T , typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
auto operator/ ( const Complex< T > &  c,
const A &  a 
)
inlineinherited

Division operator Complex / Scalar.

Defined in the usual way

\begin{align}z, z_1=x + iy &\in \mathbb{C}, a \in \mathbb{R} \\ \frac{z_1}{a} &= \frac{x}{a} + i\cdot \frac{y}{a} \end{align}

z = z_1 / a;
Template Parameters
TArithmetic type of c
AArithmetic type of a
Parameters
cComplex number to divide
aScalar to divide with
Returns
auto

Definition at line 1143 of file cmplx.h.

◆ operator/() [3/3]

template<typename T1 , typename T2 , typename Tr = hila::type_mul<T1, T2>>
Complex< Tr > operator/ ( const Complex< T1 > &  a,
const Complex< T2 > &  b 
)
inlineinherited

Division operator Complex / Complex.

Defined in the usual way

\begin{align} z,z_1,z_2 &\in \mathbb{C} \\ \frac{z_1}{z_2} &= \frac{z_1\cdot z_2^{*}}{|z_2|^2} \end{align}

z =z_1 / z_2;
Template Parameters
T1Arithmetic type of a
T2Arithmetic type of b
TrResulting type after division
Parameters
aComplex number to divide
bComplex number to divide with
Returns
Complex<Tr>

Definition at line 1122 of file cmplx.h.

◆ operator/=() [1/2]

template<typename T >
template<typename A , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
Complex< T > & Complex< T >::operator/= ( const A &  a)
inlineinherited

Real divide assignment operator.

Divide assign by real number to both components of Complex number

z /= 2; // z.re = 1, z.im = 1
Template Parameters
AType for real value to divide
Parameters
aReal value to divide
Returns
Complex<T>&

Definition at line 598 of file cmplx.h.

◆ operator/=() [2/2]

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

Complex divide assignment operator.

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
Template Parameters
AType for Complex number divide
Parameters
lhsComplex number to divide
Returns
Complex<T>&

Definition at line 577 of file cmplx.h.

◆ operator==() [1/3]

template<typename A , typename B , std::enable_if_t< hila::is_arithmetic< A >::value, int > = 0>
bool operator== ( const A  a,
const Complex< B > &  b 
)
inlineinherited

Compare equality of Scalar and Complex.

Two numbers are equal, if the arithmetic values are equal: thus, complex and real comparison (a + i b) == a is true if b == 0.

Template Parameters
AArithmetic type of a
BArithmetic type of b
Parameters
bComplex number to compare
aScalar to compare
Returns
true if values compare to equal

Definition at line 1245 of file cmplx.h.

◆ operator==() [2/3]

template<typename A , typename B , std::enable_if_t< hila::is_arithmetic< B >::value, int > = 0>
bool operator== ( const Complex< A > &  a,
const B  b 
)
inlineinherited

Compare equality of Complex and scalar.

Two numbers are equal, if the arithmetic values are equal: thus, complex and real comparison (a + i b) == a is true if b == 0.

Template Parameters
AArithmetic type of a
BArithmetic type of b
Parameters
aComplex number to compare
bScalar to compare
Returns
true if values compare to equal

Definition at line 1226 of file cmplx.h.

◆ operator==() [3/3]

template<typename A , typename B >
bool operator== ( const Complex< A > &  a,
const Complex< B > &  b 
)
inlineinherited

Compare equality of two complex numbersTwo numbers are equal, if the real and imaginary components are respectively equal.

Template Parameters
AArithmetic type of a
BArithmetic type of b
Parameters
aComplex number to compare
bComplex number to compare
Returns
true if values compare to equal

Definition at line 1207 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:346
Parameters
rRadius of Complex number
thetaAngle of complex number in radians
Returns
Complex<T> Complex number

Definition at line 346 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 358 of file cmplx.h.

◆ real() [1/2]

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

Real part of Complex number.

Pass by reference

Returns
T & Real part

Definition at line 185 of file cmplx.h.

◆ real() [2/2]

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

Real part of Complex number.

Pass by value if Complex number is defined as const

Returns
T Real part

Definition at line 167 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 281 of file cmplx.h.

Friends And Related Symbol Documentation

◆ cos()

template<typename T >
Complex< T > cos ( Complex< T >  z)
related

\begin{align}\cos(z) &= \cos(\Re{z})\cos(i \Im(z)) - \sin(\Re{z})\sin(i \Im{z}) \\ &= \cos(\Re{z})\cosh(\Im(z)) - i \sin(\Re{z})\sinh(\Im(z))\end{align}

Definition at line 1621 of file cmplx.h.

◆ cosh()

template<typename T >
Complex< T > cosh ( Complex< T >  z)
related

cosh(z) = cosh(re)cosh(i im) - sinh(re)sinh(i im) = cosh(re)cos(im) - i sinh(re)sin(im)

Definition at line 1641 of file cmplx.h.

◆ operator""_i()

template<typename T >
constexpr Imaginary_t< double > operator""_i ( long double  a)
related

Operators to implement imaginary unit 1_i, enablig expressions 3 + 2_i etc. This is defined as an user-defined literal, which requires an underscore.

Definition at line 1695 of file cmplx.h.

◆ sin()

template<typename T >
Complex< T > sin ( Complex< T >  z)
related

\begin{align}sin(z) &= \sin(\Re(z) + i \Im(z)) \\ &= \sin(\Re(z))\cos(i \Im(z)) + \cos(\Re(z))\sin(i \Im(z)) \\ &= \sin(\Re(z)) \cosh(\Im(z)) + i \cos(\Re(z)) \sinh(\Im(z)) \end{align}

Definition at line 1614 of file cmplx.h.

◆ sinh()

template<typename T >
Complex< T > sinh ( Complex< T >  z)
related

sinh(z) = sinh(re)cosh(i im) + cosh(re)sinh(i im) = sinh(re)cos(im) + i cosh(re)sin(im)

Definition at line 1634 of file cmplx.h.


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