38 const ext::shared_ptr<BatesProcess>& batesProcess,
40 const Size integroIntegrationOrder,
41 const ext::shared_ptr<FdmQuantoHelper>& quantoHelper)
42 : lambda_(batesProcess->lambda()), delta_(batesProcess->delta()),
nu_(batesProcess->
nu()),
43 m_(
std::exp(
nu_ + 0.5 * delta_ * delta_) - 1.0),
44 gaussHermiteIntegration_(integroIntegrationOrder),
mesher_(mesher), bcSet_(
std::move(bcSet)),
48 batesProcess->riskFreeRate(),
50 batesProcess->dividendYield(),
54 batesProcess->dividendYield()->dayCounter())),
57 batesProcess->
kappa(),
58 batesProcess->
theta(),
59 batesProcess->
sigma(),
64 const ext::shared_ptr<LinearInterpolation>& interpl,
67 :
x_(x), delta_(delta),
nu_(
nu),
68 bcSet_(bcSet), interpl_(interpl) { }
72 Real valueOfDerivative = (*interpl_)(x,
true);
74 for (
auto iter =
bcSet_.begin(); iter <
bcSet_.end(); ++iter) {
76 const ext::shared_ptr<FdmDirichletBoundary> dirichlet
77 = ext::dynamic_pointer_cast<FdmDirichletBoundary>(*iter);
79 QL_REQUIRE(dirichlet,
"FdmBatesOp can only deal with Dirichlet "
80 "boundary conditions.");
83 = dirichlet->applyAfterApplying(x, valueOfDerivative);
86 return std::exp(-
y*
y)*valueOfDerivative;
95 for (
const auto& iter : *
mesher_->layout()) {
96 const Size i = iter.coordinates()[0];
97 const Size j = iter.coordinates()[1];
99 x[i] =
mesher_->location(iter, 0);
100 f[j][i] =
r[iter.index()];
103 std::vector<ext::shared_ptr<LinearInterpolation> > interpl(
f.rows());
104 for (
Size i=0; i <
f.rows(); ++i) {
105 interpl[i] = ext::make_shared<LinearInterpolation>(
110 for (
const auto& iter : *
mesher_->layout()) {
111 const Size i = iter.coordinates()[0];
112 const Size j = iter.coordinates()[1];
Bates stochastic process, Heston process plus compound Poisson process plus log-normal jump diffusion...
1-D array used in linear algebra.
const_iterator end() const
const_iterator begin() const
IntegroIntegrand(const ext::shared_ptr< LinearInterpolation > &i, const FdmBoundaryConditionSet &bcSet, Real x, Real delta, Real nu)
Real operator()(Real y) const
GaussHermiteIntegration gaussHermiteIntegration_
std::vector< SparseMatrix > toMatrixDecomp() const override
const FdmBoundaryConditionSet bcSet_
Array integro(const Array &r) const
const ext::shared_ptr< FdmMesher > mesher_
FdmBatesOp(const ext::shared_ptr< FdmMesher > &mesher, const ext::shared_ptr< BatesProcess > &batesProcess, FdmBoundaryConditionSet bcSet, Size integroIntegrationOrder, const ext::shared_ptr< FdmQuantoHelper > &quantoHelper=ext::shared_ptr< FdmQuantoHelper >())
Shared handle to an observable.
Square-root stochastic-volatility Heston process.
Matrix used in linear algebra.
purely virtual base class for market observables
market element returning a stored value
Interest-rate term structure.
Term structure with an added spread on the zero yield rate.
#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)
Dirichlet boundary conditions for differential operators.
memory layout of a fdm linear operator
const ext::shared_ptr< FdmMesher > mesher_
@ NoFrequency
null frequency
std::size_t Size
size of a container
linear interpolation between discrete points
matrix used in linear algebra.
OperatorTraits< FdmLinearOp >::bc_set FdmBoundaryConditionSet
ext::shared_ptr< YieldTermStructure > r
Zero spreaded term structure.