QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
fdmbatesop.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2010 Klaus Spanderen
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file fdmbatesop.hpp
21 \brief Bates linear operator
22*/
23
24#ifndef quantlib_fdm_bates_op_hpp
25#define quantlib_fdm_bates_op_hpp
26
30
31namespace QuantLib {
32
33 class LinearInterpolation;
34 class BatesProcess;
35
37 public:
38 FdmBatesOp(const ext::shared_ptr<FdmMesher>& mesher,
39 const ext::shared_ptr<BatesProcess>& batesProcess,
41 Size integroIntegrationOrder,
42 const ext::shared_ptr<FdmQuantoHelper>& quantoHelper =
43 ext::shared_ptr<FdmQuantoHelper>());
44
45 Size size() const override;
46 void setTime(Time t1, Time t2) override;
47
48 Array apply(const Array& r) const override;
49 Array apply_mixed(const Array& r) const override;
50
51 Array apply_direction(Size direction, const Array& r) const override;
52 Array solve_splitting(Size direction, const Array& r, Real s) const override;
53 Array preconditioner(const Array& r, Real s) const override;
54
55 std::vector<SparseMatrix> toMatrixDecomp() const override;
56
57 private:
59 public:
60 IntegroIntegrand(const ext::shared_ptr<LinearInterpolation>& i,
61 const FdmBoundaryConditionSet& bcSet,
62 Real x, Real delta, Real nu);
63 Real operator()(Real y) const;
64
65 private:
66 const Real x_, delta_, nu_;
68 const ext::shared_ptr<LinearInterpolation>& interpl_;
69 };
70
71 Array integro(const Array& r) const;
72
74
77
78 const ext::shared_ptr<FdmMesher> mesher_;
80 const ext::shared_ptr<FdmHestonOp> hestonOp_;
81 };
82
83 // inline
84 inline Size FdmBatesOp::size() const {
85 return hestonOp_->size();
86 }
87
88 inline void FdmBatesOp::setTime(Time t1, Time t2) {
89 hestonOp_->setTime(t1, t2);
90 }
91
92 inline Array FdmBatesOp::apply(const Array& r) const {
93 return hestonOp_->apply(r) + integro(r);
94 }
95
96 inline Array FdmBatesOp::apply_mixed(const Array& r) const {
97 return hestonOp_->apply_mixed(r) + integro(r);
98 }
99
101 const Array& r) const {
102 return hestonOp_->apply_direction(direction, r);
103 }
104
106 const Array& r,
107 Real s) const{
108 return hestonOp_->solve_splitting(direction, r, s);
109 }
110
112 Real s) const {
113 return hestonOp_->preconditioner(r, s);
114 }
115
116}
117
118#endif
1-D array used in linear algebra.
Definition: array.hpp:52
const ext::shared_ptr< LinearInterpolation > & interpl_
Definition: fdmbatesop.hpp:68
const FdmBoundaryConditionSet & bcSet_
Definition: fdmbatesop.hpp:67
GaussHermiteIntegration gaussHermiteIntegration_
Definition: fdmbatesop.hpp:76
Size size() const override
Definition: fdmbatesop.hpp:84
Array apply_direction(Size direction, const Array &r) const override
Definition: fdmbatesop.hpp:100
Array preconditioner(const Array &r, Real s) const override
Definition: fdmbatesop.hpp:111
std::vector< SparseMatrix > toMatrixDecomp() const override
Definition: fdmbatesop.cpp:122
void setTime(Time t1, Time t2) override
Time is required.
Definition: fdmbatesop.hpp:88
const FdmBoundaryConditionSet bcSet_
Definition: fdmbatesop.hpp:79
Array apply_mixed(const Array &r) const override
Definition: fdmbatesop.hpp:96
Array integro(const Array &r) const
Definition: fdmbatesop.cpp:89
const ext::shared_ptr< FdmMesher > mesher_
Definition: fdmbatesop.hpp:78
Array solve_splitting(Size direction, const Array &r, Real s) const override
Definition: fdmbatesop.hpp:105
const ext::shared_ptr< FdmHestonOp > hestonOp_
Definition: fdmbatesop.hpp:80
Array apply(const Array &r) const override
Definition: fdmbatesop.hpp:92
generalized Gauss-Hermite integration
Heston linear operator.
Integral of a 1-dimensional function using the Gauss quadratures.
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
OperatorTraits< FdmLinearOp >::bc_set FdmBoundaryConditionSet
ext::shared_ptr< YieldTermStructure > r
Real nu
Definition: sabr.cpp:200