PSCF v1.5.0

Functions that perform reductions (C++ CPU backend). More...

Functions

double Pscf::Reduce::sum (Array< double > const &in)
 Compute sum of array elements (real).
double Pscf::Reduce::sum (Array< double > const &in, int begin, int end)
 Compute sum of elements of an array slice (real).
double Pscf::Reduce::sumSq (Array< double > const &in)
 Compute sum of of squares of array elements (real).
std::complex< double > Pscf::Reduce::sum (Array< fftw_complex > const &a)
 Compute sum of all elements of an array (complex).
std::complex< double > Pscf::Reduce::sum (Array< fftw_complex > const &a, int begin, int end)
 Compute sum of elements of an array slice (complex).
std::complex< double > Pscf::Reduce::sumSq (Array< fftw_complex > const &a)
 Compute sum of squares of elements of a complex array.
double Pscf::Reduce::innerProduct (Array< double > const &a, Array< double > const &b)
 Compute Euclidean inner product of two real arrays .
std::complex< double > Pscf::Reduce::sumProduct (Array< fftw_complex > const &a, Array< fftw_complex > const &b)
 Compute sum of complex products of elements of two arrays (complex).
double Pscf::Reduce::max (Array< double > const &in)
 Get maximum of array elements (real).
double Pscf::Reduce::max (Array< double > const &in, int begin, int end)
 Get value of maximum element in an array slice (real).
double Pscf::Reduce::maxAbs (Array< double > const &in)
 Get maximum absolute magnitude of array elements .
double Pscf::Reduce::min (Array< double > const &in)
 Get minimum of array elements .
double Pscf::Reduce::min (Array< double > const &in, int begin, int end)
 Get value of minimum element in an array slice (real).
double Pscf::Reduce::minAbs (Array< double > const &in)
 Get minimum absolute magnitude of array elements .

Detailed Description

Functions that perform reductions (C++ CPU backend).

A reduction is a operation that takes one or more arrays as inputs and returns a scalar result, such as a sum of elements, a maximum or minimum element, or an inner product.

Complex reduction results are returned as std::complex<double> values because the fftw_complex type is an alias for an array types, double[2], that cannot be returned by value.

Function Documentation

◆ sum() [1/4]

◆ sum() [2/4]

double Pscf::Reduce::sum ( Array< double > const & in,
int begin,
int end )

Compute sum of elements of an array slice (real).

Parameters
ininput array
beginindex of first element in slice
endindex one past the last in slice
Returns
sum of elements with indices [begin, end-1]

Definition at line 49 of file Reduce.cpp.

References Util::Array< Data >::capacity(), sum(), and UTIL_CHECK.

◆ sumSq() [1/2]

double Pscf::Reduce::sumSq ( Array< double > const & in)

Compute sum of of squares of array elements (real).

Parameters
ininput array

Definition at line 121 of file Reduce.cpp.

References Util::Array< Data >::capacity(), sum(), sumSq(), and UTIL_CHECK.

Referenced by Pscf::Rp::EinsteinCrystalPerturbation< D, T >::hamiltonian(), sumSq(), sumSq(), sumSq(), and sumSq().

◆ sum() [3/4]

std::complex< double > Pscf::Reduce::sum ( Array< fftw_complex > const & a)

Compute sum of all elements of an array (complex).

Parameters
ainput array
Returns
sum of all elements of complex array a

Definition at line 81 of file Reduce.cpp.

References Util::Array< Data >::capacity(), sum(), and UTIL_CHECK.

◆ sum() [4/4]

std::complex< double > Pscf::Reduce::sum ( Array< fftw_complex > const & a,
int begin,
int end )

Compute sum of elements of an array slice (complex).

Parameters
ainput array
beginindex of first element of slice
endindex one past the last element
Returns
sum of elements with indices [begin, end-1]

Definition at line 98 of file Reduce.cpp.

References Util::Array< Data >::capacity(), sum(), and UTIL_CHECK.

◆ sumSq() [2/2]

std::complex< double > Pscf::Reduce::sumSq ( Array< fftw_complex > const & a)

Compute sum of squares of elements of a complex array.

Parameters
ainput array
Returns
complex sum of squares of elements of array a

Definition at line 154 of file Reduce.cpp.

References Util::Array< Data >::capacity(), sum(), sumSq(), and UTIL_CHECK.

◆ innerProduct()

double Pscf::Reduce::innerProduct ( Array< double > const & a,
Array< double > const & b )

Compute Euclidean inner product of two real arrays .

Parameters
afirst input array
bsecond input array

Definition at line 176 of file Reduce.cpp.

References Util::Array< Data >::capacity(), innerProduct(), sum(), and UTIL_CHECK.

Referenced by Pscf::Rp::PropagatorBase< D, T >::computeQ(), innerProduct(), innerProduct(), Pscf::Rp::FilmFieldGenExt< D, CUT >::stress(), Pscf::Rp::FilmFieldGenMask< D, CUT >::stress(), and Pscf::Rp::ScftThermo< D, CPT >::write().

◆ sumProduct()

std::complex< double > Pscf::Reduce::sumProduct ( Array< fftw_complex > const & a,
Array< fftw_complex > const & b )

Compute sum of complex products of elements of two arrays (complex).

Parameters
afirst input array
bsecond input array
Returns
sum of elementwise complex products a[i]*b[i]

Definition at line 208 of file Reduce.cpp.

References Util::Array< Data >::capacity(), sum(), sumProduct(), and UTIL_CHECK.

Referenced by sumProduct().

◆ max() [1/2]

double Pscf::Reduce::max ( Array< double > const & in)

Get maximum of array elements (real).

Parameters
ininput array

Definition at line 229 of file Reduce.cpp.

References Util::Array< Data >::capacity(), max(), and UTIL_CHECK.

Referenced by max(), max(), max(), max(), maxAbs(), and maxAbs().

◆ max() [2/2]

double Pscf::Reduce::max ( Array< double > const & in,
int begin,
int end )

Get value of maximum element in an array slice (real).

Parameters
ininput array
beginindex of first element in slice
endindex one past the last in slice
Returns
maximum of elements with indices [begin, end-1]

Definition at line 243 of file Reduce.cpp.

References Util::Array< Data >::capacity(), max(), and UTIL_CHECK.

◆ maxAbs()

double Pscf::Reduce::maxAbs ( Array< double > const & in)

Get maximum absolute magnitude of array elements .

Parameters
ininput array
Returns
maximum absolute value

Definition at line 260 of file Reduce.cpp.

References Util::Array< Data >::capacity(), max(), maxAbs(), and UTIL_CHECK.

Referenced by maxAbs(), and maxAbs().

◆ min() [1/2]

double Pscf::Reduce::min ( Array< double > const & in)

Get minimum of array elements .

Parameters
ininput array
Returns
value of minimum element

Definition at line 276 of file Reduce.cpp.

References Util::Array< Data >::capacity(), min(), and UTIL_CHECK.

Referenced by min(), min(), min(), min(), minAbs(), and minAbs().

◆ min() [2/2]

double Pscf::Reduce::min ( Array< double > const & in,
int begin,
int end )

Get value of minimum element in an array slice (real).

Parameters
ininput array
beginindex of first element in slice
endindex one past the last in slice
Returns
minimum of elements with indices [begin, end-1]

Definition at line 290 of file Reduce.cpp.

References Util::Array< Data >::capacity(), min(), and UTIL_CHECK.

◆ minAbs()

double Pscf::Reduce::minAbs ( Array< double > const & in)

Get minimum absolute magnitude of array elements .

Parameters
ininput array
Returns
value of minimum absolute value of all elements

Definition at line 307 of file Reduce.cpp.

References Util::Array< Data >::capacity(), min(), minAbs(), and UTIL_CHECK.

Referenced by minAbs(), and minAbs().