00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 2009, 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_GSL_INTE_QAGIU_H 00024 #define O2SCL_GSL_INTE_QAGIU_H 00025 00026 #include <o2scl/inte.h> 00027 #include <o2scl/gsl_inte_qags.h> 00028 00029 #ifndef DOXYGENP 00030 namespace o2scl { 00031 #endif 00032 00033 /** \brief Integrate a function from \f$ a \f$ to \f$ \infty \f$ 00034 (GSL) 00035 00036 The number of subdivisions of the original interval which 00037 this class is allowed to make is dictated by the workspace 00038 size for the integration class, which can be set using 00039 \ref gsl_inte_table::set_wkspace() . 00040 00041 \todo I had to add extra code to check for non-finite 00042 values for some integrations. This should be checked. 00043 00044 The extra line was of the form: 00045 \verbatim 00046 if (!finite(area1)) area1=0.0; 00047 \endverbatim 00048 */ 00049 template<class param_t, class func_t=funct<param_t> > class gsl_inte_qagiu : 00050 public gsl_inte_transform<param_t,func_t> { 00051 00052 #ifndef DOXGYEN_INTERNAL 00053 00054 protected: 00055 00056 /// Store the lower limit 00057 double la; 00058 00059 #endif 00060 00061 public: 00062 00063 /** 00064 00065 \brief Integrate function \c func from \c a to \f$ \infty \f$ 00066 00067 The value \c b is ignored. 00068 */ 00069 virtual double integ(func_t &func, double a, double b, param_t &pa) { 00070 double res, err; 00071 integ_err(func,a,b,pa,res,err); 00072 this->interror=err; 00073 return res; 00074 } 00075 00076 /** 00077 \brief Integrate function \c func from \c a to \f$ \infty \f$ 00078 giving result \c res and error \c err 00079 00080 The value \c b is ignored. 00081 */ 00082 virtual int integ_err(func_t &func, double a, double b, 00083 param_t &pa, double &res, double &err2) { 00084 00085 la=a; 00086 00087 double fv1[8], fv2[8]; 00088 00089 int status=qags(func,8,o2scl_inte_qag_coeffs::qk15_xgk, 00090 o2scl_inte_qag_coeffs::qk15_wg, 00091 o2scl_inte_qag_coeffs::qk15_wgk, 00092 fv1,fv2,0.0,1.0,this->tolx,this->tolf, 00093 this->wkspace,&res,&err2,pa); 00094 00095 return status; 00096 00097 } 00098 00099 #ifndef DOXYGEN_INTERNAL 00100 00101 protected: 00102 00103 /// Transform to \f$ t \in (0,1] \f$ 00104 virtual double transform(func_t &func, double t, param_t &pa) { 00105 double x=la+(1-t)/t, y=0.0; 00106 func(x,y,pa); 00107 00108 return y/t/t; 00109 } 00110 00111 #endif 00112 00113 }; 00114 00115 #ifndef DOXYGENP 00116 } 00117 #endif 00118 00119 #endif
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page