PSCF v1.4.0
Arithmetic Functions

Overloaded functions and function templates for arithmetic operations using built-in real types and/or C++ standard library complex types. More...

Functions

void Pscf::assign (double &z, double const &a)
 Assign a double value.
void Pscf::assign (float &z, float const &a)
 Assign a real float value.
template<typename RT>
void Pscf::assign (std::complex< RT > &z, std::complex< RT > const &a)
 Assign one std::complex<RT> variable to another.
template<typename RT>
void Pscf::assign (std::complex< RT > &z, RT const &a, RT const &b)
 Create std::complex<RT> from real and imaginary parts, z = a + ib.
template<typename RT>
void Pscf::assign (std::complex< RT > &z, RT const &a)
 Assign a real input to a std::complex variable.
void Pscf::add (double &z, double const &a, double const &b)
 Addition of two double precision numbers, z = a + b.
void Pscf::add (float &z, float const &a, float const &b)
 Addition of two real float numbers, z = a + b.
template<typename RT>
void Pscf::add (std::complex< RT > &z, std::complex< RT > const &a, std::complex< RT > const &b)
 Addition of two std::complex variables, z = a + b.
template<typename RT>
void Pscf::add (std::complex< RT > &z, std::complex< RT > const &a, RT const &b)
 Addition of a std::complex and real number, z = a + b.
void Pscf::addEq (double &a, double const &b)
 In place addition a += b (double).
void Pscf::addEq (float &a, float const &b)
 In place addition a += b (double).
template<typename RT>
void Pscf::addEq (std::complex< RT > &a, std::complex< RT > const &b)
 In place addition a += b (std::complex<RT>)
template<typename RT>
void Pscf::addEq (std::complex< RT > &a, RT const &b)
 In place addition of std::complex and real numbers, a += b.
void Pscf::sub (double &z, double const &a, double const &b)
 Subtraction of double precision numbers, z = a - b.
void Pscf::sub (float &z, float const &a, float const &b)
 Subtraction z = a - b (real float).
template<typename RT>
void Pscf::sub (std::complex< RT > &z, std::complex< RT > const &a, std::complex< RT > const &b)
 Subtraction z = a - b (std::complex<RT>)
template<typename RT>
void Pscf::sub (std::complex< RT > &z, std::complex< RT > const &a, RT const &b)
 Subtraction of real from complex, z = a - b.
void Pscf::subEq (double &a, double const &b)
 In place subtraction a -= b (double).
void Pscf::subEq (float &a, float const &b)
 In place subtraction, a -= b (float).
template<typename RT>
void Pscf::subEq (std::complex< RT > &a, std::complex< RT > const &b)
 In place subtraction a -= b (std::complex<RT>).
template<typename RT>
void Pscf::subEq (std::complex< RT > &a, RT const &b)
 In place subtraction of real from std::complex, a -= b.
void Pscf::mul (double &z, double const &a, double const &b)
 Multiplication of double real numbers, z = a * b.
void Pscf::mul (float &z, float const &a, float const &b)
 Multiplication z = a * b (float).
template<typename RT>
void Pscf::mul (std::complex< RT > &z, std::complex< RT > const &a, std::complex< RT > const &b)
 Multiplication z = a * b (std::complex).
template<typename RT>
void Pscf::mul (std::complex< RT > &z, std::complex< RT > const &a, RT const &b)
 Multiplication of std::complex and real, z = a * b.
void Pscf::mulEq (double &a, double const &b)
 In place multiplication a *= b (double).
void Pscf::mulEq (float &a, float const &b)
 In place multiplication a *= b (float).
template<typename RT>
void Pscf::square (std::complex< RT > &z, std::complex< RT > const &a)
 Compute complex square of a std::complex, z = a * a.
void Pscf::div (double &z, double const &a, double const &b)
 Division z = a / b (double).
void Pscf::div (float &z, float const &a, float const &b)
 Division z = a / b (float).
template<typename RT>
void Pscf::div (std::complex< RT > &z, std::complex< RT > const &a, std::complex< RT > const &b)
 Division z = a / b (std::complex)
template<typename RT>
void Pscf::div (std::complex< RT > &z, std::complex< RT > const &a, RT const &b)
 Division of a std::complex number by real, z = a / b .
void Pscf::divEq (double &a, double const &b)
 In place division a /= b (double).
void Pscf::divEq (float &a, float const &b)
 In place division a /= b (float).
template<typename RT>
void Pscf::divEq (std::complex< RT > &a, std::complex< RT > const &b)
 In place division a /= b (std::complex).
template<typename RT>
void Pscf::divEq (std::complex< RT > &a, RT const &b)
 In place division of std::complex number by real, a /= b.
void Pscf::inverse (double &z, double const &a)
 Inverse, z = 1/a (double).
void Pscf::inverse (float &z, float const &a)
 Inverse, z = 1 / a (float).
void Pscf::assignExp (double &z, double const &a)
 Exponentiation, z = exp(a) (double).
void Pscf::assignExp (float &z, float const &a)
 Exponent, z = exp(a) (float).
void Pscf::assignLog (double &z, double const &a)
 Logarithm, z = exp(a) (double).
void Pscf::assignLog (float &z, float const &a)
 Logarithm, z = exp(a) (float).

Detailed Description

Overloaded functions and function templates for arithmetic operations using built-in real types and/or C++ standard library complex types.

Corresponding functions that use complex types used by the FFTW and cufft libraries are defined in the files pscf/cpu/complex.h and pscf/cuda/complex.h

Convention: Functions for which the result or output could be a complex number provide this as a modified value of the first parameter of the function, which must be passed as a non-const reference. Functions for which the output is always real (such as an absolute value function) instead provide this as the function return value. This convention creates interfaces that allow the use of data types to represent complex number for which no assignment operator is defined, which cannot be returned as function return values.

Function Documentation

◆ assign() [1/5]

void Pscf::assign ( double & z,
double const & a )
inline

Assign a double value.

Parameters
zvalue (out)
avalue (in)

Definition at line 48 of file arithmetic.h.

◆ assign() [2/5]

void Pscf::assign ( float & z,
float const & a )
inline

Assign a real float value.

Parameters
zvalue (out)
avalue (in)

Definition at line 60 of file arithmetic.h.

◆ assign() [3/5]

template<typename RT>
void Pscf::assign ( std::complex< RT > & z,
std::complex< RT > const & a )
inline

Assign one std::complex<RT> variable to another.

Parameters
zvalue (out)
avalue (in)

Definition at line 72 of file arithmetic.h.

◆ assign() [4/5]

template<typename RT>
void Pscf::assign ( std::complex< RT > & z,
RT const & a,
RT const & b )
inline

Create std::complex<RT> from real and imaginary parts, z = a + ib.

Parameters
zcomplex (out)
areal part (in)
bimaginary part (in)

Definition at line 85 of file arithmetic.h.

◆ assign() [5/5]

template<typename RT>
void Pscf::assign ( std::complex< RT > & z,
RT const & a )
inline

Assign a real input to a std::complex variable.

Parameters
zcomplex (out)
areal (in)

Definition at line 97 of file arithmetic.h.

◆ add() [1/4]

void Pscf::add ( double & z,
double const & a,
double const & b )
inline

Addition of two double precision numbers, z = a + b.

Parameters
zsum (out)
asummand (in)
bsummand (in)

Definition at line 112 of file arithmetic.h.

◆ add() [2/4]

void Pscf::add ( float & z,
float const & a,
float const & b )
inline

Addition of two real float numbers, z = a + b.

Parameters
zsum (out)
asummand (in)
bsummand (in)

Definition at line 125 of file arithmetic.h.

◆ add() [3/4]

template<typename RT>
void Pscf::add ( std::complex< RT > & z,
std::complex< RT > const & a,
std::complex< RT > const & b )
inline

Addition of two std::complex variables, z = a + b.

Parameters
zsum (out)
asummand (in)
bsummand (in)

Definition at line 138 of file arithmetic.h.

◆ add() [4/4]

template<typename RT>
void Pscf::add ( std::complex< RT > & z,
std::complex< RT > const & a,
RT const & b )
inline

Addition of a std::complex and real number, z = a + b.

Parameters
zcomplex sum (out)
acomplex summand (in)
breal summand (in)

Definition at line 152 of file arithmetic.h.

◆ addEq() [1/4]

void Pscf::addEq ( double & a,
double const & b )
inline

In place addition a += b (double).

Parameters
asummand (in) and sum (out)
bsummand (in)

Definition at line 165 of file arithmetic.h.

◆ addEq() [2/4]

void Pscf::addEq ( float & a,
float const & b )
inline

In place addition a += b (double).

Parameters
asummand (in) and sum (out)
bsummand (in)

Definition at line 177 of file arithmetic.h.

◆ addEq() [3/4]

template<typename RT>
void Pscf::addEq ( std::complex< RT > & a,
std::complex< RT > const & b )
inline

In place addition a += b (std::complex<RT>)

Parameters
asummand (in) and sum (out)
bsummand (in)

Definition at line 189 of file arithmetic.h.

◆ addEq() [4/4]

template<typename RT>
void Pscf::addEq ( std::complex< RT > & a,
RT const & b )
inline

In place addition of std::complex and real numbers, a += b.

Parameters
asummand (in) and sum (out)
bsummand (in)

Definition at line 201 of file arithmetic.h.

◆ sub() [1/4]

void Pscf::sub ( double & z,
double const & a,
double const & b )
inline

Subtraction of double precision numbers, z = a - b.

Parameters
zdifference (out)
a1st argument (in)
b2nd argument (in)

Definition at line 216 of file arithmetic.h.

◆ sub() [2/4]

void Pscf::sub ( float & z,
float const & a,
float const & b )
inline

Subtraction z = a - b (real float).

Parameters
zdifference (out)
a1st argument (in)
b2nd argument (in)

Definition at line 229 of file arithmetic.h.

◆ sub() [3/4]

template<typename RT>
void Pscf::sub ( std::complex< RT > & z,
std::complex< RT > const & a,
std::complex< RT > const & b )
inline

Subtraction z = a - b (std::complex<RT>)

Parameters
zdifference (out)
a1st argument (in)
b2nd argument (in)

Definition at line 242 of file arithmetic.h.

◆ sub() [4/4]

template<typename RT>
void Pscf::sub ( std::complex< RT > & z,
std::complex< RT > const & a,
RT const & b )
inline

Subtraction of real from complex, z = a - b.

Parameters
zcomplex difference (out)
acomplex 1st argument (in)
breal 2nd argument (in)

Definition at line 256 of file arithmetic.h.

◆ subEq() [1/4]

void Pscf::subEq ( double & a,
double const & b )
inline

In place subtraction a -= b (double).

Parameters
aargument (in) and difference (out)
bargument (in)

Definition at line 269 of file arithmetic.h.

◆ subEq() [2/4]

void Pscf::subEq ( float & a,
float const & b )
inline

In place subtraction, a -= b (float).

Parameters
aargument (in) and difference (out)
bargument (in)

Definition at line 281 of file arithmetic.h.

◆ subEq() [3/4]

template<typename RT>
void Pscf::subEq ( std::complex< RT > & a,
std::complex< RT > const & b )
inline

In place subtraction a -= b (std::complex<RT>).

Parameters
aargument (in) and difference (out)
bargument (in)

Definition at line 293 of file arithmetic.h.

◆ subEq() [4/4]

template<typename RT>
void Pscf::subEq ( std::complex< RT > & a,
RT const & b )
inline

In place subtraction of real from std::complex, a -= b.

Parameters
aargument (in) and difference (out)
bargument (in)

Definition at line 305 of file arithmetic.h.

◆ mul() [1/4]

void Pscf::mul ( double & z,
double const & a,
double const & b )
inline

Multiplication of double real numbers, z = a * b.

Parameters
zproduct (out)
afactor (in)
bfactor (in)

Definition at line 320 of file arithmetic.h.

◆ mul() [2/4]

void Pscf::mul ( float & z,
float const & a,
float const & b )
inline

Multiplication z = a * b (float).

Parameters
zproduct (out)
afactor (in)
bfactor (in)

Definition at line 333 of file arithmetic.h.

◆ mul() [3/4]

template<typename RT>
void Pscf::mul ( std::complex< RT > & z,
std::complex< RT > const & a,
std::complex< RT > const & b )
inline

Multiplication z = a * b (std::complex).

Parameters
zproduct (out)
afactor (in)
bfactor (in)

Definition at line 346 of file arithmetic.h.

◆ mul() [4/4]

template<typename RT>
void Pscf::mul ( std::complex< RT > & z,
std::complex< RT > const & a,
RT const & b )
inline

Multiplication of std::complex and real, z = a * b.

Parameters
zcomplex product (out)
acomplex factor (in)
breal factor (in)

Definition at line 360 of file arithmetic.h.

◆ mulEq() [1/2]

void Pscf::mulEq ( double & a,
double const & b )
inline

In place multiplication a *= b (double).

Parameters
afactor (in) and product (out)
bfactor (in)

Definition at line 374 of file arithmetic.h.

◆ mulEq() [2/2]

void Pscf::mulEq ( float & a,
float const & b )
inline

In place multiplication a *= b (float).

Parameters
afactor (in) and product (out)
bfactor (in)

Definition at line 386 of file arithmetic.h.

◆ square()

template<typename RT>
void Pscf::square ( std::complex< RT > & z,
std::complex< RT > const & a )
inline

Compute complex square of a std::complex, z = a * a.

Parameters
zcomplex product (out)
acomplex factor (in)

Definition at line 398 of file arithmetic.h.

◆ div() [1/4]

void Pscf::div ( double & z,
double const & a,
double const & b )
inline

Division z = a / b (double).

Parameters
zratio (out)
anumerator (in)
bdenominator (in)

Definition at line 413 of file arithmetic.h.

◆ div() [2/4]

void Pscf::div ( float & z,
float const & a,
float const & b )
inline

Division z = a / b (float).

Parameters
zratio (out)
anumerator (in)
bdenominator (in)

Definition at line 426 of file arithmetic.h.

◆ div() [3/4]

template<typename RT>
void Pscf::div ( std::complex< RT > & z,
std::complex< RT > const & a,
std::complex< RT > const & b )
inline

Division z = a / b (std::complex)

Parameters
zratio (out)
anumerator (in)
bdenominator (in)

Definition at line 439 of file arithmetic.h.

◆ div() [4/4]

template<typename RT>
void Pscf::div ( std::complex< RT > & z,
std::complex< RT > const & a,
RT const & b )
inline

Division of a std::complex number by real, z = a / b .

Parameters
zcomplex ratio (out)
acomplex numerator (in)
breal denominator (in)

Definition at line 453 of file arithmetic.h.

◆ divEq() [1/4]

void Pscf::divEq ( double & a,
double const & b )
inline

In place division a /= b (double).

Parameters
acomplex numerator (in) and ratio (out)
bcomplex denominator (in)

Definition at line 466 of file arithmetic.h.

◆ divEq() [2/4]

void Pscf::divEq ( float & a,
float const & b )
inline

In place division a /= b (float).

Parameters
acomplex numerator (in) and ratio (out)
bcomplex denominator (in)

Definition at line 478 of file arithmetic.h.

◆ divEq() [3/4]

template<typename RT>
void Pscf::divEq ( std::complex< RT > & a,
std::complex< RT > const & b )
inline

In place division a /= b (std::complex).

Parameters
acomplex numerator (in) and ratio (out)
bcomplex denominator (in)

Definition at line 490 of file arithmetic.h.

◆ divEq() [4/4]

template<typename RT>
void Pscf::divEq ( std::complex< RT > & a,
RT const & b )
inline

In place division of std::complex number by real, a /= b.

Parameters
acomplex numerator (in) and ratio (out)
breal denominator (in)

Definition at line 502 of file arithmetic.h.

◆ inverse() [1/2]

void Pscf::inverse ( double & z,
double const & a )
inline

Inverse, z = 1/a (double).

Parameters
zinverse (out)
aargument (in)

Definition at line 516 of file arithmetic.h.

◆ inverse() [2/2]

void Pscf::inverse ( float & z,
float const & a )
inline

Inverse, z = 1 / a (float).

Parameters
zinverse (out)
aargument (in)

Definition at line 528 of file arithmetic.h.

◆ assignExp() [1/2]

void Pscf::assignExp ( double & z,
double const & a )
inline

Exponentiation, z = exp(a) (double).

Parameters
zexponent (out)
aargument (in)

Definition at line 542 of file arithmetic.h.

◆ assignExp() [2/2]

void Pscf::assignExp ( float & z,
float const & a )
inline

Exponent, z = exp(a) (float).

Parameters
zexponent (out)
aargument (in)

Definition at line 554 of file arithmetic.h.

◆ assignLog() [1/2]

void Pscf::assignLog ( double & z,
double const & a )
inline

Logarithm, z = exp(a) (double).

Parameters
zlogarithm (out)
aargument (in)

Definition at line 568 of file arithmetic.h.

◆ assignLog() [2/2]

void Pscf::assignLog ( float & z,
float const & a )
inline

Logarithm, z = exp(a) (float).

Parameters
zlogarithm (out)
aargument (in)

Definition at line 580 of file arithmetic.h.