HILA
Loading...
Searching...
No Matches
cmplx.h File Reference

Definition of Complex types. More...

#include "plumbing/defs.h"
Include dependency graph for cmplx.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Complex< T >
 Complex definition. More...
 
class  Imaginary_t< T >
 Imaginary type, used to represent purely imaginary numbers. More...
 
struct  hila::is_complex_or_arithmetic< T >
 hila::is_complex_or_arithmetic<T>::value More...
 

Namespaces

namespace  hila
 Invert diagonal + const. matrix using Sherman-Morrison formula.
 

Functions

template<typename T >
abs (const Complex< T > &a)
 Return absolute value of Complex number.
 
template<typename T >
arg (const Complex< T > &a)
 Return argument of Complex number.
 
template<typename T >
Complex< T > conj (const Complex< T > &val)
 Return conjugate of Complex number.
 
template<typename T >
Complex< T > dagger (const Complex< T > &val)
 Return dagger of Complex number.
 
constexpr Imaginary_t< double > I (1.0)
 Imaginary unit I - global variable.
 
template<typename T >
imag (const Complex< T > &a)
 Retrun imaginary value of Complex number.
 
template<typename T >
std::ostream & operator<< (std::ostream &strm, const Complex< T > &A)
 Print a complex value as (re,im)
 
template<typename T >
Complex< T > polar (T r, T arg)
 Return complex number given by polar representation.
 
template<typename T >
std::string hila::prettyprint (const Complex< T > &A, int prec=8)
 Return well formatted Complex number as std::string.
 
template<typename T >
real (const Complex< T > &a)
 Return real value of Complex number.
 
template<typename T >
auto squarenorm (const Complex< T > &val)
 Return Squarenorm of Complex number.
 
template<typename T >
std::string hila::to_string (const Complex< T > &A, int prec=8, char separator=' ')
 Return Complex number as std::string.
 

Detailed Description

Definition of Complex types.

This file contains definitions and methods for Complex numbers and Imaginary type.

‍NOTE: All overloads for operators +,-,/,* are not documented separately since there exists a function for each combinations of scalar,imaginary and complex number representations. All versions are documented in the ComplexComplex definitions.

Definition in file cmplx.h.

Function Documentation

◆ abs()

template<typename T >
T abs ( const Complex< T > &  a)
inline

Return absolute value of Complex number.

Wrapper around Complex::abs

Template Parameters
TArithmetic type of a
Parameters
aComplex number to get abs from
Returns
T

Definition at line 1322 of file cmplx.h.

◆ arg()

template<typename T >
T arg ( const Complex< T > &  a)
inline

Return argument of Complex number.

Wrapper around Complex::arg

Template Parameters
TArithmetic type of a
Parameters
aComplex number to get arg from
Returns
T

Definition at line 1334 of file cmplx.h.

◆ conj()

template<typename T >
Complex< T > conj ( const Complex< T > &  val)
inline

Return conjugate of Complex number.

Wrapper around Complex::conj

Template Parameters
TArithmetic type of a
Parameters
aComplex number to get conjugate from
Returns
Complex<T>

Definition at line 1346 of file cmplx.h.

◆ dagger()

template<typename T >
Complex< T > dagger ( const Complex< T > &  val)
inline

Return dagger of Complex number.

Wrapper around Complex::conj

Template Parameters
TArithmetic type of a
Parameters
aComplex number to get conjugate from
Returns
Complex<T>

Definition at line 1358 of file cmplx.h.

◆ I()

constexpr Imaginary_t< double > I ( 1.  0)
constexpr

Imaginary unit I - global variable.

Don't use #define'd I : this will conflict with some headers in rocm

For some reason it is sufficient to use only device

◆ imag()

template<typename T >
T imag ( const Complex< T > &  a)
inline

Retrun imaginary value of Complex number.

Wrapper around Complex::imag

Template Parameters
TArithmetic type of a
Parameters
aComplex number to get imaginary value from
Returns
T

Definition at line 890 of file cmplx.h.

◆ operator<<()

template<typename T >
std::ostream & operator<< ( std::ostream &  strm,
const Complex< T > &  A 
)

Print a complex value as (re,im)

Stream operator

Print Complex number as "A.re A.im"

Template Parameters
TArithmetic type of A
Parameters
strm
AComplex number to print
Returns
std::ostream&

Definition at line 1388 of file cmplx.h.

◆ polar()

template<typename T >
Complex< T > polar ( r,
arg 
)

Return complex number given by polar representation.

Same as Complex::polar

Template Parameters
TArithmetic type r and arg
Parameters
rRadial component of Complex number
argArgument of Complex number
Returns
Complex<T>

Definition at line 903 of file cmplx.h.

◆ real()

template<typename T >
T real ( const Complex< T > &  a)
inline

Return real value of Complex number.

Wrapper around Complex::real

Template Parameters
TArithmetic type of a
Parameters
aComplex number to get real value from
Returns
T

Definition at line 878 of file cmplx.h.

◆ squarenorm()

template<typename T >
auto squarenorm ( const Complex< T > &  val)
inline

Return Squarenorm of Complex number.

Wrapper around Complex::squarenorm

Template Parameters
TArithmetic type of a
Parameters
aComplex number to compute squarenorm of
Returns
T

Definition at line 1370 of file cmplx.h.