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 template<class param_t, class func_t=funct<param_t> > class inte { 00037 00038 public: 00039 00040 inte() { 00041 tolf=1.0e-8; 00042 tolx=1.0e-8; 00043 verbose=0; 00044 interror=0.0; 00045 err_nonconv=true; 00046 last_conv=0; 00047 } 00048 00049 virtual ~inte() {} 00050 00051 /** \brief Verbosity 00052 */ 00053 int verbose; 00054 00055 /// The most recent number of iterations taken 00056 int last_iter; 00057 00058 /** \brief The maximum relative uncertainty 00059 in the value of the integral (default \f$ 10^{-8} \f$) 00060 */ 00061 double tolf; 00062 00063 /** \brief The maximum absolute uncertainty 00064 in the value of the integral (default \f$ 10^{-8} \f$) 00065 */ 00066 double tolx; 00067 00068 /// If true, call the error handler if the routine does not "converge" 00069 bool err_nonconv; 00070 00071 /** \brief Zero if last call to integ() or integ_err() converged 00072 00073 This is particularly useful if err_nonconv is false to test 00074 if the last integration call converged. 00075 */ 00076 int last_conv; 00077 00078 /** \brief Integrate function \c func from \c a to \c b. 00079 */ 00080 virtual double integ(func_t &func, double a, double b, param_t &pa)=0; 00081 00082 /** \brief Integrate function \c func from \c a to \c b and place 00083 the result in \c res and the error in \c err 00084 */ 00085 virtual int integ_err(func_t &func, double a, double b, 00086 param_t &pa, double &res, double &err)=0; 00087 00088 /** \brief Return the error in the result from the last call to 00089 integ() 00090 00091 This will quietly return zero if no integrations have been 00092 performed. 00093 */ 00094 double get_error() { return interror; } 00095 00096 /// Return string denoting type ("inte") 00097 virtual const char *type() { return "inte"; } 00098 00099 #ifndef DOXYGEN_INTERNAL 00100 00101 protected: 00102 00103 /// The uncertainty for the last integration computation 00104 double interror; 00105 00106 #endif 00107 00108 }; 00109 00110 #ifndef DOXYGENP 00111 } 00112 #endif 00113 00114 #endif 00115 00116 00117 00118
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