PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800

◆ integration_weights() [1/2]

std::map< size_t, double > pism::integration_weights ( const double *  x,
size_t  x_size,
InterpolationType  type,
double  a,
double  b 
)

Compute weights for integrating a piece-wise linear or piece-wise constant function defined on the grid x from a to b.

Uses constant extrapolation, both on the left and on the right.

In the piece-wise constant case points in x are interpreted as left end points of intervals, i.e. the value data[k] corresponds to the interval x[k], x[k + 1].

To evaluate in the integral compute the dot product of data on the grid x with weights computed by this function:

double result = 0.0;
for (const auto &weight : weights) {
size_t k = weight.first;
double w = weight.second;
result += w * data[k];
}
static int weight(int M_ij, int M_n, double h_ij, double h_n)
static const double k
Definition: exactTestP.cc:42

Definition at line 308 of file interpolation.cc.

References LINEAR, PIECEWISE_CONSTANT, PISM_ERROR_LOCATION, weights_piecewise_constant(), and weights_piecewise_linear().

Referenced by pism::array::Forcing::average(), and integration_weights().