29#include <boost/numeric/ublas/matrix.hpp>
34 const ext::shared_ptr<FdmMesher>& mesher,
35 const ext::shared_ptr<GeneralizedBlackScholesProcess>& p1,
36 const ext::shared_ptr<GeneralizedBlackScholesProcess>& p2,
40 Real illegalLocalVolOverwrite)
45 localVol1_((localVol) ? p1->localVolatility().currentLink()
47 localVol2_((localVol) ? p2->localVolatility().currentLink()
53 opX_(mesher, p1, p1->x0(), localVol, illegalLocalVolOverwrite, 0),
54 opY_(mesher, p2, p2->x0(), localVol, illegalLocalVolOverwrite, 1),
56 corrMapT_(0, 1, mesher),
58 .mult(
Array(mesher->layout()->size(), correlation))),
60 illegalLocalVolOverwrite_(illegalLocalVolOverwrite) {
73 for (
const auto& iter : *
mesher_->layout()) {
74 const Size i = iter.index();
77 vol1[i] =
localVol1_->localVol(0.5*(t1+t2),
x_[i],
true);
78 vol2[i] =
localVol2_->localVol(0.5*(t1+t2),
y_[i],
true);
97 ->blackVolatility()->blackForwardVol(t1, t2,
p1_->x0());
100 ->blackVolatility()->blackForwardVol(t1, t2,
p2_->x0());
120 if (direction == 0) {
123 else if (direction == 1) {
127 QL_FAIL(
"direction is too large");
133 if (direction == 0) {
136 else if (direction == 1) {
140 QL_FAIL(
"direction is too large");
1-D array used in linear algebra.
const ext::shared_ptr< LocalVolTermStructure > localVol2_
Fdm2dBlackScholesOp(const ext::shared_ptr< FdmMesher > &mesher, const ext::shared_ptr< GeneralizedBlackScholesProcess > &p1, const ext::shared_ptr< GeneralizedBlackScholesProcess > &p2, Real correlation, Time maturity, bool localVol=false, Real illegalLocalVolOverwrite=-Null< Real >())
Array solve_splitting(Size direction, const Array &x, Real s) const override
Size size() const override
const NinePointLinearOp corrMapTemplate_
Array preconditioner(const Array &r, Real s) const override
std::vector< SparseMatrix > toMatrixDecomp() const override
const ext::shared_ptr< GeneralizedBlackScholesProcess > p1_
Array apply_mixed(const Array &x) const override
void setTime(Time t1, Time t2) override
Time is required.
NinePointLinearOp corrMapT_
Array apply(const Array &x) const override
Array apply_direction(Size direction, const Array &x) const override
const ext::shared_ptr< FdmMesher > mesher_
const ext::shared_ptr< GeneralizedBlackScholesProcess > p2_
const ext::shared_ptr< LocalVolTermStructure > localVol1_
const Real illegalLocalVolOverwrite_
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
SparseMatrix toMatrix() const override
SparseMatrix toMatrix() const override
Array apply(const Array &r) const override
NinePointLinearOp mult(const Array &u) const
#define QL_FAIL(message)
throw an error (possibly with file and line information)
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 Exp(const Array &v)
ext::shared_ptr< YieldTermStructure > r
second order mixed derivative linear operator