POD for Math::GSL::Test
[Math-GSL.git] / Integration.i
blobd7dd6a7ca7a3108264873d4d89e855cc6f09545a
1 %module "Math::GSL::Integration"
2 %include "typemaps.i"
3 %include "gsl_typemaps.i"
5 %{
6 #include "gsl/gsl_integration.h"
7 #include "gsl/gsl_math.h"
8 %}
9 %include "gsl/gsl_integration.h"
10 %include "gsl/gsl_math.h"
12 %perlcode %{
13 @EXPORT_OK = qw/
14 gsl_integration_workspace_alloc
15 gsl_integration_workspace_free
16 gsl_integration_qaws_table_alloc
17 gsl_integration_qaws_table_set
18 gsl_integration_qaws_table_free
19 gsl_integration_qawo_table_alloc
20 gsl_integration_qawo_table_set
21 gsl_integration_qawo_table_set_length
22 gsl_integration_qawo_table_free
23 gsl_integration_qk15
24 gsl_integration_qk21
25 gsl_integration_qk31
26 gsl_integration_qk41
27 gsl_integration_qk51
28 gsl_integration_qk61
29 gsl_integration_qcheb
30 gsl_integration_qk
31 gsl_integration_qng
32 gsl_integration_qag
33 gsl_integration_qagi
34 gsl_integration_qagiu
35 gsl_integration_qagil
36 gsl_integration_qags
37 gsl_integration_qagp
38 gsl_integration_qawc
39 gsl_integration_qaws
40 gsl_integration_qawo
41 gsl_integration_qawf
42 $GSL_INTEG_COSINE
43 $GSL_INTEG_SINE
44 $GSL_INTEG_GAUSS15
45 $GSL_INTEG_GAUSS21
46 $GSL_INTEG_GAUSS31
47 $GSL_INTEG_GAUSS41
48 $GSL_INTEG_GAUSS51
49 $GSL_INTEG_GAUSS61
51 %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
53 __END__
55 =head1 NAME
57 Math::GSL::Integration - Routines for performing numerical integration (quadrature) of a function in one dimension
59 =head1 SYNOPSIS
61 use Math::GSL::Integration qw /:all/;
63 my $function = sub { $_[0]**2 } ;
64 my ($lower, $upper ) = (0,1);
65 my ($relerr,$abserr) = (0,1e-7);
67 my ($status, $result, $abserr, $num_evals) = gsl_integration_qng ( $function,
68 $lower, $upper, $relerr, $abserr
71 =head1 DESCRIPTION
73 This module allows you to numerically integrate a Perl subroutine. Depending
74 on the properties of your function (singularities, smoothness) and the type
75 of integration range (finite, infinite, semi-infinite), you will need to
76 choose a quadrature routine that fits your needs.
79 =over
81 =item * C<gsl_integration_workspace_alloc($n)>
83 This function allocates a workspace sufficient to hold $n double precision
84 intervals, their integration results and error estimates.
86 =item * C<gsl_integration_workspace_free($w)>
88 This function frees the memory associated with the workspace $w.
90 =item * C<gsl_integration_qaws_table_alloc($alpha, $beta, $mu, $nu)>
92 This function allocates space for a gsl_integration_qaws_table struct
93 describing a singular weight function W(x) with the parameters ($alpha, $beta,
94 $mu, $nu), W(x) = (x-a)^alpha (b-x)^beta log^mu (x-a) log^nu (b-x) where
95 $alpha > -1, $beta > -1, and $mu = 0, 1, $nu = 0, 1. The weight function can
96 take four different forms depending on the values of $mu and $nu,
98 W(x) = (x-a)^alpha (b-x)^beta (mu = 0, nu = 0)
99 W(x) = (x-a)^alpha (b-x)^beta log(x-a) (mu = 1, nu = 0)
100 W(x) = (x-a)^alpha (b-x)^beta log(b-x) (mu = 0, nu = 1)
101 W(x) = (x-a)^alpha (b-x)^beta log(x-a) log(b-x) (mu = 1, nu = 1)
103 The singular points (a,b) do not have to be specified until the integral is
104 computed, where they are the endpoints of the integration range. The function
105 returns a pointer to the newly allocated table gsl_integration_qaws_table if no
106 errors were detected, and 0 in the case of error.
108 =item * C<gsl_integration_qaws_table_set($t, $alpha, $beta, $mu, $nu)>
110 This function modifies the parameters ($alpha, $beta, $mu, $nu) of an existing
111 gsl_integration_qaws_table struct $t.
113 =item * C<gsl_integration_qaws_table_free($t)>
115 This function frees all the memory associated with the
116 gsl_integration_qaws_table struct $t.
118 =item * C<gsl_integration_qawo_table_alloc($omega, $L, $sine, $n)>
120 =item * C<gsl_integration_qawo_table_set($t, $omega, $L, $sine, $n)>
122 This function changes the parameters omega, L and sine of the existing
123 workspace $t.
125 =item * C<gsl_integration_qawo_table_set_length($t, $L)>
127 This function allows the length parameter $L of the workspace $t to be
128 changed.
130 =item * C<gsl_integration_qawo_table_free($t)>
132 This function frees all the memory associated with the workspace $t.
134 =item * C<gsl_integration_qk15($function,$a,$b,$resabs,$resasc) >
136 =item * C<gsl_integration_qk21($function,$a,$b,$resabs,$resasc) >
138 =item * C<gsl_integration_qk31($function,$a,$b,$resabs,$resasc) >
140 =item * C<gsl_integration_qk41($function,$a,$b,$resabs,$resasc) >
142 =item * C<gsl_integration_qk51($function,$a,$b,$resabs,$resasc) >
144 =item * C<gsl_integration_qk61($function,$a,$b,$resabs,$resasc) >
146 =item * C<gsl_integration_qcheb($function, $a, $b, $cheb12, $cheb24) >
148 =item * C<gsl_integration_qk >
150 =item * C<gsl_integration_qng($function,$a,$b,$epsabs,$epsrel,$num_evals) >
152 This routine QNG (Quadrature Non-Adaptive Gaussian) is inexpensive is the sense
153 that it will evaluate the function much fewer times than the adaptive routines.
154 Because of this it does not need any workspaces, so it is also more memory
155 efficient. It should be perfectly fine for well-behaved functions (smooth and
156 nonsingular), but will not be able to get the required accuracy or may not
157 converge for more complicated functions.
159 =item * C<gsl_integration_qag($function,$a,$b,$epsabs,$epsrel,$limit,$key,$workspace) >
161 This routine QAG (Quadrature Adaptive Gaussian) ...
163 =item * C<gsl_integration_qagi($function,$epsabs,$epsrel,$limit,$workspace) >
165 =item * C<gsl_integration_qagiu($function,$a,$epsabs,$epsrel,$limit,$workspace) >
167 =item * C<gsl_integration_qagil($function,$b,$epsabs,$epsrel,$limit,$workspace) >
169 =item * C<gsl_integration_qags($func,$a,$b,$epsabs,$epsrel,$limit,$workspace)>
171 ($status, $result, $abserr) = gsl_integration_qags (
172 sub { 1/$_[0]} ,
173 1, 10, 0, 1e-7, 1000,
174 $workspace,
177 This function applies the Gauss-Kronrod 21-point integration rule
178 adaptively until an estimate of the integral of $func over ($a,$b) is
179 achieved within the desired absolute and relative error limits,
180 $epsabs and $epsrel.
183 =item * C<gsl_integration_qagp($function, $pts, $npts, $epsbs, $epsrel, $limit, $workspace) >
185 =item * C<gsl_integration_qawc($function, $a, $b, $c, $epsabs, $epsrel, $limit, $workspace) >
187 =item * C<gsl_integration_qaws($function, $a, $b, $qaws_table, $epsabs, $epsrel, $limit, $workspace) >
189 =item * C<gsl_integration_qawo($function, $a, $epsabs, $epsrel, $limit, $workspace, $qawo_table) >
191 =item * C<gsl_integration_qawf($function, $a, $epsabs, $limit, $workspace, $cycle_workspace, $qawo_table) >
193 =back
195 This module also includes the following constants :
197 =over
199 =item * $GSL_INTEG_COSINE
201 =item * $GSL_INTEG_SINE
203 =item * $GSL_INTEG_GAUSS15
205 =item * $GSL_INTEG_GAUSS21
207 =item * $GSL_INTEG_GAUSS31
209 =item * $GSL_INTEG_GAUSS41
211 =item * $GSL_INTEG_GAUSS51
213 =item * $GSL_INTEG_GAUSS61
215 =back
217 The following error constants are part of the Math::GSL::Errno module and can
218 be returned by the gsl_integration_* functions :
220 =over
222 =item * $GSL_EMAXITER
224 Maximum number of subdivisions was exceeded.
226 =item * $GSL_EROUND
228 Cannot reach tolerance because of roundoff error, or roundoff error was detected in the extrapolation table.
230 =item * GSL_ESING
232 A non-integrable singularity or other bad integrand behavior was found in the integration interval.
234 =item * GSL_EDIVERGE
236 The integral is divergent, or too slowly convergent to be integrated numerically.
238 =back
240 =head1 MORE INFO
242 For more informations on the functions, we refer you to the GSL offcial
243 documentation: L<http://www.gnu.org/software/gsl/manual/html_node/>
245 =head1 AUTHORS
247 Jonathan Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
249 =head1 COPYRIGHT AND LICENSE
251 Copyright (C) 2008 Jonathan Leto and Thierry Moisan
253 This program is free software; you can redistribute it and/or modify it
254 under the same terms as Perl itself.
256 =cut