/usr/include/ql/math/integrals/kronrodintegral.hpp is in libquantlib0-dev 1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2007 François du Vignaud
Copyright (C) 2003 Niels Elken Sønderby
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
/*! \file kronrodintegral.hpp
\brief Integral of a 1-dimensional function using the Gauss-Kronrod method
*/
#ifndef quantlib_kronrod_integral_hpp
#define quantlib_kronrod_integral_hpp
#include <ql/errors.hpp>
#include <ql/types.hpp>
#include <ql/utilities/null.hpp>
#include <ql/math/integrals/integral.hpp>
#include <boost/function.hpp>
namespace QuantLib {
//! Integral of a 1-dimensional function using the Gauss-Kronrod methods
/*! This class provide a non-adaptive integration procedure which
uses fixed Gauss-Kronrod abscissae to sample the integrand at
a maximum of 87 points. It is provided for fast integration
of smooth functions.
This function applies the Gauss-Kronrod 10-point, 21-point, 43-point
and 87-point integration rules in succession until an estimate of the
integral of f over (a, b) is achieved within the desired absolute and
relative error limits, epsabs and epsrel. The function returns the
final approximation, result, an estimate of the absolute error,
abserr and the number of function evaluations used, neval. The
Gauss-Kronrod rules are designed in such a way that each rule uses
all the results of its predecessors, in order to minimize the total
number of function evaluations.
*/
class GaussKronrodNonAdaptive : public Integrator {
public:
GaussKronrodNonAdaptive(Real absoluteAccuracy,
Size maxEvaluations,
Real relativeAccuracy);
void setRelativeAccuracy(Real);
Real relativeAccuracy() const;
protected:
Real integrate(const boost::function<Real (Real)>& f,
Real a,
Real b) const;
private:
Real relativeAccuracy_;
};
//! Integral of a 1-dimensional function using the Gauss-Kronrod methods
/*! This class provide an adaptive integration procedure using 15
points Gauss-Kronrod integration rule. This is more robust in
that it allows to integrate less smooth functions (though
singular functions should be integrated using dedicated
algorithms) but less efficient beacuse it does not reuse
precedently computed points during computation steps.
References:
Gauss-Kronrod Integration
<http://mathcssun1.emporia.edu/~oneilcat/ExperimentApplet3/ExperimentApplet3.html>
NMS - Numerical Analysis Library
<http://www.math.iastate.edu/burkardt/f_src/nms/nms.html>
\test the correctness of the result is tested by checking it
against known good values.
*/
class GaussKronrodAdaptive : public Integrator {
public:
GaussKronrodAdaptive(Real tolerance,
Size maxFunctionEvaluations = Null<Size>());
protected:
Real integrate(const boost::function<Real (Real)>& f,
Real a,
Real b) const;
private:
Real integrateRecursively(const boost::function<Real (Real)>& f,
Real a,
Real b,
Real tolerance) const;
};
}
#endif
|