/src/quantlib/ql/methods/finitedifferences/schemes/boundaryconditionschemehelper.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) 2012 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 | | |
21 | | /*! \file boundaryconditionschemehelper.hpp |
22 | | */ |
23 | | |
24 | | #ifndef quantlib_boundary_condition_scheme_helper_hpp |
25 | | #define quantlib_boundary_condition_scheme_helper_hpp |
26 | | |
27 | | #include <ql/methods/finitedifferences/utilities/fdmboundaryconditionset.hpp> |
28 | | #include <utility> |
29 | | |
30 | | namespace QuantLib { |
31 | | |
32 | | class BoundaryConditionSchemeHelper { |
33 | | public: |
34 | | typedef OperatorTraits<FdmLinearOp>::array_type array_type; |
35 | | typedef OperatorTraits<FdmLinearOp>::operator_type operator_type; |
36 | | |
37 | | explicit BoundaryConditionSchemeHelper(OperatorTraits<FdmLinearOp>::bc_set bcSet) |
38 | 0 | : bcSet_(std::move(bcSet)) {} |
39 | | |
40 | 0 | void applyBeforeApplying(operator_type& op) const { |
41 | 0 | for (const auto& i : bcSet_) |
42 | 0 | i->applyBeforeApplying(op); |
43 | 0 | } |
44 | 0 | void applyBeforeSolving(operator_type& op, array_type& a) const { |
45 | 0 | for (const auto& i : bcSet_) |
46 | 0 | i->applyBeforeSolving(op, a); |
47 | 0 | } |
48 | 0 | void applyAfterApplying(array_type& a) const { |
49 | 0 | for (const auto& i : bcSet_) |
50 | 0 | i->applyAfterApplying(a); |
51 | 0 | } |
52 | 0 | void applyAfterSolving(array_type& a) const { |
53 | 0 | for (const auto& i : bcSet_) |
54 | 0 | i->applyAfterSolving(a); |
55 | 0 | } |
56 | 0 | void setTime(Time t) const { |
57 | 0 | for (const auto& i : bcSet_) |
58 | 0 | i->setTime(t); |
59 | 0 | } |
60 | | |
61 | | private: |
62 | | BoundaryConditionSchemeHelper() = default; |
63 | | OperatorTraits<FdmLinearOp>::bc_set bcSet_; |
64 | | }; |
65 | | |
66 | | } |
67 | | |
68 | | #endif |