|
OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
|
#include <LinearSpline.h>


Public Member Functions | |
| LinearSpline ()=default | |
| Default constructor. | |
| LinearSpline (const std::vector< double > &x, const std::vector< double > &y) | |
| Construct and initialize from tabulated data. | |
| 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. | |
| double | evalIntegral (double xa, double xb, Accelerator &accel) const override |
Evaluate the integral of the spline at x. | |
Protected Member Functions | |
| size_t | findInterval (double x, size_t &intervalCache) const |
| Return the interval index for the given x-coordinate, using the supplied cached value if possible. | |
Protected Attributes | |
| std::vector< double > | x_ {} |
| std::vector< double > | y_ {} |
Private Member Functions | |
| void | computeCoefficients () |
| Compute linear spline coefficients. | |
| void | computeIntegrals () |
| Compute the integrals of the intervals. | |
| double | integral (size_t i, double dx) const |
| Calculate the integral from x_[i] to x_[i]+dx. | |
| double | extrapolateLeft (double x) const |
| Linear extrapolation to the left of the data range. | |
| double | extrapolateRight (double x) const |
| Linear extrapolation to the right of the data range. | |
Private Attributes | |
| std::vector< double > | m_ {} |
| std::vector< double > | c_ {} |
| std::vector< double > | integrals_ {} |
Definition at line 26 of file LinearSpline.h.
|
default |
Default constructor.
| LinearSpline::LinearSpline | ( | const std::vector< double > & | x, |
| const std::vector< double > & | y | ||
| ) |
Construct and initialize from tabulated data.
| x | Input: strictly increasing x-coordinates. |
| y | Input: y-values corresponding to x. |
Definition at line 21 of file LinearSpline.cpp.
References init().

|
private |
Compute linear spline coefficients.
Definition at line 89 of file LinearSpline.cpp.
References c_, m_, AbstractSpline::x_, and AbstractSpline::y_.
Referenced by init().
|
private |
Compute the integrals of the intervals.
Definition at line 98 of file LinearSpline.cpp.
References integral(), integrals_, and AbstractSpline::x_.
Referenced by init().

|
overridevirtual |
Evaluate the spline at x using an accelerator.
| x | Input: x-coordinate. |
| accel | Input/Output: cached interval index. |
Implements AbstractSpline.
Definition at line 34 of file LinearSpline.cpp.
References c_, extrapolateLeft(), extrapolateRight(), AbstractSpline::findInterval(), AbstractSpline::Accelerator::last_index_, m_, and AbstractSpline::x_.
Referenced by TEST_F(), TEST_F(), TEST_F(), and TEST_F().

|
overridevirtual |
Evaluate the integral of the spline at x.
| xa | Input: x-coordinate lower bound. |
| xb | Input: x-coordinate upper bound. |
| accel | Input/output: accelerator for interval caching. |
Implements AbstractSpline.
Definition at line 50 of file LinearSpline.cpp.
References extrapolateLeft(), extrapolateRight(), AbstractSpline::findInterval(), integral(), integrals_, AbstractSpline::Accelerator::last_index_, AbstractSpline::Accelerator::last_upper_index_, AbstractSpline::x_, and AbstractSpline::y_.
Referenced by TEST_F().

|
private |
Linear extrapolation to the left of the data range.
| x | Input: x-coordinate. |
Definition at line 110 of file LinearSpline.cpp.
Referenced by eval(), and evalIntegral().
|
private |
Linear extrapolation to the right of the data range.
| x | Input: x-coordinate. |
Definition at line 112 of file LinearSpline.cpp.
Referenced by eval(), and evalIntegral().
|
protectedinherited |
Return the interval index for the given x-coordinate, using the supplied cached value if possible.
| x | Input: x-coordinate. |
| intervalCache | Input/output: The cached interval index. |
Definition at line 39 of file AbstractSpline.cpp.
References AbstractSpline::x_.
Referenced by CubicSpline::eval(), eval(), CubicSpline::evalIntegral(), and evalIntegral().
|
overridevirtual |
Initialize from tabulated data (natural spline).
| x | Input: strictly increasing x-coordinates. |
| y | Input: y-values corresponding to x. |
Reimplemented from AbstractSpline.
Definition at line 25 of file LinearSpline.cpp.
References computeCoefficients(), computeIntegrals(), and AbstractSpline::init().
Referenced by LinearSpline(), and TEST_F().

|
private |
Calculate the integral from x_[i] to x_[i]+dx.
| i | Input: the interval index |
| dx | Input: the distance in the interval over which to calculate |
Definition at line 105 of file LinearSpline.cpp.
References c_, m_, and AbstractSpline::x_.
Referenced by computeIntegrals(), and evalIntegral().
|
private |
Definition at line 79 of file LinearSpline.h.
Referenced by computeCoefficients(), eval(), extrapolateLeft(), extrapolateRight(), and integral().
|
private |
Definition at line 80 of file LinearSpline.h.
Referenced by computeIntegrals(), and evalIntegral().
|
private |
Definition at line 78 of file LinearSpline.h.
Referenced by computeCoefficients(), eval(), extrapolateLeft(), extrapolateRight(), and integral().
|
protectedinherited |
Definition at line 73 of file AbstractSpline.h.
Referenced by CubicSpline::computeCoefficients(), computeCoefficients(), CubicSpline::computeIntegrals(), computeIntegrals(), CubicSpline::eval(), eval(), CubicSpline::evalIntegral(), evalIntegral(), CubicSpline::extrapolateLeft(), CubicSpline::extrapolateRight(), AbstractSpline::findInterval(), AbstractSpline::init(), and integral().
|
protectedinherited |
Definition at line 74 of file AbstractSpline.h.
Referenced by CubicSpline::computeCoefficients(), computeCoefficients(), CubicSpline::eval(), CubicSpline::evalIntegral(), evalIntegral(), CubicSpline::extrapolateLeft(), CubicSpline::extrapolateRight(), AbstractSpline::init(), and CubicSpline::integral().