inte_gauss56_cern.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 /** \file inte_gauss56_cern.h
24  \brief File defining \ref o2scl::inte_gauss56_cern
25 */
26 #ifndef O2SCL_CERN_GAUSS56_H
27 #define O2SCL_CERN_GAUSS56_H
28 
29 #include <o2scl/inte.h>
30 #include <o2scl/funct.h>
31 
32 #ifndef DOXYGEN_NO_O2NS
33 namespace o2scl {
34 #endif
35 
36  /** \brief 5,6-point Gaussian quadrature (CERNLIB)
37 
38  If \f$ I_5 \f$ is the 5-point approximation, and \f$ I_6 \f$ is the
39  6-point approximation to the integral, then integ_err() returns
40  the result \f$ \frac{1}{2}(I_5+I_6) \f$ with uncertainty
41  \f$ |I_5-I_6| \f$.
42 
43  This class is based on the CERNLIB routines RGS56P and
44  DGS56P which are documented at
45  http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/d106/top.html
46 
47  */
48  template<class func_t=funct11> class inte_gauss56_cern : public inte<func_t> {
49 
50  public:
51 
53  x5[0]=4.6910077030668004e-02;
54  w5[0]=1.1846344252809454e-01;
55  x5[1]=2.3076534494715846e-01;
56  w5[1]=2.3931433524968324e-01;
57  x5[2]=5.0000000000000000e-01;
58  w5[2]=2.8444444444444444e-01;
59  x5[3]=7.6923465505284154e-01;
60  w5[3]=2.3931433524968324e-01;
61  x5[4]=9.5308992296933200e-01;
62  w5[4]=1.1846344252809454e-01;
63 
64  x6[0]=3.3765242898423989e-02;
65  w6[0]=8.5662246189585178e-02;
66  x6[1]=1.6939530676686775e-01;
67  w6[1]=1.8038078652406930e-01;
68  x6[2]=3.8069040695840155e-01;
69  w6[2]=2.3395696728634552e-01;
70  x6[3]=6.1930959304159845e-01;
71  w6[3]=2.3395696728634552e-01;
72  x6[4]=8.3060469323313225e-01;
73  w6[4]=1.8038078652406930e-01;
74  x6[5]=9.6623475710157601e-01;
75  w6[5]=8.5662246189585178e-02;
76  }
77 
78  /** \brief Integrate function \c func from \c a to \c b
79  giving result \c res and error \c err
80 
81  This function always returns \ref success.
82  */
83  virtual int integ_err(func_t &func, double a, double b,
84  double &res, double &err) {
85 
86  double rang=b-a, e5=0.0, e6=0.0, ytmp;
87 
88  for(int i=0;i<5;i++) {
89  ytmp=func(a+rang*x5[i]);
90  e5+=w5[i]*ytmp;
91  ytmp=func(a+rang*x6[i]);
92  e6+=w6[i]*ytmp;
93  }
94  ytmp=func(a+rang*x6[5]);
95  e6+=w6[5]*ytmp;
96  res=(e6+e5)*rang/2.0;
97  err=fabs((e6-e5)*rang);
98 
99  return success;
100  }
101 
102  protected:
103 
104 #ifndef DOXYGEN_INTERNAL
105 
106  /** \name Integration constants
107  */
108  //@{
109  double x5[5], w5[5];
110  double x6[6], w6[6];
111  //@}
112 
113 #endif
114 
115  };
116 
117 #ifndef DOXYGEN_NO_O2NS
118 }
119 #endif
120 
121 #endif
virtual int integ_err(func_t &func, double a, double b, double &res, double &err)
Integrate function func from a to b giving result res and error err.
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
Base integration class [abstract base].
Definition: inte.h:44
5,6-point Gaussian quadrature (CERNLIB)
Success.
Definition: err_hnd.h:47

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