| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | |
| 3 | /* |
| 4 | Copyright (C) 2008 Andreas Gaida |
| 5 | Copyright (C) 2008 Ralph Schreyer |
| 6 | Copyright (C) 2008 Klaus Spanderen |
| 7 | |
| 8 | This file is part of QuantLib, a free-software/open-source library |
| 9 | for financial quantitative analysts and developers - http://quantlib.org/ |
| 10 | |
| 11 | QuantLib is free software: you can redistribute it and/or modify it |
| 12 | under the terms of the QuantLib license. You should have received a |
| 13 | copy of the license along with this program; if not, please email |
| 14 | <quantlib-dev@lists.sf.net>. The license is also available online at |
| 15 | <http://quantlib.org/license.shtml>. |
| 16 | |
| 17 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 | FOR A PARTICULAR PURPOSE. See the license for more details. |
| 20 | */ |
| 21 | |
| 22 | /*! \file fdmstepconditioncomposite.hpp |
| 23 | \brief composite of fdm step conditions |
| 24 | */ |
| 25 | |
| 26 | #ifndef quantlib_fdm_step_condition_composite_hpp |
| 27 | #define quantlib_fdm_step_condition_composite_hpp |
| 28 | |
| 29 | #include <ql/time/date.hpp> |
| 30 | #include <ql/time/daycounter.hpp> |
| 31 | #include <ql/instruments/dividendschedule.hpp> |
| 32 | #include <ql/methods/finitedifferences/stepcondition.hpp> |
| 33 | |
| 34 | #include <list> |
| 35 | |
| 36 | namespace QuantLib { |
| 37 | |
| 38 | class FdmMesher; |
| 39 | class Exercise; |
| 40 | class FdmSnapshotCondition; |
| 41 | class FdmInnerValueCalculator; |
| 42 | |
| 43 | class FdmStepConditionComposite : public StepCondition<Array> { |
| 44 | public: |
| 45 | typedef std::list<ext::shared_ptr<StepCondition<Array> > > Conditions; |
| 46 | |
| 47 | FdmStepConditionComposite(const std::list<std::vector<Time> >& stoppingTimes, |
| 48 | Conditions conditions); |
| 49 | |
| 50 | void applyTo(Array& a, Time t) const override; |
| 51 | const std::vector<Time>& stoppingTimes() const; |
| 52 | const Conditions& conditions() const; |
| 53 | |
| 54 | static ext::shared_ptr<FdmStepConditionComposite> joinConditions( |
| 55 | const ext::shared_ptr<FdmSnapshotCondition>& c1, |
| 56 | const ext::shared_ptr<FdmStepConditionComposite>& c2); |
| 57 | |
| 58 | static ext::shared_ptr<FdmStepConditionComposite> vanillaComposite( |
| 59 | const DividendSchedule& schedule, |
| 60 | const ext::shared_ptr<Exercise>& exercise, |
| 61 | const ext::shared_ptr<FdmMesher>& mesher, |
| 62 | const ext::shared_ptr<FdmInnerValueCalculator>& calculator, |
| 63 | const Date& refDate, |
| 64 | const DayCounter& dayCounter); |
| 65 | |
| 66 | private: |
| 67 | std::vector<Time> stoppingTimes_; |
| 68 | const Conditions conditions_; |
| 69 | }; |
| 70 | } |
| 71 | #endif |
| 72 | |