HILA
Loading...
Searching...
No Matches
Complex<S>

User guide for custom HILA Complex class

The Complex class is a general representation of a Complex number where the real and imaginary components are store in Complex::re and Complex::im.

Construction, Assignment and Access

NOTE: Construction and assignment is possible only when the assignable values type is compatible with the type S of the Complex<S> variable.

The multiple ways of constructing, assigning and accessing a Complex object can be viewed on the Object documentation page

A simple example of constructing a Complex object is as follows:

Complex<MyType> C(1,1); // Constructor which assigns both (real,imaginary) values
Complex<MyType> B; // Constructor by default assigns to both (real=0,imaginary=0)
B = C; // Complex Assignment copies both real and imaginary values
B = 1; // Scalar assignment will assign only the real component
Complex definition.
Definition cmplx.h:50

Accessing the real and complex components of a Complex type can be done by either accessing the components directly

hila::out0 << C.re << " " << C.im;
std::ostream out0
This writes output only from main process (node 0)

or by using the std like accessors

hila::out0 << C.real() << " " << C.imag();

Mathematical methods

The arithmetic methods and arithmetic assignment methods hold allot of overloads depending on specific objects they are called for. All cases are documented and should be listed in order on the class page. These can be seen by following the links below.

Standard arithmetic methods

The following standard arithmetic methods are defined in the usual way for Complex numbers.

Arithmetic assignment methods

Arithmetic increment operators

Comparison operators

Mathematical functions

Random number generators

There are two random number generators available for the Complex type.

Uniform distribution:

Complex< T > & random()
Assign random values to Complex real and imaginary part.
Definition cmplx.h:358

Gaussian distribution:

Complex< T > & gaussian_random(double width=1.0)
Produces complex gaussian random values.
Definition cmplx.h:371

More detailed description on the functionality for both functions can be read on the Class page.