QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
gausslobattointegral.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) 2008 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 gausslobattointegral.hpp
21 \brief integral of a one-dimensional function using the adaptive
22 Gauss-Lobatto integral
23*/
24
25#ifndef quantlib_gauss_lobatto_integral_hpp
26#define quantlib_gauss_lobatto_integral_hpp
27
28#include <ql/errors.hpp>
29#include <ql/utilities/null.hpp>
31
32namespace QuantLib {
33
34 //! Integral of a one-dimensional function
35 /*! Given a target accuracy \f$ \epsilon \f$, the integral of
36 a function \f$ f \f$ between \f$ a \f$ and \f$ b \f$ is
37 calculated by means of the Gauss-Lobatto formula
38 */
39
40 /*! References:
41 This algorithm is a C++ implementation of the algorithm outlined in
42
43 W. Gander and W. Gautschi, Adaptive Quadrature - Revisited.
44 BIT, 40(1):84-101, March 2000. CS technical report:
45 ftp.inf.ethz.ch/pub/publications/tech-reports/3xx/306.ps.gz
46
47 The original MATLAB version can be downloaded here
48 http://www.inf.ethz.ch/personal/gander/adaptlob.m
49 */
50
52 public:
53 GaussLobattoIntegral(Size maxIterations,
54 Real absAccuracy,
55 Real relAccuracy = Null<Real>(),
56 bool useConvergenceEstimate = true);
57
58 protected:
59 Real integrate(const ext::function<Real(Real)>& f, Real a, Real b) const override;
60
61 Real adaptivGaussLobattoStep(const ext::function<Real (Real)>& f,
62 Real a, Real b, Real fa, Real fb,
63 Real is) const;
64 Real calculateAbsTolerance(const ext::function<Real (Real)>& f,
65 Real a, Real b) const;
66
69 const static Real alpha_, beta_, x1_, x2_, x3_;
70 };
71}
72#endif
Integral of a one-dimensional function.
Real integrate(const ext::function< Real(Real)> &f, Real a, Real b) const override
Real adaptivGaussLobattoStep(const ext::function< Real(Real)> &f, Real a, Real b, Real fa, Real fb, Real is) const
Real calculateAbsTolerance(const ext::function< Real(Real)> &f, Real a, Real b) const
template class providing a null value for a given type.
Definition: null.hpp:76
Classes and functions for error handling.
ext::function< Real(Real)> b
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Integrators base class definition.
Definition: any.hpp:35
null values