1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* 4 Copyright (C) 2018 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 methodoflinesscheme.hpp 21 \brief Method of Lines scheme 22 */ 23 24 #ifndef quantlib_method_of_lines_scheme_hpp 25 #define quantlib_method_of_lines_scheme_hpp 26 27 #include <ql/methods/finitedifferences/operatortraits.hpp> 28 #include <ql/methods/finitedifferences/operators/fdmlinearopcomposite.hpp> 29 #include <ql/methods/finitedifferences/schemes/boundaryconditionschemehelper.hpp> 30 31 namespace QuantLib { 32 33 class MethodOfLinesScheme { 34 public: 35 // typedefs 36 typedef OperatorTraits<FdmLinearOp> traits; 37 typedef traits::operator_type operator_type; 38 typedef traits::array_type array_type; 39 typedef traits::bc_set bc_set; 40 typedef traits::condition_type condition_type; 41 42 // constructors 43 MethodOfLinesScheme(Real eps, 44 Real relInitStepSize, 45 const ext::shared_ptr<FdmLinearOpComposite>& map, 46 const bc_set& bcSet = bc_set()); 47 48 void step(array_type& a, Time t); 49 void setStep(Time dt); 50 51 protected: 52 //apply for QuantLib's Runge-Kutta implementation 53 Disposable<std::vector<Real> > 54 apply(Time, const std::vector<Real>&) const; 55 56 Time dt_; 57 const Real eps_, relInitStepSize_; 58 const ext::shared_ptr<FdmLinearOpComposite> map_; 59 const BoundaryConditionSchemeHelper bcSet_; 60 }; 61 } 62 63 #endif 64