1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 /*
4  Copyright (C) 2011 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 FdmAffineModelswapinnervalue.cpp
21 */
22 
23 #include <ql/models/shortrate/twofactormodels/g2.hpp>
24 #include <ql/models/shortrate/onefactormodels/hullwhite.hpp>
25 #include <ql/methods/finitedifferences/utilities/fdmaffinemodelswapinnervalue.hpp>
26 
27 namespace QuantLib {
28 
29     template <>
getState(const ext::shared_ptr<HullWhite> & model,Time t,const FdmLinearOpIterator & iter) const30     Disposable<Array> FdmAffineModelSwapInnerValue<HullWhite>::getState(
31         const ext::shared_ptr<HullWhite>& model, Time t,
32         const FdmLinearOpIterator& iter) const {
33 
34         Array retVal(1, model->dynamics()->shortRate(t,
35                                     mesher_->location(iter, direction_)));
36         return retVal;
37     }
38 
39     template <>
getState(const ext::shared_ptr<G2> &,Time,const FdmLinearOpIterator & iter) const40     Disposable<Array> FdmAffineModelSwapInnerValue<G2>::getState(
41         const ext::shared_ptr<G2>&, Time,
42         const FdmLinearOpIterator& iter) const {
43 
44         Array retVal(2);
45         retVal[0] = mesher_->location(iter, direction_);
46         retVal[1] = mesher_->location(iter, direction_+1);
47 
48         return retVal;
49     }
50 
51 }
52