1 %module
"Math::GSL::Integration"
3 %include
"gsl_typemaps.i"
6 #include
"gsl/gsl_integration.h"
7 #include
"gsl/gsl_math.h"
9 %include
"gsl/gsl_integration.h"
10 %include
"gsl/gsl_math.h"
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
51 %EXPORT_TAGS
= ( all
=> [ @EXPORT_OK
] );
57 Math
::GSL
::Integration
- Routines for performing numerical integration
(quadrature
) of a function in one dimension
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
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.
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
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
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
(
173 1, 10, 0, 1e-7, 1000,
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
,
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
) >
195 This module also includes the following constants
:
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
217 The following error constants are part of the Math
::GSL
::Errno module and can
218 be returned by the gsl_integration_
* functions
:
222 =item
* $GSL_EMAXITER
224 Maximum number of subdivisions was exceeded.
228 Cannot reach tolerance because of roundoff error
, or roundoff error was detected in the extrapolation table.
232 A non-integrable singularity or other bad integrand behavior was found in the integration interval.
236 The integral is divergent
, or too slowly convergent to be integrated numerically.
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
/>
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.