Skip to content

Commit 607757d

Browse files
pcaspersjenkins
authored andcommitted
QPR-11618 interpolate solution when rolling back to t=0
1 parent 1a3d44b commit 607757d

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

QuantExt/qle/models/lgmfdsolver.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
1717
*/
1818

19-
#include <qle/models/lgmfdsolver.hpp>
2019
#include <qle/methods/fdmlgmop.hpp>
20+
#include <qle/models/lgmfdsolver.hpp>
2121

22+
#include <ql/math/interpolations/cubicinterpolation.hpp>
2223
#include <ql/methods/finitedifferences/meshers/fdmmeshercomposite.hpp>
2324
#include <ql/methods/finitedifferences/meshers/fdmsimpleprocess1dmesher.hpp>
2425

25-
2626
namespace QuantExt {
2727

2828
LgmFdSolver::LgmFdSolver(const boost::shared_ptr<LinearGaussMarkovModel>& model, const Real maxTime,
@@ -51,7 +51,14 @@ RandomVariable LgmFdSolver::rollback(const RandomVariable& v, const Real t1, con
5151
Array workingArray(v.size());
5252
v.copyToArray(workingArray);
5353
solver_->rollback(workingArray, t1, t0, steps, 0);
54-
return RandomVariable(workingArray);
54+
if (QuantLib::close_enough(t0, 0.0)) {
55+
Array x = mesher_->locations(0);
56+
MonotonicCubicNaturalSpline interpolation(x.begin(), x.end(), workingArray.begin());
57+
interpolation.enableExtrapolation();
58+
return RandomVariable(gridSize(), interpolation(0.0));
59+
} else {
60+
return RandomVariable(workingArray);
61+
}
5562
}
5663

5764
} // namespace QuantExt

0 commit comments

Comments
 (0)