20#include <ql/methods/finitedifferences/meshers/fdmmesher.hpp>
21#include <ql/methods/finitedifferences/operators/secondderivativeop.hpp>
28 const QuantLib::ext::shared_ptr<QuantLib::FdmMesher>& mesher,
29 const QuantLib::ext::shared_ptr<DefaultableEquityJumpDiffusionModel>& model,
const Size direction,
30 const std::function<Real(Real, Real, Real)>& recovery,
const Handle<QuantLib::YieldTermStructure>& discountingCurve,
31 const Handle<QuantLib::Quote>& discountingSpread,
32 const Handle<QuantLib::DefaultProbabilityTermStructure>& addCreditCurve,
33 const std::function<Real(Real, Real, Real)>& addRecovery)
34 : mesher_(mesher), model_(model), direction_(direction), recovery_(recovery), discountingCurve_(discountingCurve),
35 addCreditCurve_(addCreditCurve), addRecovery_(addRecovery), discountingSpread_(discountingSpread),
36 dxMap_(FirstDerivativeOp(direction, mesher)), dxxMap_(SecondDerivativeOp(direction, mesher)),
37 mapT_(direction, mesher), recoveryTerm_(mesher_->locations(direction).size()) {}
50 for (Size i = 0; i < h.size(); ++i) {
69 "FdmDefaultableEquityJumpDiffusionOp: addCreditCurve implies zero survival probability at t = "
71 <<
", this can not be handled. Check the credit curve / security spread provided in the market "
72 "data. If this happens during a spread imply, the target price might not be ataainable even "
76 std::fill(h2.begin(), h2.end(), tmp);
79 Array drift(n, r - q - 0.5 * v);
80 if (
model_->adjustEquityForward())
81 drift +=
model_->eta() * h;
82 mapT_.axpyb(drift,
dxMap_,
dxxMap_.mult(Array(n, 0.5 * v)), -(Array(n, r_dis) + h + h2));
84 for (Size i = 0; i < n; ++i) {
102 Array retVal(r.size(), 0.0);
108 return mapT_.apply(r);
110 Array retVal(r.size(), 0.0);
117 return mapT_.solve_splitting(r, s, 1.0);
128#if !defined(QL_NO_UBLAS_SUPPORT)
130 std::vector<SparseMatrix> retVal(1,
mapT_.toMatrix());
std::function< Real(Real, Real, Real)> recovery_
Handle< QuantLib::DefaultProbabilityTermStructure > addCreditCurve_
Size size() const override
QuantLib::TripleBandLinearOp dxxMap_
Handle< QuantLib::YieldTermStructure > discountingCurve_
Array apply_direction(Size direction, const Array &r) const override
Array preconditioner(const Array &r, Real s) const override
std::function< Real(Real)> conversionRatio_
QuantLib::ext::shared_ptr< QuantLib::FdmMesher > mesher_
std::vector< QuantLib::SparseMatrix > toMatrixDecomp() const override
FdmDefaultableEquityJumpDiffusionOp(const QuantLib::ext::shared_ptr< QuantLib::FdmMesher > &mesher, const QuantLib::ext::shared_ptr< DefaultableEquityJumpDiffusionModel > &model, const Size direction=0, const std::function< Real(Real, Real, Real)> &recovery={}, const Handle< QuantLib::YieldTermStructure > &discountingCurve=Handle< QuantLib::YieldTermStructure >(), const Handle< QuantLib::Quote > &discountingSpread=Handle< QuantLib::Quote >(), const Handle< QuantLib::DefaultProbabilityTermStructure > &addCreditCurve=Handle< QuantLib::DefaultProbabilityTermStructure >(), const std::function< Real(Real, Real, Real)> &addRecovery={})
void setTime(Time t1, Time t2) override
Array apply_mixed(const Array &r) const override
Handle< QuantLib::Quote > discountingSpread_
Array solve_splitting(Size direction, const Array &r, Real s) const override
QuantLib::FirstDerivativeOp dxMap_
Array apply(const Array &r) const override
void setConversionRatio(const std::function< Real(Real)> &conversionRatio)
QuantLib::TripleBandLinearOp mapT_
QuantLib::ext::shared_ptr< DefaultableEquityJumpDiffusionModel > model_
std::function< Real(Real, Real, Real)> addRecovery_
Filter close_enough(const RandomVariable &x, const RandomVariable &y)