All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
inte.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2014, Andrew W. Steiner and Jerry Gagelman
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_INTE_H
24 #define O2SCL_INTE_H
25 
26 /** \file inte.h
27  \brief File defining \ref o2scl::inte
28 */
29 
30 #include <cmath>
31 #include <o2scl/err_hnd.h>
32 #include <o2scl/funct.h>
33 
34 #ifndef DOXYGEN_NO_O2NS
35 namespace o2scl {
36 #endif
37 
38  /** \brief Base integration class [abstract base]
39 
40  \future It might be useful to have all of the integration
41  classes report the number of function evaluations used
42  in addition to the number of iterations which were taken
43  */
44  template<class func_t=funct11> class inte {
45 
46  public:
47 
48  inte() {
49  tol_rel=1.0e-8;
50  tol_abs=1.0e-8;
51  verbose=0;
52  interror=0.0;
53  err_nonconv=true;
54  }
55 
56  virtual ~inte() {}
57 
58  /** \brief Verbosity
59  */
60  int verbose;
61 
62  /// The most recent number of iterations taken
63  size_t last_iter;
64 
65  /** \brief The maximum relative uncertainty
66  in the value of the integral (default \f$ 10^{-8} \f$)
67  */
68  double tol_rel;
69 
70  /** \brief The maximum absolute uncertainty
71  in the value of the integral (default \f$ 10^{-8} \f$)
72  */
73  double tol_abs;
74 
75  /** \brief If true, call the error handler if the routine does not
76  converge or reach the desired tolerance (default true)
77 
78  If this is false, the function proceeds normally and
79  may provide convergence information in the integer return value.
80  */
82 
83  /** \brief Integrate function \c func from \c a to \c b.
84  */
85  virtual double integ(func_t &func, double a, double b) {
86  double res;
87  integ_err(func,a,b,res,this->interror);
88  return res;
89  }
90 
91  /** \brief Integrate function \c func from \c a to \c b and place
92  the result in \c res and the error in \c err
93  */
94  virtual int integ_err(func_t &func, double a, double b,
95  double &res, double &err)=0;
96 
97  /** \brief Return the numerically estimated error in the result from
98  the last call to integ()
99 
100  This will quietly return zero if no integrations have been
101  performed or if the integrator does not estimate the error.
102  */
103  double get_error() { return interror; }
104 
105  /// Return string denoting type ("inte")
106  virtual const char *type() { return "inte"; }
107 
108 #ifndef DOXYGEN_INTERNAL
109 
110  protected:
111 
112  /// The uncertainty for the last integration computation
113  double interror;
114 
115 #endif
116 
117  };
118 
119 #ifndef DOXYGEN_NO_O2NS
120 }
121 #endif
122 
123 #endif
124 
125 
126 
127 
virtual int integ_err(func_t &func, double a, double b, double &res, double &err)=0
Integrate function func from a to b and place the result in res and the error in err.
double get_error()
Return the numerically estimated error in the result from the last call to integ() ...
Definition: inte.h:103
size_t last_iter
The most recent number of iterations taken.
Definition: inte.h:63
bool err_nonconv
If true, call the error handler if the routine does not converge or reach the desired tolerance (defa...
Definition: inte.h:81
virtual double integ(func_t &func, double a, double b)
Integrate function func from a to b.
Definition: inte.h:85
double tol_abs
The maximum absolute uncertainty in the value of the integral (default )
Definition: inte.h:73
Base integration class [abstract base].
Definition: inte.h:44
double interror
The uncertainty for the last integration computation.
Definition: inte.h:113
double tol_rel
The maximum relative uncertainty in the value of the integral (default )
Definition: inte.h:68
int verbose
Verbosity.
Definition: inte.h:60
virtual const char * type()
Return string denoting type ("inte")
Definition: inte.h:106

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).
Hosted at Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads..