Coverage Report

Created: 2025-08-28 06:30

/src/quantlib/ql/experimental/finitedifferences/fdmklugeextousolver.hpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2011 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 fdmklugeextousolver.hpp
21
    \brief Kluge/extended Ornstein-Uhlenbeck FDM solver
22
*/
23
24
#ifndef quantlib_fdm_kluge_ou_solver_hpp
25
#define quantlib_fdm_kluge_ou_solver_hpp
26
27
#include <ql/experimental/finitedifferences/fdmklugeextouop.hpp>
28
#include <ql/experimental/processes/klugeextouprocess.hpp>
29
#include <ql/handle.hpp>
30
#include <ql/methods/finitedifferences/solvers/fdmbackwardsolver.hpp>
31
#include <ql/methods/finitedifferences/solvers/fdmndimsolver.hpp>
32
#include <ql/methods/finitedifferences/solvers/fdmsolverdesc.hpp>
33
#include <ql/patterns/lazyobject.hpp>
34
#include <utility>
35
36
namespace QuantLib {
37
38
    class ExtOUWithJumpsProcess;
39
    class ExtendedOrnsteinUhlenbeckProcess;
40
41
    template <Size N=3>
42
    class FdmKlugeExtOUSolver : public LazyObject {
43
      public:
44
        FdmKlugeExtOUSolver(Handle<KlugeExtOUProcess> klugeOUProcess,
45
                            ext::shared_ptr<YieldTermStructure> rTS,
46
                            FdmSolverDesc solverDesc,
47
                            const FdmSchemeDesc& schemeDesc = FdmSchemeDesc::Hundsdorfer())
48
0
        : klugeOUProcess_(std::move(klugeOUProcess)), rTS_(std::move(rTS)),
49
0
          solverDesc_(std::move(solverDesc)), schemeDesc_(schemeDesc) {
50
0
            registerWith(klugeOUProcess_);
51
0
        }
Unexecuted instantiation: QuantLib::FdmKlugeExtOUSolver<3ul>::FdmKlugeExtOUSolver(QuantLib::Handle<QuantLib::KlugeExtOUProcess>, boost::shared_ptr<QuantLib::YieldTermStructure>, QuantLib::FdmSolverDesc, QuantLib::FdmSchemeDesc const&)
Unexecuted instantiation: QuantLib::FdmKlugeExtOUSolver<4ul>::FdmKlugeExtOUSolver(QuantLib::Handle<QuantLib::KlugeExtOUProcess>, boost::shared_ptr<QuantLib::YieldTermStructure>, QuantLib::FdmSolverDesc, QuantLib::FdmSchemeDesc const&)
52
53
0
        Real valueAt(const std::vector<Real>& x) const {
54
0
            calculate();
55
0
            return solver_->interpolateAt(x);
56
0
        }
Unexecuted instantiation: QuantLib::FdmKlugeExtOUSolver<3ul>::valueAt(std::__1::vector<double, std::__1::allocator<double> > const&) const
Unexecuted instantiation: QuantLib::FdmKlugeExtOUSolver<4ul>::valueAt(std::__1::vector<double, std::__1::allocator<double> > const&) const
57
58
      protected:
59
0
        void performCalculations() const override {
60
0
            ext::shared_ptr<FdmLinearOpComposite>op(
61
0
                new FdmKlugeExtOUOp(solverDesc_.mesher,
62
0
                                    klugeOUProcess_.currentLink(),
63
0
                                    rTS_, solverDesc_.bcSet, 16));
64
65
0
            solver_ = ext::shared_ptr<FdmNdimSolver<N> >(
66
0
                          new FdmNdimSolver<N>(solverDesc_, schemeDesc_, op));
67
0
        }
Unexecuted instantiation: QuantLib::FdmKlugeExtOUSolver<3ul>::performCalculations() const
Unexecuted instantiation: QuantLib::FdmKlugeExtOUSolver<4ul>::performCalculations() const
68
69
      private:
70
        const Handle<KlugeExtOUProcess> klugeOUProcess_;
71
        const ext::shared_ptr<YieldTermStructure> rTS_;
72
73
        const FdmSolverDesc solverDesc_;
74
        const FdmSchemeDesc schemeDesc_;
75
76
        mutable ext::shared_ptr<FdmNdimSolver<N> > solver_;
77
        BOOST_STATIC_ASSERT(N >= 3); // NOLINT(readability-simplify-boolean-expr)
78
                                     // KlugeExtOU solver can't be applied on meshes
79
                                     // with less than three dimensions
80
    };
81
}
82
83
#endif