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_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 Perform the generalized multi-dimensional integral: 00034 \f[ 00035 \int_{x_0=a_0}^{x_0=b_0} f(x_0) \int_{x_1=a_1(x_0)}^{x_1=b_1(x_0)} 00036 f(x_0, x_1) ... 00037 \int_{x_{\mathrm{n}-1}=a_{\mathrm{n}-1}(x_0,x_1,..,x_{\mathrm{n}-2})}^ 00038 {x_{\mathrm{n}-1}=b_{\mathrm{n}-1}(x_0,x_1,..,x_{\mathrm{n}-2})} 00039 f(x_0,x_1,...,x_{\mathrm{n-1}})~d x_{\mathrm{n}-1}~...~d x_1~d x_0 00040 \f] 00041 00042 The functions \f$ a_i \f$ and \f$ b_i \f$ are specified 00043 in the arguments <tt>a</tt> and <tt>b</tt> to the function 00044 \ref ginteg() or \ref ginteg_err() . 00045 00046 In order to allow the user to specify only three functions (for 00047 the integrand, the lower limits, and the upper limits) the first 00048 argument to the limit and integrand functions is used to 00049 distinguish among the limits for each separate integral. So 00050 first argument to <tt>a</tt> for \f$ a_0() \f$ is 0, and the 00051 first argument to <tt>a</tt> for \f$ a_1() \f$ is 1, etc., and 00052 similarly for the upper limits specified in <tt>b</tt> and 00053 the integrands specified in <tt>func</tt>. 00054 00055 At present, the only implementation of this abstract base 00056 is in \ref comp_gen_inte . 00057 */ 00058 template<class param_t, class func_t, class lfunc_t, class ufunc_t, 00059 class vec_t=ovector_base> class gen_inte { 00060 00061 public: 00062 00063 gen_inte() { 00064 tolf=1.0e-8; 00065 verbose=0; 00066 interror=0.0; 00067 err_nonconv=true; 00068 } 00069 00070 virtual ~gen_inte() {} 00071 00072 /** \brief Verbosity 00073 */ 00074 int verbose; 00075 00076 /** \brief The maximum "uncertainty" in the value of the integral 00077 */ 00078 double tolf; 00079 00080 /// If true, call the error handler if the routine does not "converge" 00081 bool err_nonconv; 00082 00083 /** \brief Integrate function \c func from 00084 \f$ x_i=a_i(x_i) \f$ to \f$ x_i=b_i(x_i) \f$ for 00085 \f$ 0<i<\mathrm{ndim}-1 \f$. 00086 00087 */ 00088 virtual double ginteg(func_t &func, size_t ndim, lfunc_t &a, ufunc_t &b, 00089 param_t &pa)=0; 00090 00091 /** \brief Integrate function \c func from 00092 \f$ x_i=a_i(x_i) \f$ to \f$ x_i=b_i(x_i) \f$ for 00093 \f$ 0<i<\mathrm{ndim}-1 \f$. 00094 00095 */ 00096 virtual int ginteg_err(func_t &func, size_t ndim, lfunc_t &a, 00097 ufunc_t &b, param_t &pa, double &res, 00098 double &err) { 00099 res=ginteg(func,ndim,a,b,pa); 00100 return 0; 00101 } 00102 00103 /** \brief Return the error in the result from the last call to 00104 ginteg() or ginteg_err() 00105 00106 This will quietly return zero if no integrations have been 00107 performed. 00108 */ 00109 double get_error() { return interror; } 00110 00111 /// Return string denoting type ("gen_inte") 00112 const char *type() { return "gen_inte"; } 00113 00114 #ifndef DOXYGEN_INTERNAL 00115 00116 protected: 00117 00118 /// The uncertainty for the last integration computation 00119 double interror; 00120 00121 #endif 00122 00123 }; 00124 00125 #ifndef DOXYGENP 00126 } 00127 #endif 00128 00129 #endif 00130 00131 00132 00133 00134 00135
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