multi_inte.h

00001 /*
00002   -------------------------------------------------------------------
00003   
00004   Copyright (C) 2006, 2007, 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   /** 
00034       \brief Multi-dimensional integration over a hypercube base class
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 param_t, class func_t, 
00041     class vec_t=ovector_view> class multi_inte {
00042       
00043       public:
00044       
00045       /** \brief Verbosity
00046        */
00047       int verbose;
00048   
00049       /** \brief The maximum "uncertainty" in the value of the integral
00050           (default \f$ 10^{-8} \f$).
00051        */
00052       double tolf;
00053   
00054       multi_inte() {
00055         tolf=1.0e-8;
00056         verbose=0;
00057         interror=0.0;
00058       }
00059 
00060       virtual ~multi_inte() {}
00061 
00062       /* \brief Integrate function \c func over the hypercube from
00063           \f$ x_i=a_i \f$ to \f$ x_i=b_i\ f$ for 
00064           \f$ 0<i< \f$ ndim-1.
00065       */
00066       // for some reason, \mathrm can't be used in the formula above
00067       virtual double minteg(func_t &func, size_t ndim, const vec_t &a, 
00068                             const vec_t &b, param_t &pa) 
00069       {
00070         double res;
00071         minteg_err(func,ndim,a,b,pa,res,interror);
00072         return res;
00073       }
00074   
00075       /* \brief Integrate function \c func over the hypercube from
00076           \f$ x_i=a_i \f$ to \f$ x_i=b_i \f$ for 
00077           \f$ 0<i< \f$ ndim-1  
00078  
00079       */
00080       virtual int minteg_err(func_t &func, size_t ndim, const vec_t &a, 
00081                              const vec_t &b, param_t &pa, double &res, 
00082                              double &err)
00083       {
00084         res=minteg(func,ndim,a,b,pa);
00085         return 0;
00086       }
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   

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.