QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
richardsonextrapolation.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) 2012 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 richardsonextrapolation.hpp
21*/
22
23#ifndef quantlib_richardson_extrapolation_hpp
24#define quantlib_richardson_extrapolation_hpp
25
26#include <ql/types.hpp>
27#include <ql/utilities/null.hpp>
28#include <ql/functional.hpp>
29
30namespace QuantLib {
31
32 //! Richardson Extrapolation
33 /*! Richardson Extrapolation is a sequence acceleration technique for
34 \f[
35 f(\Delta h) = f_0 + \alpha\cdot (\Delta h)^n + O((\Delta h)^{n+1})
36 \f]
37 */
38
39 /*! References:
40 http://en.wikipedia.org/wiki/Richardson_extrapolation
41 */
42
44 public:
45 /*! Richardon Extrapolation
46 \param f function to be extrapolated to delta_h -> 0
47 \param delta_h step size
48 \param n if known, n is the order of convergence
49 */
50 RichardsonExtrapolation(const ext::function<Real (Real)>& f,
51 Real delta_h, Real n = Null<Real>());
52
53
54 /*! Extrapolation for known order of convergence
55 \param t scaling factor for the step size
56 */
57 Real operator()(Real t=2.0) const;
58
59 /*! Extrapolation for unknown order of convergence
60 \param t first scaling factor for the step size
61 \param s second scaling factor for the step size
62 */
63 Real operator()(Real t, Real s) const;
64
65 private:
68 const Real n_;
69 const ext::function<Real (Real)> f_;
70 };
71}
72
73#endif
template class providing a null value for a given type.
Definition: null.hpp:76
const ext::function< Real(Real)> f_
const DefaultType & t
Maps function, bind and cref to either the boost or std implementation.
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
null values
Custom types.