40 const ext::shared_ptr<HestonProcess>& process,
42 ext::shared_ptr<LocalVolTermStructure> leverageFct,
43 const Real mixingFactor)
45 rho_(process->
rho()), v0_(process->
v0()), mixedSigma_(mixingFactor *
sigma_),
46 rTS_(process->riskFreeRate().currentLink()), qTS_(process->dividendYield().currentLink()),
47 varianceValues_(0.5 * mesher->locations(1)),
60 .mult(
Array(mesher->layout()->size(), rho_ * mixedSigma_)) :
62 .mult(rho_ * mixedSigma_ * mesher->locations(1)))),
63 leverageFct_(
std::move(leverageFct)),
mesher_(mesher) {
65 const Size n = mesher->layout()->dim()[1];
66 const Real lowerBoundaryFactor =
mapY_->lowerBoundaryFactor(type);
67 const Real upperBoundaryFactor =
mapY_->upperBoundaryFactor(type);
77 for (
const auto& iter : *mesher->layout()) {
78 if (iter.coordinates()[1] == 0) {
79 const Size idx = iter.index();
89 else if (iter.coordinates()[1] ==
n-1) {
90 const Size idx = iter.index();
147 return mapX_->apply(u)
151 return mapX_->apply(u)
169 return mapX_->apply(u) ;
170 else if (direction == 1)
171 return mapY_->apply(u) ;
173 QL_FAIL(
"direction too large");
178 if (direction == 0) {
179 return mapX_->solve_splitting(u,
s, 1.0);
181 else if (direction == 1) {
182 return mapY_->solve_splitting(1, u,
s);
185 QL_FAIL(
"direction too large");
199 const Real t = 0.5*(t1+t2);
203 for (
const auto& iter : *
mesher_->layout()) {
204 const Size nx = iter.coordinates()[0];
206 if (iter.coordinates()[1] == 0) {
207 const Real x = std::exp(
mesher_->location(iter, 0));
210 v[nx] = std::max(0.01,
leverageFct_->localVol(time, spot,
true));
213 v[iter.index()] =
v[nx];
221 std::vector<SparseMatrix> retVal(3);
223 retVal[0] =
mapX_->toMatrix();
224 retVal[1] =
mapY_->toMatrix();
1-D array used in linear algebra.
const ext::shared_ptr< FirstDerivativeOp > dxMap_
Size size() const override
Array apply_direction(Size direction, const Array &r) const override
const ext::shared_ptr< NinePointLinearOp > correlation_
Array preconditioner(const Array &r, Real s) const override
std::vector< SparseMatrix > toMatrixDecomp() const override
FdmHestonFwdOp(const ext::shared_ptr< FdmMesher > &mesher, const ext::shared_ptr< HestonProcess > &process, FdmSquareRootFwdOp::TransformationType type=FdmSquareRootFwdOp::Plain, ext::shared_ptr< LocalVolTermStructure > leverageFct=ext::shared_ptr< LocalVolTermStructure >(), Real mixingFactor=1.0)
const ext::shared_ptr< LocalVolTermStructure > leverageFct_
void setTime(Time t1, Time t2) override
Time is required.
const Array varianceValues_
const ext::shared_ptr< ModTripleBandLinearOp > boundary_
Array apply_mixed(const Array &r) const override
const ext::shared_ptr< YieldTermStructure > qTS_
const ext::shared_ptr< FdmMesher > mesher_
const ext::shared_ptr< TripleBandLinearOp > mapX_
Array getLeverageFctSlice(Time t1, Time t2) const
Array solve_splitting(Size direction, const Array &r, Real s) const override
const ext::shared_ptr< ModTripleBandLinearOp > dxxMap_
const ext::shared_ptr< YieldTermStructure > rTS_
const FdmSquareRootFwdOp::TransformationType type_
Array apply(const Array &r) const override
const ext::shared_ptr< FdmSquareRootFwdOp > mapY_
#define QL_FAIL(message)
throw an error (possibly with file and line information)
const ext::shared_ptr< YieldTermStructure > rTS_
Heston Fokker-Planck forward operator.
memory layout of a fdm linear operator
const ext::shared_ptr< FdmMesher > mesher_
first derivative linear operator
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
Heston stochastic process.
modifiable triple band linear operator
Array Log(const Array &v)
Array Exp(const Array &v)
ext::shared_ptr< YieldTermStructure > q
ext::shared_ptr< YieldTermStructure > r
ext::shared_ptr< BlackVolTermStructure > v
second derivative operator
second order mixed derivative linear operator