33 ext::shared_ptr<YieldTermStructure> rTS,
34 ext::shared_ptr<YieldTermStructure> qTS,
35 ext::shared_ptr<FdmQuantoHelper> quantoHelper,
36 ext::shared_ptr<LocalVolTermStructure> leverageFct)
37 : varianceValues_(0.5 * mesher->locations(1)), dxMap_(
FirstDerivativeOp(0, mesher)),
38 dxxMap_(
SecondDerivativeOp(0, mesher).mult(0.5 * mesher->locations(1))), mapT_(0, mesher),
40 quantoHelper_(
std::move(quantoHelper)), leverageFct_(
std::move(leverageFct)) {
45 for (
const auto& iter : *
mesher_->layout()) {
46 if ( iter.coordinates()[0] == 0
47 || iter.coordinates()[0] ==
mesher_->layout()->dim()[0]-1) {
79 const Real t = 0.5*(t1+t2);
82 for (
const auto& iter : *
mesher_->layout()) {
83 const Size nx = iter.coordinates()[0];
85 if (iter.coordinates()[1] == 0) {
86 const Real x = std::exp(
mesher_->location(iter, 0));
89 v[nx] = std::max(0.01,
leverageFct_->localVol(time, spot,
true));
92 v[iter.index()] =
v[nx];
104 ext::shared_ptr<YieldTermStructure> rTS,
109 .mult(0.5 * mixedSigma * mixedSigma * mesher->locations(1))
111 mapT_(1, mesher),
rTS_(
std::move(rTS)) {}
123 const ext::shared_ptr<FdmMesher>& mesher,
124 const ext::shared_ptr<HestonProcess> & hestonProcess,
125 const ext::shared_ptr<FdmQuantoHelper>& quantoHelper,
126 const ext::shared_ptr<LocalVolTermStructure>& leverageFct,
127 const Real mixingFactor)
129 .mult(hestonProcess->
rho()*hestonProcess->
sigma()
131 *mesher->locations(1))),
132 dyMap_(mesher, hestonProcess->riskFreeRate().currentLink(),
133 hestonProcess->
sigma()*mixingFactor,
134 hestonProcess->
kappa(),
135 hestonProcess->
theta()),
137 hestonProcess->riskFreeRate().currentLink(),
138 hestonProcess->dividendYield().currentLink(),
139 quantoHelper, leverageFct) {
161 else if (direction == 1)
164 QL_FAIL(
"direction too large");
174 if (direction == 0) {
177 else if (direction == 1) {
181 QL_FAIL(
"direction too large");
1-D array used in linear algebra.
void setTime(Time t1, Time t2)
const Array & getL() const
const TripleBandLinearOp & getMap() const
FdmHestonEquityPart(const ext::shared_ptr< FdmMesher > &mesher, ext::shared_ptr< YieldTermStructure > rTS, ext::shared_ptr< YieldTermStructure > qTS, ext::shared_ptr< FdmQuantoHelper > quantoHelper, ext::shared_ptr< LocalVolTermStructure > leverageFct=ext::shared_ptr< LocalVolTermStructure >())
const TripleBandLinearOp dxxMap_
const ext::shared_ptr< FdmQuantoHelper > quantoHelper_
const ext::shared_ptr< LocalVolTermStructure > leverageFct_
const ext::shared_ptr< YieldTermStructure > qTS_
const FirstDerivativeOp dxMap_
const ext::shared_ptr< FdmMesher > mesher_
Array getLeverageFctSlice(Time t1, Time t2) const
const ext::shared_ptr< YieldTermStructure > rTS_
Size size() const override
FdmHestonEquityPart dxMap_
FdmHestonVariancePart dyMap_
Array apply_direction(Size direction, const Array &r) const override
Array preconditioner(const Array &r, Real s) const override
std::vector< SparseMatrix > toMatrixDecomp() const override
void setTime(Time t1, Time t2) override
Time is required.
Array apply_mixed(const Array &r) const override
NinePointLinearOp correlationMap_
Array solve_splitting(Size direction, const Array &r, Real s) const override
FdmHestonOp(const ext::shared_ptr< FdmMesher > &mesher, const ext::shared_ptr< HestonProcess > &hestonProcess, const ext::shared_ptr< FdmQuantoHelper > &quantoHelper=ext::shared_ptr< FdmQuantoHelper >(), const ext::shared_ptr< LocalVolTermStructure > &leverageFct=ext::shared_ptr< LocalVolTermStructure >(), Real mixingFactor=1.0)
Array apply(const Array &r) const override
void setTime(Time t1, Time t2)
const TripleBandLinearOp & getMap() const
const TripleBandLinearOp dyMap_
FdmHestonVariancePart(const ext::shared_ptr< FdmMesher > &mesher, ext::shared_ptr< YieldTermStructure > rTS, Real mixedSigma, Real kappa, Real theta)
const ext::shared_ptr< YieldTermStructure > rTS_
SparseMatrix toMatrix() const override
Array apply(const Array &r) const override
SparseMatrix toMatrix() const override
Array solve_splitting(const Array &r, Real a, Real b=1.0) const
void axpyb(const Array &a, const TripleBandLinearOp &x, const TripleBandLinearOp &y, const Array &b)
TripleBandLinearOp mult(const Array &u) const
Array apply(const Array &r) const override
#define QL_FAIL(message)
throw an error (possibly with file and line information)
const ext::shared_ptr< YieldTermStructure > rTS_
memory layout of a fdm linear operator
const ext::shared_ptr< FdmMesher > mesher_
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
Array Sqrt(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