25#ifndef quantlib_interpolation2D_hpp
26#define quantlib_interpolation2D_hpp
56 virtual std::vector<Real>
xValues()
const = 0;
60 virtual std::vector<Real>
yValues()
const = 0;
69 template <
class I1,
class I2,
class M>
73 const I2& yBegin,
const I2& yEnd,
78 "not enough x points to interpolate: at least 2 "
81 "not enough y points to interpolate: at least 2 "
92#if defined(QL_EXTRA_SAFETY_CHECKS)
97 bool xIsInrange = (x >= x1 && x <= x2) ||
100 if (!xIsInrange)
return false;
102 #if defined(QL_EXTRA_SAFETY_CHECKS)
112#if defined(QL_EXTRA_SAFETY_CHECKS)
118 else if (x > *(
xEnd_-1))
124#if defined(QL_EXTRA_SAFETY_CHECKS)
142 bool allowExtrapolation =
false)
const {
147 return impl_->xMin();
150 return impl_->xMax();
153 return impl_->xValues();
156 return impl_->locateX(x);
159 return impl_->yMin();
162 return impl_->yMax();
165 return impl_->yValues();
171 return impl_->zData();
174 return impl_->isInRange(x,
y);
183 "interpolation range is ["
187 <<
"]: extrapolation at ("
188 << x <<
", " <<
y <<
") not allowed");
abstract base class for 2-D interpolation implementations
virtual Size locateX(Real x) const =0
virtual void calculate()=0
virtual const Matrix & zData() const =0
virtual bool isInRange(Real x, Real y) const =0
virtual Real yMin() const =0
virtual Size locateY(Real y) const =0
virtual Real xMin() const =0
virtual std::vector< Real > yValues() const =0
virtual Real value(Real x, Real y) const =0
virtual Real xMax() const =0
virtual std::vector< Real > xValues() const =0
virtual Real yMax() const =0
basic template implementation
Size locateX(Real x) const override
Real yMin() const override
const Matrix & zData() const override
Size locateY(Real y) const override
templateImpl(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, const I2 &yEnd, const M &zData)
Real xMax() const override
std::vector< Real > xValues() const override
std::vector< Real > yValues() const override
Real yMax() const override
Real xMin() const override
bool isInRange(Real x, Real y) const override
base class for 2-D interpolations.
std::vector< Real > xValues() const
void checkRange(Real x, Real y, bool extrapolate) const
std::vector< Real > yValues() const
bool isInRange(Real x, Real y) const
const Matrix & zData() const
Size locateY(Real y) const
Size locateX(Real x) const
Interpolation2D()=default
ext::shared_ptr< Impl > impl_
Real operator()(Real x, Real y, bool allowExtrapolation=false) const
Matrix used in linear algebra.
floating-point comparisons
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
matrix used in linear algebra.
bool close(const Quantity &m1, const Quantity &m2, Size n)