/* 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 ferdinando@ametrano.net The license is also available online at http://quantlib.org/html/license.html 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 nesquant_kronrod_integral_h #define nesquant_kronrod_integral_h // #ifndef quantlib_kronrod_integral_h // #define quantlib_kronrod_integral_h #include #include #include // namespace QuantLib { namespace NesQuant { namespace Math { //! Integral of a 1-dimensional function using the Gauss-Kronrod method /*! References: \n Gauss-Kronrod Integration \n NMS - Numerical Analysis Library */ class KronrodIntegral { public: KronrodIntegral(double tolerance_, long maxFunctionEvaluations); template double operator()(const F& f, double a, double b) { QL_REQUIRE(a < b, "to compute an integral on [a,b] it must be a QL_EPSILON, "tolerance must be > 0"); QL_REQUIRE(maxFunctionEvaluations >= 15, "maxFunctionEvaluations must be >= 15"); } } } #endif