multi_inte.h

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_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           \comment 
00067           (I had some problems with Doxygen 
00068           using \mathrm in the formula above.)
00069           \endcomment
00070       */
00071       virtual double minteg(func_t &func, size_t ndim, const vec_t &a, 
00072                             const vec_t &b, param_t &pa) 
00073       {
00074         double res;
00075         minteg_err(func,ndim,a,b,pa,res,interror);
00076         return res;
00077       }
00078       
00079       /** \brief Integrate function \c func over the hypercube from
00080           \f$ x_i=a_i \f$ to \f$ x_i=b_i \f$ for
00081           \f$ 0<i< \f$ ndim-1
00082       */
00083       virtual int minteg_err(func_t &func, size_t ndim, const vec_t &a, 
00084                              const vec_t &b, param_t &pa, double &res, 
00085                              double &err)
00086       {
00087         res=minteg(func,ndim,a,b,pa);
00088         return 0;
00089       }
00090       
00091       /** \brief Return the error in the result from the last call to 
00092           minteg() or minteg_err()
00093           
00094           This will quietly return zero if no integrations have been
00095           performed.
00096       */
00097       double get_error() { return interror; }
00098   
00099       /// Return string denoting type ("multi_inte")
00100       const char *type() { return "multi_inte"; }
00101   
00102 #ifndef DOXYGEN_INTERNAL
00103   
00104       protected:
00105   
00106       /// The uncertainty for the last integration computation
00107       double interror;
00108   
00109 #endif
00110   
00111     };
00112 
00113 #ifndef DOXYGENP
00114 }
00115 #endif
00116 
00117 #endif
00118 
00119 
00120 
00121 
00122 
00123   

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

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page