1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* 4 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl 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 expliciteuler.hpp 21 \brief explicit Euler scheme for finite difference methods 22 */ 23 24 #ifndef quantlib_explicit_euler_hpp 25 #define quantlib_explicit_euler_hpp 26 27 #include <ql/methods/finitedifferences/mixedscheme.hpp> 28 29 namespace QuantLib { 30 31 //! %Forward Euler scheme for finite difference methods 32 /*! See sect. \ref findiff for details on the method. 33 34 In this implementation, the passed operator must be derived 35 from either TimeConstantOperator or TimeDependentOperator. 36 Also, it must implement at least the following interface: 37 38 \code 39 typedef ... array_type; 40 41 // copy constructor/assignment 42 // (these will be provided by the compiler if none is defined) 43 Operator(const Operator&); 44 Operator& operator=(const Operator&); 45 46 // inspectors 47 Size size(); 48 49 // modifiers 50 void setTime(Time t); 51 52 // operator interface 53 array_type applyTo(const array_type&); 54 static Operator identity(Size size); 55 56 // operator algebra 57 Operator operator*(Real, const Operator&); 58 Operator operator-(const Operator&, const Operator&); 59 \endcode 60 61 \todo add Richardson extrapolation 62 63 \ingroup findiff 64 */ 65 template <class Operator> 66 class ExplicitEuler : public MixedScheme<Operator> { 67 public: 68 // typedefs 69 typedef OperatorTraits<Operator> traits; 70 typedef typename traits::operator_type operator_type; 71 typedef typename traits::array_type array_type; 72 typedef typename traits::bc_type bc_type; 73 typedef typename traits::bc_set bc_set; 74 typedef typename traits::condition_type condition_type; 75 // constructors ExplicitEuler(const operator_type & L,const std::vector<ext::shared_ptr<bc_type>> & bcs)76 ExplicitEuler(const operator_type& L, 77 const std::vector<ext::shared_ptr<bc_type> >& bcs) 78 : MixedScheme<Operator>(L, 0.0, bcs) {} 79 }; 80 81 } 82 83 84 #endif 85