QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
numericalmethod.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb
5 Copyright (C) 2004, 2005 StatPro Italia srl
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file numericalmethod.hpp
22 \brief Numerical method class
23*/
24
25#ifndef quantlib_lattice_hpp
26#define quantlib_lattice_hpp
27
28#include <ql/math/array.hpp>
29#include <ql/timegrid.hpp>
30#include <utility>
31
32namespace QuantLib {
33
34 class DiscretizedAsset;
35
36 //! %Lattice (tree, finite-differences) base class
37 class Lattice {
38 public:
39 explicit Lattice(TimeGrid timeGrid) : t_(std::move(timeGrid)) {}
40 virtual ~Lattice() = default;
41
42 //!\name Inspectors
43 //{
44 const TimeGrid& timeGrid() const { return t_; }
45 //@}
46
47 /*! \name Numerical method interface
48
49 These methods are to be used by discretized assets and
50 must be overridden by developers implementing numerical
51 methods. Users are advised to use the corresponding
52 methods of DiscretizedAsset instead.
53
54 @{
55 */
56
57 //! initialize an asset at the given time.
59 Time time) const = 0;
60
61 /*! Roll back an asset until the given time, performing any
62 needed adjustment.
63 */
65 Time to) const = 0;
66
67 /*! Roll back an asset until the given time, but do not perform
68 the final adjustment.
69
70 \warning In version 0.3.7 and earlier, this method was
71 called rollAlmostBack method and performed
72 pre-adjustment. This is no longer true; when
73 migrating your code, you'll have to replace calls
74 such as:
75 \code
76 method->rollAlmostBack(asset,t);
77 \endcode
78 with the two statements:
79 \code
80 method->partialRollback(asset,t);
81 asset->preAdjustValues();
82 \endcode
83 */
85 Time to) const = 0;
86
87 //! computes the present value of an asset.
88 virtual Real presentValue(DiscretizedAsset&) const = 0;
89
90 //@}
91
92 // this is a smell, but we need it. We'll rethink it later.
93 virtual Array grid(Time) const = 0;
94 protected:
96 };
97
98}
99
100
101#endif
1-D array used in linear algebra.
1-D array used in linear algebra.
Definition: array.hpp:52
Discretized asset class used by numerical methods.
Lattice (tree, finite-differences) base class
virtual void partialRollback(DiscretizedAsset &, Time to) const =0
virtual Real presentValue(DiscretizedAsset &) const =0
computes the present value of an asset.
virtual Array grid(Time) const =0
virtual void initialize(DiscretizedAsset &, Time time) const =0
initialize an asset at the given time.
virtual ~Lattice()=default
const TimeGrid & timeGrid() const
virtual void rollback(DiscretizedAsset &, Time to) const =0
Lattice(TimeGrid timeGrid)
time grid class
Definition: timegrid.hpp:43
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
STL namespace.
discrete time grid