inte_multi.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2017, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_MULTI_INTE_H
24 #define O2SCL_MULTI_INTE_H
25 
26 /** \file inte_multi.h
27  \brief File defining \ref o2scl::inte_multi
28 */
29 #include <boost/numeric/ublas/vector.hpp>
30 
31 #include <o2scl/inte.h>
32 #include <o2scl/multi_funct.h>
33 
34 #ifndef DOXYGEN_NO_O2NS
35 namespace o2scl {
36 #endif
37 
38  /** \brief Multi-dimensional integration over a hypercube
39  [abstract base]
40 
41  Multi-dimensional integration over a region defined by constant
42  limits. For more general regions of integration, use children of
43  the class \ref inte_gen.
44  */
45  template<class func_t=multi_funct11,
47 
48  public:
49 
50  inte_multi() {
51  tol_rel=1.0e-8;
52  verbose=0;
53  interror=0.0;
54  err_nonconv=true;
55  }
56 
57  virtual ~inte_multi() {}
58 
59  /// If true, call the error handler if the routine does not "converge"
61 
62  /** \brief Verbosity
63  */
64  int verbose;
65 
66  /** \brief The maximum "uncertainty" in the value of the integral
67  (default \f$ 10^{-8} \f$).
68  */
69  double tol_rel;
70 
71  /** \brief Integrate function \c func over the hypercube from
72  \f$ x_i=a_i \f$ to \f$ x_i=b_i \f$ for
73  \f$ 0<i< \f$ ndim-1
74 
75  \comment
76  (I had some problems with Doxygen
77  using \mathrm in the formula above.)
78  \endcomment
79  */
80  virtual double minteg(func_t &func, size_t ndim, const vec_t &a,
81  const vec_t &b) {
82  double err, res;
83  minteg_err(func,ndim,a,b,res,err);
84  return res;
85  }
86 
87  /** \brief Integrate function \c func over the hypercube from
88  \f$ x_i=a_i \f$ to \f$ x_i=b_i \f$ for
89  \f$ 0<i< \f$ ndim-1
90  */
91  virtual int minteg_err(func_t &func, size_t ndim, const vec_t &a,
92  const vec_t &b, double &res, double &err)=0;
93 
94  /** \brief Return the error in the result from the last call to
95  minteg() or minteg_err()
96 
97  This will quietly return zero if no integrations have been
98  performed.
99  */
100  double get_error() { return interror; }
101 
102  /// Return string denoting type ("inte_multi")
103  const char *type() { return "inte_multi"; }
104 
105 #ifndef DOXYGEN_INTERNAL
106 
107  protected:
108 
109  /// The uncertainty for the last integration computation
110  double interror;
111 
112 #endif
113 
114  };
115 
116 #ifndef DOXYGEN_NO_O2NS
117 }
118 #endif
119 
120 #endif
121 
122 
123 
124 
125 
126 
double get_error()
Return the error in the result from the last call to minteg() or minteg_err()
Definition: inte_multi.h:100
The main O<span style=&#39;position: relative; top: 0.3em; font-size: 0.8em&#39;>2</span>scl O$_2$scl names...
Definition: anneal.h:42
virtual double minteg(func_t &func, size_t ndim, const vec_t &a, const vec_t &b)
Integrate function func over the hypercube from to for ndim-1.
Definition: inte_multi.h:80
virtual int minteg_err(func_t &func, size_t ndim, const vec_t &a, const vec_t &b, double &res, double &err)=0
Integrate function func over the hypercube from to for ndim-1.
const char * type()
Return string denoting type ("inte_multi")
Definition: inte_multi.h:103
double tol_rel
The maximum "uncertainty" in the value of the integral (default ).
Definition: inte_multi.h:69
int verbose
Verbosity.
Definition: inte_multi.h:64
Multi-dimensional integration over a hypercube [abstract base].
Definition: inte_multi.h:46
double interror
The uncertainty for the last integration computation.
Definition: inte_multi.h:110
bool err_nonconv
If true, call the error handler if the routine does not "converge".
Definition: inte_multi.h:60
std::function< double(size_t, const boost::numeric::ublas::vector< double > &)> multi_funct11
Multi-dimensional function typedef.
Definition: multi_funct.h:45

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