Object-oriented Scientific Computing Library: Version 0.910
multi_inte.h
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_MULTI_INTE_H
00024 #define O2SCL_MULTI_INTE_H
00025 
00026 #include <o2scl/inte.h>
00027 #include <o2scl/ovector_tlate.h>
00028 
00029 #ifndef DOXYGENP
00030 namespace o2scl {
00031 #endif
00032   
00033   /** \brief Multi-dimensional integration over a hypercube 
00034       [abstract base]
00035  
00036       Multi-dimensional integration over a region defined by constant
00037       limits. For more general regions of integration, use children of
00038       the class \ref gen_inte.
00039   */
00040   template<class func_t, class vec_t=ovector_base> class multi_inte {
00041       
00042       public:
00043       
00044       multi_inte() {
00045         tol_rel=1.0e-8;
00046         verbose=0;
00047         interror=0.0;
00048         err_nonconv=true;
00049       }
00050       
00051       virtual ~multi_inte() {}
00052       
00053       /// If true, call the error handler if the routine does not "converge"
00054       bool err_nonconv;
00055       
00056       /** \brief Verbosity
00057        */
00058       int verbose;
00059   
00060       /** \brief The maximum "uncertainty" in the value of the integral
00061           (default \f$ 10^{-8} \f$).
00062        */
00063       double tol_rel;
00064   
00065       /** \brief Integrate function \c func over the hypercube from
00066           \f$ x_i=a_i \f$ to \f$ x_i=b_i \f$ for
00067           \f$ 0<i< \f$ ndim-1
00068           
00069           \comment 
00070           (I had some problems with Doxygen 
00071           using \mathrm in the formula above.)
00072           \endcomment
00073       */
00074       virtual double minteg(func_t &func, size_t ndim, const vec_t &a, 
00075                             const vec_t &b) {
00076         double err, res;
00077         minteg_err(func,ndim,a,b,res,err);
00078         return res;
00079       }
00080       
00081       /** \brief Integrate function \c func over the hypercube from
00082           \f$ x_i=a_i \f$ to \f$ x_i=b_i \f$ for
00083           \f$ 0<i< \f$ ndim-1
00084       */
00085       virtual int minteg_err(func_t &func, size_t ndim, const vec_t &a, 
00086                              const vec_t &b, double &res, double &err)=0;
00087       
00088       /** \brief Return the error in the result from the last call to 
00089           minteg() or minteg_err()
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 ("multi_inte")
00097       const char *type() { return "multi_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 
00119 
00120   
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.