PDL::GSL::INTEG is a PDL interface to numerical integration routines in GSL.
This is an interface to the numerical integration package present in the GNU Scientific Library, which is an implementation of QUADPACK.
Functions are named gslinteg_{algorithm} where {algorithm} is the QUADPACK naming convention. The available functions are:
gslinteg_qng: Non-adaptive Gauss-Kronrod integration
gslinteg_qag: Adaptive integration
gslinteg_qags: Adaptive integration with singularities
gslinteg_qagp: Adaptive integration with known singular points
gslinteg_qagi: Adaptive integration on infinite interval of the form (-infty,infty)
gslinteg_qagiu: Adaptive integration on infinite interval of the form (a,infty)
gslinteg_qagil: Adaptive integration on infinite interval of the form (-infty,b)
gslinteg_qawc: Adaptive integration for Cauchy principal values
gslinteg_qaws: Adaptive integration for singular functions
gslinteg_qawo: Adaptive integration for oscillatory functions
gslinteg_qawf: Adaptive integration for Fourier integrals
Each algorithm computes an approximation to the integral, I, of the function f(x)w(x), where w(x) is a weight function (for general integrands w(x)=1). The user provides absolute and relative error bounds (epsabs,epsrel) which specify the following accuracy requirement:
|RESULT - I| 'y'} is specified in which case the reason of failure will be printed.
You can nest integrals up to 20 levels. If you find yourself in the unlikely situation that you need more, you can change the value of 'max_nested_integrals' in the first line of the file 'FUNC.c' and recompile.
Please check the GSL documentation for more information.
SYNOPSIS
use PDL;
use PDL::GSL::INTEG;
my $a = 1.2;
my $b = 3.7;
my $epsrel = 0;
my $epsabs = 1e-6;
# Non adaptive integration
my ($res,$abserr,$ierr,$neval) = gslinteg_qng(&myf,$a,$b,$epsrel,$epsabs);
# Warnings on
my ($res,$abserr,$ierr,$neval) = gslinteg_qng(&myf,$a,$b,$epsrel,$epsabs,{Warn=>'y'});
# Adaptive integration with warnings on
my $limit = 1000;
my $key = 5;
my ($res,$abserr,$ierr) = gslinteg_qag(&myf,$a,$b,$epsrel,
$epsabs,$limit,$key,{Warn=>'y'});
sub myf{
my ($x) = @_;
return exp(-$x**2);
}
Product's homepage
Requirements:
· Perl