diff --git a/ql/grid.hpp b/ql/grid.hpp index 077c541717..b23efc5bca 100644 --- a/ql/grid.hpp +++ b/ql/grid.hpp @@ -28,10 +28,28 @@ namespace QuantLib { + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. + */ + [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] Array CenteredGrid(Real center, Real dx, Size steps); + + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. + */ + [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] Array BoundedGrid(Real xMin, Real xMax, Size steps); + + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. + */ + [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] Array BoundedLogGrid(Real xMin, Real xMax, Size steps); + // inline definitions inline Array CenteredGrid(Real center, Real dx, Size steps) { diff --git a/ql/math/transformedgrid.hpp b/ql/math/transformedgrid.hpp index 5ef2861efa..9658b3b215 100644 --- a/ql/math/transformedgrid.hpp +++ b/ql/math/transformedgrid.hpp @@ -30,11 +30,11 @@ namespace QuantLib { - //! transformed grid - /*! This package encapuslates an array of grid points. It is used primarily - in PDE calculations. + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. */ - class TransformedGrid { + class [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] TransformedGrid { public: TransformedGrid (const Array &grid) : grid_(grid), transformedGrid_(grid), @@ -93,7 +93,14 @@ namespace QuantLib { Array dx_; }; - class LogGrid : public TransformedGrid { + + QL_DEPRECATED_DISABLE_WARNING + + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. + */ + class [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] LogGrid : public TransformedGrid { public: LogGrid(const Array &grid) : TransformedGrid(grid, [](Real x) -> Real { return std::log(x); }){}; @@ -101,6 +108,8 @@ namespace QuantLib { Real logGrid(Size i) const { return transformedGrid(i);} }; + QL_DEPRECATED_ENABLE_WARNING + } diff --git a/ql/methods/finitedifferences/bsmoperator.cpp b/ql/methods/finitedifferences/bsmoperator.cpp index 04f08d76bf..b5490f2dd4 100644 --- a/ql/methods/finitedifferences/bsmoperator.cpp +++ b/ql/methods/finitedifferences/bsmoperator.cpp @@ -24,6 +24,8 @@ namespace QuantLib { + QL_DEPRECATED_DISABLE_WARNING + BSMOperator::BSMOperator(Size size, Real dx, Rate r, Rate q, Volatility sigma) : TridiagonalOperator(size) { @@ -49,4 +51,6 @@ namespace QuantLib { } } + QL_DEPRECATED_ENABLE_WARNING + } diff --git a/ql/methods/finitedifferences/bsmoperator.hpp b/ql/methods/finitedifferences/bsmoperator.hpp index 2cfcf9b708..c2e7475097 100644 --- a/ql/methods/finitedifferences/bsmoperator.hpp +++ b/ql/methods/finitedifferences/bsmoperator.hpp @@ -30,9 +30,11 @@ namespace QuantLib { - //! Black-Scholes-Merton differential operator - /*! \ingroup findiff */ - class BSMOperator : public TridiagonalOperator { + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. + */ + class [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] BSMOperator : public TridiagonalOperator { public: BSMOperator() = default; BSMOperator(Size size, Real dx, Rate r, Rate q, Volatility sigma); diff --git a/ql/methods/finitedifferences/pde.hpp b/ql/methods/finitedifferences/pde.hpp index b765c2a510..844a607b28 100644 --- a/ql/methods/finitedifferences/pde.hpp +++ b/ql/methods/finitedifferences/pde.hpp @@ -29,12 +29,18 @@ #include namespace QuantLib { - class PdeSecondOrderParabolic { + + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. + */ + class [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] PdeSecondOrderParabolic { public: virtual ~PdeSecondOrderParabolic() = default; virtual Real diffusion(Time t, Real x) const = 0; virtual Real drift(Time t, Real x) const = 0; virtual Real discount(Time t, Real x) const = 0; + QL_DEPRECATED_DISABLE_WARNING virtual void generateOperator(Time t, const TransformedGrid& tg, TridiagonalOperator& L) const { for (Size i = 1; i < tg.size() - 1; i++) { @@ -51,8 +57,12 @@ namespace QuantLib { } }; + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. + */ template - class PdeConstantCoeff : public PdeSecondOrderParabolic { + class [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] PdeConstantCoeff : public PdeSecondOrderParabolic { public: PdeConstantCoeff(const typename PdeClass::argument_type &process, Time t, Real x) { @@ -71,8 +81,14 @@ namespace QuantLib { Real discount_; }; + QL_DEPRECATED_ENABLE_WARNING + + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. + */ template - class GenericTimeSetter:public TridiagonalOperator::TimeSetter { + class [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] GenericTimeSetter:public TridiagonalOperator::TimeSetter { public: template GenericTimeSetter(const Array &grid, T process) : @@ -86,17 +102,23 @@ namespace QuantLib { PdeClass pde_; }; + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. + */ template - class PdeOperator:public TridiagonalOperator { + class [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] PdeOperator:public TridiagonalOperator { public: template PdeOperator(const Array& grid, T process, Time residualTime = 0.0) : TridiagonalOperator(grid.size()) { + QL_DEPRECATED_DISABLE_WARNING timeSetter_ = ext::shared_ptr >( new GenericTimeSetter(grid, process)); + QL_DEPRECATED_ENABLE_WARNING setTime(residualTime); } }; diff --git a/ql/methods/finitedifferences/pdebsm.hpp b/ql/methods/finitedifferences/pdebsm.hpp index d04df70257..334e2f1f70 100644 --- a/ql/methods/finitedifferences/pdebsm.hpp +++ b/ql/methods/finitedifferences/pdebsm.hpp @@ -30,10 +30,15 @@ namespace QuantLib { - class PdeBSM : public PdeSecondOrderParabolic { + QL_DEPRECATED_DISABLE_WARNING + + /*! \deprecated Part of the old FD framework; copy this function + in your codebase if needed. + Deprecated in version 1.37. + */ + class [[deprecated("Part of the old FD framework; copy this function in your codebase if needed")]] PdeBSM : public PdeSecondOrderParabolic { public: - typedef ext::shared_ptr - argument_type; + typedef ext::shared_ptr argument_type; typedef LogGrid grid_type; PdeBSM(argument_type process) : process_(std::move(process)){}; Real diffusion(Time t, Real x) const override { return process_->diffusion(t, x); } @@ -48,6 +53,8 @@ namespace QuantLib { const argument_type process_; }; + QL_DEPRECATED_ENABLE_WARNING + } diff --git a/test-suite/operators.cpp b/test-suite/operators.cpp index 92d8109654..fd0a2421cc 100644 --- a/test-suite/operators.cpp +++ b/test-suite/operators.cpp @@ -168,6 +168,8 @@ BOOST_AUTO_TEST_CASE(testConsistency) { BOOST_AUTO_TEST_CASE(testBSMOperatorConsistency) { BOOST_TEST_MESSAGE("Testing consistency of BSM operators..."); + QL_DEPRECATED_DISABLE_WARNING + Array grid(10); Real price = 20.0; Real factor = 1.1; @@ -198,6 +200,7 @@ BOOST_AUTO_TEST_CASE(testBSMOperatorConsistency) { Handle(qTS), Handle(rTS), Handle(volTS))); + PdeOperator op2(grid, stochProcess, residualTime); Real tolerance = 1.0e-6; @@ -222,6 +225,9 @@ BOOST_AUTO_TEST_CASE(testBSMOperatorConsistency) { << op2.upperDiagonal()[i]); } } + + QL_DEPRECATED_ENABLE_WARNING + } BOOST_AUTO_TEST_SUITE_END() diff --git a/test-suite/transformedgrid.cpp b/test-suite/transformedgrid.cpp index 1e25e5c463..e83a067346 100644 --- a/test-suite/transformedgrid.cpp +++ b/test-suite/transformedgrid.cpp @@ -39,6 +39,8 @@ BOOST_AUTO_TEST_CASE(testConstruction) { BOOST_TEST_MESSAGE("Testing transformed grid construction..."); + QL_DEPRECATED_DISABLE_WARNING + PlusOne p1; Array grid = BoundedGrid(0, 100, 100); TransformedGrid tg(grid, p1); @@ -48,6 +50,9 @@ BOOST_AUTO_TEST_CASE(testConstruction) { if (std::fabs(tg.transformedGrid(0) - 1.0) > 1e-5) BOOST_ERROR("grid transformation failed"); + + QL_DEPRECATED_ENABLE_WARNING + } BOOST_AUTO_TEST_SUITE_END()