Object-oriented Scientific Computing Library: Version 0.910
gsl_inte_qagiu.h
00001 /*
00002   -------------------------------------------------------------------
00003   
00004   Copyright (C) 2006-2012, Jerry Gagelman
00005   and Andrew W. Steiner
00006   
00007   This file is part of O2scl.
00008   
00009   O2scl is free software; you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation; either version 3 of the License, or
00012   (at your option) any later version.
00013   
00014   O2scl is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018   
00019   You should have received a copy of the GNU General Public License
00020   along with O2scl. If not, see <http://www.gnu.org/licenses/>.
00021 
00022   -------------------------------------------------------------------
00023 */
00024 #ifndef O2SCL_GSL_INTE_QAGIU_H
00025 #define O2SCL_GSL_INTE_QAGIU_H
00026 
00027 #include <o2scl/inte.h>
00028 #include <o2scl/gsl_inte_qags.h>
00029 
00030 #ifndef DOXYGENP
00031 namespace o2scl {
00032 #endif
00033   
00034   /** \brief Integrate a function over the interval \f$ [a, \infty) \f$ 
00035       (GSL)
00036 
00037       The integral on the unbounded interval is rewritten over the
00038       semi-open interval \f$ (0, 1] \f$ via a variable transformation,
00039       \f[
00040       \int_a^{\infty} f(x)~dx =
00041       \int_0^1 f(a + (1-t)/t)t^{-2}~dt,
00042       \f]
00043       and the right hand side is evaluated with \ref gsl_inte_qags.
00044 
00045       See \ref gslinte_subsect in the User's guide for general
00046       information about the GSL integration classes.
00047   */
00048   template<class func_t=funct> class gsl_inte_qagiu : 
00049   public gsl_inte_transform<func_t> {
00050       
00051 #ifndef DOXGYEN_INTERNAL
00052 
00053   protected:
00054 
00055   /// The lower limit
00056   double lower_limit;
00057 
00058 #endif
00059       
00060   public:
00061   
00062   /** \brief Integrate a function over the interval \f$ [a, \infty) \f$ 
00063       giving result \c res and error \c err
00064 
00065       The value \c b is ignored.
00066   */
00067   virtual int integ_err(func_t &func, double a, double b, 
00068                         double &res, double &err) {
00069     this->last_conv=0;
00070     lower_limit=a;
00071     return qags(func,0.0,1.0,this->tol_abs,this->tol_rel,&res,&err);
00072   }
00073 
00074 #ifndef DOXYGEN_INTERNAL
00075 
00076   protected:
00077     
00078   /// Transform to \f$ t \in (0,1] \f$
00079   virtual double transform(double t, func_t &func) {
00080     double x=lower_limit+(1-t)/t, y=0.0;
00081     y=func(x);
00082     return y/t/t;
00083   }
00084 
00085 #endif
00086       
00087   };
00088   
00089 #ifndef DOXYGENP
00090 }
00091 #endif
00092 
00093 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.