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_GEN_INTE_H 00024 #define O2SCL_GEN_INTE_H 00025 00026 #ifndef DOXYGENP 00027 namespace o2scl { 00028 #endif 00029 00030 /** 00031 \brief Generalized multi-dimensional integration [abstract base] 00032 00033 In order to allow the user to specify only three functions (for 00034 the integrand, the lower limits, and the upper limits) the first 00035 integer variable is used to distinguish among the variable 00036 limits. So the function \f$ a_0() \f$ is just lower(0,NULL,vp) 00037 where vp is a void pointer, the function \f$ a_1 \f$ is 00038 lower(1,x,vp) where x is a 1-dimensional vector, and the 00039 function \f$ a_i \f$ is lower(i,x,vp) where x is an 00040 i-dimensional vector. Similarly, the function \f$ b_i \f$ is 00041 upper(i,x,vp) where x is an i-dimensional vector. 00042 */ 00043 template<class param_t, class func_t, class lfunc_t, class ufunc_t, 00044 class vec_t=ovector_view> class gen_inte { 00045 00046 public: 00047 00048 /** \brief Verbosity 00049 */ 00050 int verbose; 00051 00052 /** \brief The maximum "uncertainty" in the value of the integral 00053 */ 00054 double tolf; 00055 00056 gen_inte() { 00057 tolf=1.0e-8; 00058 verbose=0; 00059 interror=0.0; 00060 } 00061 00062 virtual ~gen_inte() {} 00063 00064 /** \brief Integrate function \c func from 00065 \f$ x_i=f_i(x_i) \f$ to \f$ x_i=g_i(x_i) \f$ for 00066 \f$ 0<i<\mathrm{ndim}-1 \f$. 00067 00068 */ 00069 virtual double ginteg(func_t &func, size_t ndim, lfunc_t &a, ufunc_t &b, 00070 param_t &pa)=0; 00071 00072 /** \brief Integrate function \c func from 00073 \f$ x_i=f_i(x_i) \f$ to \f$ x_i=g_i(x_i) \f$ for 00074 \f$ 0<i<\mathrm{ndim}-1 \f$. 00075 00076 */ 00077 virtual int ginteg_err(func_t &func, size_t ndim, lfunc_t &a, 00078 ufunc_t &b, param_t &pa, double &res, 00079 double &err) { 00080 res=ginteg(func,ndim,a,b,pa); 00081 return 0; 00082 } 00083 00084 /** \brief Return the error in the result from the last call to 00085 ginteg() or ginteg_err() 00086 00087 This will quietly return zero if no integrations have been 00088 performed. 00089 */ 00090 double get_error() { return interror; } 00091 00092 /// Return string denoting type ("gen_inte") 00093 const char *type() { return "gen_inte"; } 00094 00095 #ifndef DOXYGEN_INTERNAL 00096 00097 protected: 00098 00099 /// The uncertainty for the last integration computation 00100 double interror; 00101 00102 #endif 00103 00104 }; 00105 00106 #ifndef DOXYGENP 00107 } 00108 #endif 00109 00110 #endif 00111 00112 00113 00114 00115 00116
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