00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 2009, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_INTE_H 00024 #define O2SCL_INTE_H 00025 00026 #include <cmath> 00027 #include <o2scl/err_hnd.h> 00028 #include <o2scl/funct.h> 00029 00030 #ifndef DOXYGENP 00031 namespace o2scl { 00032 #endif 00033 00034 /** \brief Base integration class [abstract base] 00035 00036 \future It might be useful to have all of the integration 00037 classes report the number of function evaluations used 00038 in addition to the number of iterations which were taken 00039 */ 00040 template<class param_t, class func_t=funct<param_t> > class inte { 00041 00042 public: 00043 00044 inte() { 00045 tolf=1.0e-8; 00046 tolx=1.0e-8; 00047 verbose=0; 00048 interror=0.0; 00049 err_nonconv=true; 00050 last_conv=0; 00051 } 00052 00053 virtual ~inte() {} 00054 00055 /** \brief Verbosity 00056 */ 00057 int verbose; 00058 00059 /// The most recent number of iterations taken 00060 int last_iter; 00061 00062 /** \brief The maximum relative uncertainty 00063 in the value of the integral (default \f$ 10^{-8} \f$) 00064 */ 00065 double tolf; 00066 00067 /** \brief The maximum absolute uncertainty 00068 in the value of the integral (default \f$ 10^{-8} \f$) 00069 */ 00070 double tolx; 00071 00072 /// If true, call the error handler if the routine does not "converge" 00073 bool err_nonconv; 00074 00075 /** \brief Zero if last call to integ() or integ_err() converged 00076 00077 This is particularly useful if err_nonconv is false to test 00078 if the last integration call converged. 00079 */ 00080 int last_conv; 00081 00082 /** \brief Integrate function \c func from \c a to \c b. 00083 */ 00084 virtual double integ(func_t &func, double a, double b, param_t &pa)=0; 00085 00086 /** \brief Integrate function \c func from \c a to \c b and place 00087 the result in \c res and the error in \c err 00088 */ 00089 virtual int integ_err(func_t &func, double a, double b, 00090 param_t &pa, double &res, double &err)=0; 00091 00092 /** \brief Return the error in the result from the last call to 00093 integ() 00094 00095 This will quietly return zero if no integrations have been 00096 performed or if the integrator does not compute an error. 00097 */ 00098 double get_error() { return interror; } 00099 00100 /// Return string denoting type ("inte") 00101 virtual const char *type() { return "inte"; } 00102 00103 #ifndef DOXYGEN_INTERNAL 00104 00105 protected: 00106 00107 /// The uncertainty for the last integration computation 00108 double interror; 00109 00110 #endif 00111 00112 }; 00113 00114 #ifndef DOXYGENP 00115 } 00116 #endif 00117 00118 #endif 00119 00120 00121 00122
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page