00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 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 00029 #ifndef DOXYGENP 00030 namespace o2scl { 00031 #endif 00032 00033 /** \brief Base integration class 00034 */ 00035 template<class param_t, class func_t> class inte { 00036 00037 public: 00038 00039 /** \brief Verbosity 00040 */ 00041 int verbose; 00042 00043 /// The most recent number of iterations taken 00044 int last_iter; 00045 00046 /** \brief The maximum relative uncertainty 00047 in the value of the integral (default \f$ 10^{-8} \f$) 00048 */ 00049 double tolf; 00050 00051 /** \brief The maximum absolute uncertainty 00052 in the value of the integral (default \f$ 10^{-8} \f$) 00053 */ 00054 double tolx; 00055 00056 inte() { 00057 tolf=1.0e-8; 00058 tolx=1.0e-8; 00059 verbose=0; 00060 interror=0.0; 00061 } 00062 00063 virtual ~inte() {} 00064 00065 /** \brief Integrate function \c func from \c a to \c b. 00066 */ 00067 virtual double integ(func_t &func, double a, double b, param_t &pa) { 00068 return 0.0; 00069 } 00070 00071 /** \brief Integrate function \c func from \c a to \c b and place 00072 the result in \c res and the error in \c err 00073 00074 Ideally, if this function succeeds, then \c err should be 00075 less than or close to \ref tolf. 00076 */ 00077 virtual int integ_err(func_t &func, double a, double b, 00078 param_t &pa, double &res, double &err) { 00079 return 0; 00080 } 00081 00082 /** \brief Return the error in the result from the last call to 00083 integ() 00084 00085 This will quietly return zero if no integrations have been 00086 performed. 00087 */ 00088 double get_error() { return interror; } 00089 00090 /// Return string denoting type ("inte") 00091 virtual const char *type() { return "inte"; } 00092 00093 #ifndef DOXYGEN_INTERNAL 00094 00095 protected: 00096 00097 /// The uncertainty for the last integration computation 00098 double interror; 00099 00100 #endif 00101 00102 }; 00103 00104 #ifndef DOXYGENP 00105 } 00106 #endif 00107 00108 #endif 00109 00110 00111 00112
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