HILA
|
Imaginary type, used to represent purely imaginary numbers. More...
#include <cmplx.h>
Public Member Functions | |
T | abs () const |
Compute absolute value of Complex number. | |
T | 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. | |
T | 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. | |
T | real () const |
Real part of Complex number. | |
T | 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 | |
| |
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)\) | |
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
T | type of imaginary (float/double) |
|
inlineinherited |
|
inlineinherited |
Compute dagger of Complex number.
Alias to Complex::conj
\begin{align} z^* = z^\dagger \end{align}
|
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
width | gaussian_random |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Multiply add with Complex numbers.
Defined as
T | Arithmetic type of a,b and c |
a | Complex number to multiply |
b | Complex number to multiply |
c | Complex number to add to result of multiplication |
|
inlineinherited |
Compare non-equality of Scalar and Complex number.
Negation of operator==()
A | Arithmetic type of a |
B | Arithmetic type of b |
a | Scalar to compare |
b | Complex number to compare |
|
inlineinherited |
Compare non-equality of Complex number and Scalar.
Negation of operator==()
A | Arithmetic type of a |
B | Arithmetic type of b |
a | Complex number to compare |
b | Scalar to compare |
|
inlineinherited |
Compare non-equality of two complex numbers.
Negation of operator==()
A | Arithmetic type of a |
B | Arithmetic type of b |
|
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}
T | Arithmetic type of c |
A | Arithmetic type of a |
c | Complex number to multiply |
a | Scalar to multiply |
|
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}
T | Arithmetic type of c |
A | Arithmetic type of a |
c | Complex number to multiply |
a | Scalar to multiply |
|
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}
T1 | Arithmetic type of a |
T2 | Arithmetic type of b |
Tr | Resulting type after multiplication |
a | |
b |
|
inlineinherited |
Real multiply assign operator.
Multiply assign by real number to both components of Complex number
A | Type for real value a |
a | Real value to multiply |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
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}
T1 | Type for first complex number |
T2 | Type for second complex number |
Tr | Conversion type between T1 and T2 |
a | First complex number |
b | Second complex number |
Single increment operator.
Increments real part of Complex number
Multiple increment operator.
Increments real part of Complex number
|
inlineinherited |
Real addition assignment operator.
Add assign only to real part of Complex number
A | Type for real value a |
a | Real value to add |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
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}
T1 | Arithmetic type of a |
T2 | Arithmetic type of b |
Tr | Resulting type after subtraction |
a | First complex number |
b | Second complex number to subtract |
Single decrement operator.
Decrement real part of Complex number
Multiple decrement operator.
Decrement real part of Complex number
|
inlineinherited |
Real subtraction assignment operator Subtract assign only to real part of Complex number.
A | Type for real value a |
a | Real value to subtract |
|
inlineinherited |
|
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}
T | Arithmetic type of c |
A | Arithmetic type of a |
c | Complex number to divide |
a | Scalar to divide with |
|
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}
T | Arithmetic type of c |
A | Arithmetic type of a |
c | Complex number to divide |
a | Scalar to divide with |
|
inlineinherited |
|
inlineinherited |
Real divide assignment operator.
Divide assign by real number to both components of Complex number
A | Type for real value to divide |
a | Real value to divide |
|
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}
A | Type for Complex number divide |
lhs | Complex number to divide |
|
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.
A | Arithmetic type of a |
B | Arithmetic type of b |
b | Complex number to compare |
a | Scalar to compare |
|
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.
A | Arithmetic type of a |
B | Arithmetic type of b |
a | Complex number to compare |
b | Scalar to compare |
|
inlineinherited |
Compare equality of two complex numbersTwo numbers are equal, if the real and imaginary components are respectively equal.
A | Arithmetic type of a |
B | Arithmetic type of b |
Stores and returns Complex number given in polar coordinates.
\begin{align} z = r\cdot e^{i\theta} \end{align}
r | Radius of Complex number |
theta | Angle of complex number in radians |
Assign random values to Complex real and imaginary part.
Uses hila::random for both real and imaginary part
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
related |