24#ifndef quantlib_sampled_curve_hpp
25#define quantlib_sampled_curve_hpp
36 class [[deprecated(
"Use the new finite-differences framework instead")]]
SampledCurve {
43 const Array& grid()
const;
45 const Array& values()
const;
57 void setGrid(
const Array&);
58 void setValues(
const Array&);
62 for(i=grid_.begin(), j = values_.begin();
63 i != grid_.end(); ++i, ++j)
73 Real valueAtCenter()
const;
77 Real firstDerivativeAtCenter()
const;
81 Real secondDerivativeAtCenter()
const;
94 [](
Real x) ->
Real {
return std::log(x); });
103 void regrid(
const Array &new_grid);
105#if defined(__GNUC__) && (__GNUC__ >= 7)
106#pragma GCC diagnostic push
107#pragma GCC diagnostic ignored "-Wnoexcept-type"
113 Array transformed_grid(grid_.size());
115 std::transform(grid_.begin(), grid_.end(),
116 transformed_grid.
begin(), func);
118 transformed_grid.
end(),
120 CubicInterpolation::Spline,
false,
121 CubicInterpolation::SecondDerivative, 0.0,
122 CubicInterpolation::SecondDerivative, 0.0);
125 Array newValues = new_grid;
126 std::transform(newValues.
begin(), newValues.
end(),
127 newValues.
begin(), func);
128 for (
Real& newValue : newValues) {
129 newValue = priceSpline(newValue,
true);
131 values_.swap(newValues);
135#if defined(__GNUC__) && (__GNUC__ >= 7)
136#pragma GCC diagnostic pop
142 std::transform(values_.begin(), values_.end(),
149 std::transform(grid_.begin(), grid_.end(),
168 [[deprecated(
"Use the new finite-differences framework instead")]]
179 : grid_(gridSize), values_(gridSize) {}
182 : grid_(grid), values_(grid.size()) {}
233 grid_.swap(from.grid_);
234 values_.swap(from.values_);
243 out <<
"[ " << a.
grid() <<
"; "
1-D array used in linear algebra.
1-D array used in linear algebra.
bool empty() const
whether the array is empty
const_iterator end() const
Size size() const
dimension of the array
const_iterator begin() const
Cubic interpolation between discrete points.
SampledCurve(Size gridSize=0)
QL_DEPRECATED_DISABLE_WARNING const SampledCurve & transform(T x)
void regridLogGrid(Real min, Real max)
void regrid(const Array &new_grid, T func)
QL_DEPRECATED_DISABLE_WARNING void swap(SampledCurve &) noexcept
const Array & grid() const
void setValues(const Array &)
void setGrid(const Array &)
const Array & values() const
const SampledCurve & transformGrid(T x)
Real gridValue(Size i) const
QL_DEPRECATED_ENABLE_WARNING void setLogGrid(Real min, Real max)
cubic interpolation between discrete points
std::size_t Size
size of a container
SampledCurve SampledCurveSet
Array BoundedLogGrid(Real xMin, Real xMax, Size steps)
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
void swap(Array &v, Array &w) noexcept
#define QL_DEPRECATED_DISABLE_WARNING
#define QL_DEPRECATED_ENABLE_WARNING