18#ifndef OPALX_LINEAR_SPLINE_H
19#define OPALX_LINEAR_SPLINE_H
34 LinearSpline(
const std::vector<double>& x,
const std::vector<double>& y);
39 void init(
const std::vector<double>& x,
const std::vector<double>& y)
override;
65 [[nodiscard]]
double integral(
size_t i,
double dx)
const;
78 std::vector<double>
m_{};
79 std::vector<double>
c_{};
Accelerator caching last interval indices.
Base class for the linear and cubic interpolation spline classes.
std::vector< double > integrals_
LinearSpline()=default
Default constructor.
double evalIntegral(double xa, double xb, Accelerator &accel) const override
Evaluate the integral of the spline at x.
double extrapolateRight(double x) const
Linear extrapolation to the right of the data range.
double extrapolateLeft(double x) const
Linear extrapolation to the left of the data range.
void computeCoefficients()
Compute linear spline coefficients.
double integral(size_t i, double dx) const
Calculate the integral from x_[i] to x_[i]+dx.
void computeIntegrals()
Compute the integrals of the intervals.
void init(const std::vector< double > &x, const std::vector< double > &y) override
Initialize from tabulated data (natural spline).
double eval(double x, Accelerator &accel) const override
Evaluate the spline at x using an accelerator.