24#ifndef quantlib_mixed_interpolation_hpp
25#define quantlib_mixed_interpolation_hpp
35 template<
class I1,
class I2,
class Ia,
class Ib>
36 class MixedInterpolationImpl;
61 template <
class I1,
class I2>
63 const I2& yBegin,
Size n,
68 Real leftConditionValue,
70 Real rightConditionValue) {
71 impl_ = ext::shared_ptr<Interpolation::Impl>(
new
73 xBegin, xEnd, yBegin,
n, behavior,
76 leftC, leftConditionValue,
77 rightC, rightConditionValue)));
89 bool monotonic =
true,
92 Real leftConditionValue = 0.0,
95 Real rightConditionValue = 0.0)
99 template <
class I1,
class I2>
101 const I2& yBegin)
const {
125 template <
class I1,
class I2>
127 const I2& yBegin,
Size n,
139 template <
class I1,
class I2>
141 const I2& yBegin,
Size n,
153 template <
class I1,
class I2>
155 const I2& yBegin,
Size n,
167 template <
class I1,
class I2>
169 const I2& yBegin,
Size n,
181 template <
class I1,
class I2>
183 const I2& yBegin,
Size n,
195 template <
class I1,
class I2>
197 const I2& yBegin,
Size n,
208 template <
class I1,
class I2,
class Interpolator1,
class Interpolator2>
213 const I2& yBegin,
Size n,
216 const Interpolator1& factory1 = Interpolator1(),
217 const Interpolator2& factory2 = Interpolator2())
219 xBegin, xEnd, yBegin,
220 std::max(
Size(Interpolator1::requiredPoints),
221 Size(Interpolator2::requiredPoints))),
228 "too large n (" <<
n <<
") for " <<
229 this->xEnd_-this->
xBegin_ <<
"-element x sequence");
249 QL_FAIL(
"unknown mixed-interpolation behavior: " << behavior);
Cubic interpolation factory and traits
Cubic interpolation between discrete points.
@ SecondDerivative
Match value of second derivative at end.
basic template implementation
templateImpl(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, const int requiredPoints=2)
base class for 1-D interpolations.
Real secondDerivative(Real x, bool allowExtrapolation=false) const
Real derivative(Real x, bool allowExtrapolation=false) const
ext::shared_ptr< Impl > impl_
Real primitive(Real x, bool allowExtrapolation=false) const
Linear-interpolation factory and traits
mixed linear/cubic interpolation factory and traits
CubicInterpolation::DerivativeApprox da_
MixedLinearCubic(Size n, MixedInterpolation::Behavior behavior, CubicInterpolation::DerivativeApprox da, bool monotonic=true, CubicInterpolation::BoundaryCondition leftCondition=CubicInterpolation::SecondDerivative, Real leftConditionValue=0.0, CubicInterpolation::BoundaryCondition rightCondition=CubicInterpolation::SecondDerivative, Real rightConditionValue=0.0)
CubicInterpolation::BoundaryCondition rightType_
CubicInterpolation::BoundaryCondition leftType_
static const Size requiredPoints
MixedInterpolation::Behavior behavior_
Interpolation interpolate(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin) const
mixed linear/cubic interpolation between discrete points
MixedLinearCubicInterpolation(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, Size n, MixedInterpolation::Behavior behavior, CubicInterpolation::DerivativeApprox da, bool monotonic, CubicInterpolation::BoundaryCondition leftC, Real leftConditionValue, CubicInterpolation::BoundaryCondition rightC, Real rightConditionValue)
MixedLinearCubicNaturalSpline(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, Size n, MixedInterpolation::Behavior behavior=MixedInterpolation::ShareRanges)
MixedLinearFritschButlandCubic(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, Size n, MixedInterpolation::Behavior behavior=MixedInterpolation::ShareRanges)
MixedLinearKrugerCubic(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, Size n, MixedInterpolation::Behavior behavior=MixedInterpolation::ShareRanges)
MixedLinearMonotonicCubicNaturalSpline(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, Size n, MixedInterpolation::Behavior behavior=MixedInterpolation::ShareRanges)
MixedLinearMonotonicParabolic(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, Size n, MixedInterpolation::Behavior behavior=MixedInterpolation::ShareRanges)
MixedLinearParabolic(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, Size n, MixedInterpolation::Behavior behavior=MixedInterpolation::ShareRanges)
Real derivative(Real x) const
MixedInterpolationImpl(const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, Size n, MixedInterpolation::Behavior behavior=MixedInterpolation::ShareRanges, const Interpolator1 &factory1=Interpolator1(), const Interpolator2 &factory2=Interpolator2())
Real secondDerivative(Real x) const
Real primitive(Real x) const
Interpolation interpolation2_
Interpolation interpolation1_
cubic interpolation between discrete points
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
std::size_t Size
size of a container
linear interpolation between discrete points