Object-oriented Scientific Computing Library: Version 0.910
gsl_inte_qagil.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_QAGIL_H
00025 #define O2SCL_GSL_INTE_QAGIL_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$ 
00035       (-\infty, b] \f$ (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_{-\infty}^b f(x)~dx =
00041       \int_0^1 f(b - (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_qagil : 
00049   public gsl_inte_transform<func_t> {
00050 
00051 #ifndef DOXYGEN_INTERNAL      
00052 
00053   protected:
00054 
00055   /// The upper limit
00056   double upper_limit;
00057 
00058 #endif
00059 
00060   public:
00061     
00062   /** \brief Integrate function \c func from \f$ -\infty \f$ to \c b
00063       and place the result in \c res and the error in \c err
00064       
00065       The value given in \c a is ignored.
00066   */
00067   virtual int integ_err(func_t &func, double a, double b, 
00068                         double &res, double &err) {
00069     upper_limit=b;
00070     this->last_conv=0;
00071     return qags(func,0.0,1.0,this->tol_abs,this->tol_rel,&res,&err);
00072   }
00073 
00074   protected:
00075       
00076   /// Transform to \f$ t \in (0,1] \f$
00077   virtual double transform(double t, func_t &func) {
00078     double x=upper_limit-(1-t)/t, y;
00079     y=func(x);
00080     return y/t/t;
00081   }
00082       
00083   };
00084   
00085 #ifndef DOXYGENP
00086 }
00087 #endif
00088 
00089 #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.