1/*
2 Copyright (C) 2007 François du Vignaud
3
4 This file is part of QuantLib, a free-software/open-source library
5 for financial quantitative analysts and developers - http://quantlib.org/
6
7 QuantLib is free software: you can redistribute it and/or modify it
8 under the terms of the QuantLib license. You should have received a
9 copy of the license along with this program; if not, please email
10 <quantlib-dev@lists.sf.net>. The license is also available online at
11 <http://quantlib.org/license.shtml>.
12
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the license for more details.
16*/
17
18/*! \file integral.hpp
19\brief Integrators base class definition
20*/
21
22#ifndef quantlib_math_integrator_hpp
23#define quantlib_math_integrator_hpp
24
25#include <ql/types.hpp>
26#include <ql/functional.hpp>
27
28namespace QuantLib {
29
30 class Integrator{
31 public:
32 Integrator(Real absoluteAccuracy,
33 Size maxEvaluations);
34 virtual ~Integrator() = default;
35
36 Real operator()(const ext::function<Real (Real)>& f,
37 Real a,
38 Real b) const;
39
40 //! \name Modifiers
41 //@{
42 void setAbsoluteAccuracy(Real);
43 void setMaxEvaluations(Size);
44 //@}
45
46 //! \name Inspectors
47 //@{
48 Real absoluteAccuracy() const;
49 Size maxEvaluations() const;
50 //@}
51
52 Real absoluteError() const ;
53
54 Size numberOfEvaluations() const;
55
56 virtual bool integrationSuccess() const;
57
58 protected:
59 virtual Real integrate(const ext::function<Real (Real)>& f,
60 Real a,
61 Real b) const = 0;
62 void setAbsoluteError(Real error) const;
63 void setNumberOfEvaluations(Size evaluations) const;
64 void increaseNumberOfEvaluations(Size increase) const;
65 private:
66 Real absoluteAccuracy_;
67 mutable Real absoluteError_;
68 Size maxEvaluations_;
69 mutable Size evaluations_;
70 };
71
72}
73
74
75#endif
76

source code of quantlib/ql/math/integrals/integral.hpp