PSCF v1.4.0
ReduceCx.h
1#ifndef PSCF_CPU_REDUCE_CX_H
2#define PSCF_CPU_REDUCE_CX_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include "Reduce.h"
12#include <fftw3.h>
13#include <complex.h>
14
15// Forward declaration
16namespace Util {
17 template <typename T> class Array;
18}
19
20namespace Pscf {
21
22 using namespace Util;
23
24 /*
25 * Functions that perform reductions on fftw_complex arrays.
26 *
27 * A reduction is any operation that involves reducing all of
28 * the elements of one or more array to a single scalar, such as
29 * a summation or inner product. Complex reduction results are
30 * returned as values of type std::complex<double> because the
31 * fftw_complex type is an alias for an array type double[2]
32 * that cannot be returned by value.
33 */
34
35 namespace Reduce {
36
45 std::complex<double> sum(Array<fftw_complex> const & a);
46
57 std::complex<double> sum(Array<fftw_complex> const & a,
58 int begin, int end);
59
68 std::complex<double> sumSq(Array<fftw_complex> const & a);
69
79 std::complex<double> sumProduct(Array<fftw_complex> const & a,
80 Array<fftw_complex> const & b);
81
82 } // namespace Reduce
83} // namespace Pscf
84#endif
Array container class template.
Definition Array.h:40
std::complex< double > sumProduct(Array< fftw_complex > const &a, Array< fftw_complex > const &b)
Compute sum of complex products of elements of two arrays (complex).
Definition ReduceCx.cpp:75
double sumSq(Array< double > const &in)
Compute sum of of squares of array elements (real).
Definition Reduce.cpp:82
double sum(Array< double > const &in)
Compute sum of array elements (real).
Definition Reduce.cpp:20
Reduction operations performed on a CPU or GPU.
Definition Reduce.cpp:13
PSCF package top-level namespace.
Utility classes for scientific computation.