Refactor Roots and add failing TODO test
[Math-GSL.git] / Integration.i
blob80c830442981c0329d9a0125e5db99a463b97427
1 %module "Math::GSL::Integration"
2 %{
3 #include "gsl/gsl_integration.h"
4 %}
6 %include "typemaps.i"
7 %include "gsl_typemaps.i"
8 %include "gsl/gsl_integration.h"
10 %perlcode %{
11 @EXPORT_OK = qw/
12 gsl_integration_workspace_alloc
13 gsl_integration_workspace_free
14 gsl_integration_qaws_table_alloc
15 gsl_integration_qaws_table_set
16 gsl_integration_qaws_table_free
17 gsl_integration_qawo_table_alloc
18 gsl_integration_qawo_table_set
19 gsl_integration_qawo_table_set_length
20 gsl_integration_qawo_table_free
21 gsl_integration_qk15
22 gsl_integration_qk21
23 gsl_integration_qk31
24 gsl_integration_qk41
25 gsl_integration_qk51
26 gsl_integration_qk61
27 gsl_integration_qcheb
28 gsl_integration_qk
29 gsl_integration_qng
30 gsl_integration_qag
31 gsl_integration_qagi
32 gsl_integration_qagiu
33 gsl_integration_qagil
34 gsl_integration_qags
35 gsl_integration_qagp
36 gsl_integration_qawc
37 gsl_integration_qaws
38 gsl_integration_qawo
39 gsl_integration_qawf
40 $GSL_INTEG_COSINE
41 $GSL_INTEG_SINE
42 $GSL_INTEG_GAUSS15
43 $GSL_INTEG_GAUSS21
44 $GSL_INTEG_GAUSS31
45 $GSL_INTEG_GAUSS41
46 $GSL_INTEG_GAUSS51
47 $GSL_INTEG_GAUSS61
49 %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
51 __END__
53 =head1 NAME
55 Math::GSL::Integration - Routines for performing numerical integration (quadrature) of a function in one dimension
57 =head1 SYNOPSIS
59 This module is not yet implemented. Patches Welcome!
61 use Math::GSL::Integration qw /:all/;
63 =head1 DESCRIPTION
65 Here is a list of all the functions in this module :
67 =over
69 =item * C<gsl_integration_workspace_alloc($n)> - This function allocates a workspace sufficient to hold $n double precision intervals, their integration results and error estimates.
71 =item * C<gsl_integration_workspace_free($w)> - This function frees the memory associated with the workspace $w.
73 =item * C<gsl_integration_qaws_table_alloc($alpha, $beta, $mu, $nu)> - This function allocates space for a gsl_integration_qaws_table struct describing a singular weight function W(x) with the parameters ($alpha, $beta, $mu, $nu), W(x) = (x-a)^alpha (b-x)^beta log^mu (x-a) log^nu (b-x) where $alpha > -1, $beta > -1, and $mu = 0, 1, $nu = 0, 1. The weight function can take four different forms depending on the values of $mu and $nu,
75 W(x) = (x-a)^alpha (b-x)^beta (mu = 0, nu = 0)
76 W(x) = (x-a)^alpha (b-x)^beta log(x-a) (mu = 1, nu = 0)
77 W(x) = (x-a)^alpha (b-x)^beta log(b-x) (mu = 0, nu = 1)
78 W(x) = (x-a)^alpha (b-x)^beta log(x-a) log(b-x) (mu = 1, nu = 1)
80 The singular points (a,b) do not have to be specified until the integral is computed, where they are the endpoints of the integration range.
81 The function returns a pointer to the newly allocated table gsl_integration_qaws_table if no errors were detected, and 0 in the case of error.
83 =item * C<gsl_integration_qaws_table_set($t, $alpha, $beta, $mu, $nu)> - This function modifies the parameters ($alpha, $beta, $mu, $nu) of an existing gsl_integration_qaws_table struct $t.
85 =item * C<gsl_integration_qaws_table_free($t)> - This function frees all the memory associated with the gsl_integration_qaws_table struct $t.
87 =item * C<gsl_integration_qawo_table_alloc($omega, $L, $sine, $n)>
89 =item * C<gsl_integration_qawo_table_set($t, $omega, $L, $sine, $n)> - This function changes the parameters omega, L and sine of the existing workspace $t.
91 =item * C<gsl_integration_qawo_table_set_length($t, $L)> - This function allows the length parameter $L of the workspace $t to be changed.
93 =item * C<gsl_integration_qawo_table_free($t)> - This function frees all the memory associated with the workspace $t.
95 =item * C<gsl_integration_qk15 >
97 =item * C<gsl_integration_qk21 >
99 =item * C<gsl_integration_qk31 >
101 =item * C<gsl_integration_qk41 >
103 =item * C<gsl_integration_qk51 >
105 =item * C<gsl_integration_qk61 >
107 =item * C<gsl_integration_qcheb >
109 =item * C<gsl_integration_qk >
111 =item * C<gsl_integration_qng >
113 =item * C<gsl_integration_qag >
115 =item * C<gsl_integration_qagi >
117 =item * C<gsl_integration_qagiu >
119 =item * C<gsl_integration_qagil >
121 =item * C<gsl_integration_qags($func,$a,$b,$epsabs,$epsrel,$limit,$workspace)>
123 ($status, $result, $abserr) = gsl_integration_qags (
124 sub { 1/$_[0]} ,
125 1, 10, 0, 1e-7, 1000,
126 $workspace,
129 This function applies the Gauss-Kronrod 21-point integration rule
130 adaptively until an estimate of the integral of $func over ($a,$b) is
131 achieved within the desired absolute and relative error limits,
132 $epsabs and $epsrel.
135 =item * C<gsl_integration_qagp >
137 =item * C<gsl_integration_qawc >
139 =item * C<gsl_integration_qaws >
141 =item * C<gsl_integration_qawo >
143 =item * C<gsl_integration_qawf >
145 =back
147 This module also includes the following constants :
149 =over
151 =item * $GSL_INTEG_COSINE
153 =item * $GSL_INTEG_SINE
155 =item * $GSL_INTEG_GAUSS15
157 =item * $GSL_INTEG_GAUSS21
159 =item * $GSL_INTEG_GAUSS31
161 =item * $GSL_INTEG_GAUSS41
163 =item * $GSL_INTEG_GAUSS51
165 =item * $GSL_INTEG_GAUSS61
167 =back
169 The following errors constants are part of the Math::GSL::Errno module and can be returned by the gsl_integration functions :
171 =over
173 =item * $GSL_EMAXITER - the maximum number of subdivisions was exceeded.
175 =item * $GSL_EROUND - cannot reach tolerance because of roundoff error, or roundoff error was detected in the extrapolation table.
177 =item * GSL_ESING - a non-integrable singularity or other bad integrand behavior was found in the integration interval.
179 =item * GSL_EDIVERGE - the integral is divergent, or too slowly convergent to be integrated numerically.
181 =back
183 For more informations on the functions, we refer you to the GSL offcial
184 documentation: L<http://www.gnu.org/software/gsl/manual/html_node/>
186 Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want
189 =head1 AUTHORS
191 Jonathan Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
193 =head1 COPYRIGHT AND LICENSE
195 Copyright (C) 2008 Jonathan Leto and Thierry Moisan
197 This program is free software; you can redistribute it and/or modify it
198 under the same terms as Perl itself.
200 =cut