Flow123d  release_3.0.0-916-g95df358
adaptivesimpson.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file adaptivesimpson.hh
15  * @brief
16  */
17 
18 #ifndef ADAPTIVESIMPSON_H
19 #define ADAPTIVESIMPSON_H
20 
21 template <class Type> class FunctorBase;
22 
23 #define MAX_RECURSION 1e+7
24 
25 
26 ///Static class implementing integration using Simpson's rule.
27 /** Uses 3-point Simpson's rule to evaluate an intergral on interval a,b.
28  * Divides interval in halves in recusion until the difference
29  * between values of Simpson's rule before and after division is
30  * smaller then \f$ 15\epsilon \f$.
31  */
33 {
34  private:
35  ///Evaluates the Simpson's rule.
36  static double Simpson ( const double& h, const double &fa, const double &fc, const double &fb );
37 
38  ///the recursive method
39  static double SimpsonAd( FunctorBase<double> &func,
40  const double& h, const double &a, const double &c, const double &b,
41  const double &fa, const double &fc, const double &fb,
42  const double &sx, const double &tol, long &recursion );
43 
44  public:
45 
46  ///main method that starts the evaluation and calls the recursion
47  static double AdaptSimpson( FunctorBase<double> &func,
48  const double& a, const double& b,
49  const double& tol );
50 };
51 
52 
53 
54 #endif //ADAPTIVESIMPSON_H
static double SimpsonAd(FunctorBase< double > &func, const double &h, const double &a, const double &c, const double &b, const double &fa, const double &fc, const double &fb, const double &sx, const double &tol, long &recursion)
the recursive method
Static class implementing integration using Simpson&#39;s rule.
Abstract templated explicit functor class.
static double AdaptSimpson(FunctorBase< double > &func, const double &a, const double &b, const double &tol)
main method that starts the evaluation and calls the recursion
static double Simpson(const double &h, const double &fa, const double &fc, const double &fb)
Evaluates the Simpson&#39;s rule.