Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages

◆ 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 const double k
Definition exactTestP.cc:42

Definition at line 309 of file Interpolation1D.cc.

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

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