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 fdmhullwhiteop.hpp
21     \brief FDM operator for the Hull-White interest rate model
22 */
23 
24 #ifndef quantlib_fdm_hull_white_op_hpp
25 #define quantlib_fdm_hull_white_op_hpp
26 
27 #include <ql/methods/finitedifferences/operators/triplebandlinearop.hpp>
28 #include <ql/methods/finitedifferences/operators/fdmlinearopcomposite.hpp>
29 
30 namespace QuantLib {
31 
32     class FdmMesher;
33     class HullWhite;
34 
35     class FdmHullWhiteOp : public FdmLinearOpComposite {
36       public:
37 
38         FdmHullWhiteOp(
39             const ext::shared_ptr<FdmMesher>& mesher,
40             const ext::shared_ptr<HullWhite>& model,
41             Size direction);
42 
43         Size size() const;
44 
45         //! Time \f$t1 <= t2\f$ is required
46         void setTime(Time t1, Time t2);
47 
48         Disposable<Array> apply(const Array& r) const;
49         Disposable<Array> apply_mixed(const Array& r) const;
50         Disposable<Array> apply_direction(Size direction, const Array& r) const;
51         Disposable<Array>
52             solve_splitting(Size direction, const Array& r, Real s) const;
53         Disposable<Array> preconditioner(const Array& r, Real s) const;
54 
55 #if !defined(QL_NO_UBLAS_SUPPORT)
56         Disposable<std::vector<SparseMatrix> > toMatrixDecomp() const;
57 #endif
58       private:
59         const Size direction_;
60         const Array x_;
61         const TripleBandLinearOp dzMap_;
62         TripleBandLinearOp mapT_;
63         const ext::shared_ptr<HullWhite> model_;
64     };
65 }
66 
67 #endif
68