/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb Copyright (C) 2005 StatPro Italia srl This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ QuantLib is free software: you can redistribute it and/or modify it under the terms of the QuantLib license. You should have received a copy of the license along with this program; if not, please email . The license is also available online at . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /*! \file latticeshortratemodelengine.hpp \brief Engine for a short-rate model specialized on a lattice */ #ifndef quantlib_short_rate_model_engine_hpp #define quantlib_short_rate_model_engine_hpp #include #include namespace QuantLib { //! Engine for a short-rate model specialized on a lattice /*! Derived engines only need to implement the calculate() method */ template class LatticeShortRateModelEngine : public GenericModelEngine { public: LatticeShortRateModelEngine( const boost::shared_ptr& model, Size timeSteps); LatticeShortRateModelEngine( const boost::shared_ptr& model, const TimeGrid& timeGrid); void update(); protected: TimeGrid timeGrid_; Size timeSteps_; boost::shared_ptr lattice_; }; template LatticeShortRateModelEngine::LatticeShortRateModelEngine( const boost::shared_ptr& model, Size timeSteps) : GenericModelEngine(model), timeSteps_(timeSteps) {} template LatticeShortRateModelEngine::LatticeShortRateModelEngine( const boost::shared_ptr& model, const TimeGrid& timeGrid) : GenericModelEngine(model), timeGrid_(timeGrid), timeSteps_(0) { lattice_ = this->model_->tree(timeGrid); } template void LatticeShortRateModelEngine::update() { if (!timeGrid_.empty()) lattice_ = this->model_->tree(timeGrid_); this->notifyObservers(); } } #endif