33 const ext::shared_ptr<FdmMesher>& mesher,
34 ext::shared_ptr<HullWhite> hwModel,
35 ext::shared_ptr<YieldTermStructure> qTS)
36 :
x_(mesher->locations(2)), varianceValues_(0.5 * mesher->locations(1)),
38 dxxMap_(
SecondDerivativeOp(0, mesher).mult(0.5 * mesher->locations(1))), mapT_(0, mesher),
39 hwModel_(
std::move(hwModel)),
mesher_(mesher), qTS_(
std::move(qTS)) {
44 for (
const auto& iter : *
mesher_->layout()) {
45 if ( iter.coordinates()[0] == 0
46 || iter.coordinates()[0] ==
mesher_->layout()->dim()[0]-1) {
54 const ext::shared_ptr<OneFactorModel::ShortRateDynamics> dynamics =
57 const Real phi = 0.5*( dynamics->shortRate(t1, 0.0)
58 + dynamics->shortRate(t2, 0.0));
70 const ext::shared_ptr<HestonProcess>& hestonProcess,
71 const ext::shared_ptr<HullWhiteProcess>& hwProcess,
72 Real equityShortRateCorrelation)
76 hestonProcess->riskFreeRate(), hwProcess->a(), hwProcess->
sigma())),
81 .mult(
Sqrt(mesher->locations(1)) * hwProcess->
sigma() * equityShortRateCorrelation)),
85 dxMap_(mesher, hwModel_, hestonProcess->dividendYield().currentLink()),
86 hullWhiteOp_(mesher, hwModel_, 2) {
88 QL_REQUIRE( equityShortRateCorrelation*equityShortRateCorrelation
89 + hestonProcess->rho()*hestonProcess->rho() <= 1.0,
90 "correlation matrix has negative eigenvalues");
112 else if (direction == 1)
114 else if (direction == 2)
117 QL_FAIL(
"direction too large");
126 if (direction == 0) {
129 else if (direction == 1) {
132 else if (direction == 2) {
136 QL_FAIL(
"direction too large");
1-D array used in linear algebra.
void setTime(Time t1, Time t2)
const ext::shared_ptr< HullWhite > hwModel_
const TripleBandLinearOp & getMap() const
const TripleBandLinearOp dxxMap_
const ext::shared_ptr< YieldTermStructure > qTS_
const FirstDerivativeOp dxMap_
const ext::shared_ptr< FdmMesher > mesher_
FdmHestonHullWhiteEquityPart(const ext::shared_ptr< FdmMesher > &mesher, ext::shared_ptr< HullWhite > hwModel, ext::shared_ptr< YieldTermStructure > qTS)
Size size() const override
Array apply_direction(Size direction, const Array &r) const override
NinePointLinearOp hestonCorrMap_
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
FdmHullWhiteOp hullWhiteOp_
Array solve_splitting(Size direction, const Array &r, Real s) const override
FdmHestonHullWhiteEquityPart dxMap_
FdmHestonHullWhiteOp(const ext::shared_ptr< FdmMesher > &mesher, const ext::shared_ptr< HestonProcess > &hestonProcess, const ext::shared_ptr< HullWhiteProcess > &hwProcess, Real equityShortRateCorrelation)
Array apply(const Array &r) const override
NinePointLinearOp equityIrCorrMap_
TripleBandLinearOp dyMap_
std::vector< SparseMatrix > toMatrixDecomp() const override
void setTime(Time t1, Time t2) override
Time is required.
Array solve_splitting(Size direction, const Array &r, Real s) const override
Array apply(const Array &r) const override
Single-factor Hull-White (extended Vasicek) model class.
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)
Array apply(const Array &r) const override
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Heston Hull White linear operator.
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
second derivative operator
second order mixed derivative linear operator