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