POD for Math::GSL::Test
[Math-GSL.git] / ODEIV.i
blob6becdc977931339c8a49674a406c7ba8a272bc9c
1 %module "Math::GSL::ODEIV"
2 %include "gsl_typemaps.i"
3 %{
4 #include "gsl/gsl_odeiv.h"
5 #include "gsl/gsl_types.h"
6 %}
7 %include "gsl/gsl_types.h"
8 %include "gsl/gsl_odeiv.h"
10 %perlcode %{
11 @EXPORT_OK = qw/
12 gsl_odeiv_step_alloc
13 gsl_odeiv_step_reset
14 gsl_odeiv_step_free
15 gsl_odeiv_step_name
16 gsl_odeiv_step_order
17 gsl_odeiv_step_apply
18 gsl_odeiv_control_alloc
19 gsl_odeiv_control_init
20 gsl_odeiv_control_free
21 gsl_odeiv_control_hadjust
22 gsl_odeiv_control_name
23 gsl_odeiv_control_standard_new
24 gsl_odeiv_control_y_new
25 gsl_odeiv_control_yp_new
26 gsl_odeiv_control_scaled_new
27 gsl_odeiv_evolve_alloc
28 gsl_odeiv_evolve_apply
29 gsl_odeiv_evolve_reset
30 gsl_odeiv_evolve_free
31 $gsl_odeiv_step_rk2
32 $gsl_odeiv_step_rk4
33 $gsl_odeiv_step_rkf45
34 $gsl_odeiv_step_rkck
35 $gsl_odeiv_step_rk8pd
36 $gsl_odeiv_step_rk2imp
37 $gsl_odeiv_step_rk2simp
38 $gsl_odeiv_step_rk4imp
39 $gsl_odeiv_step_bsimp
40 $gsl_odeiv_step_gear1
41 $gsl_odeiv_step_gear2
42 $GSL_ODEIV_HADJ_INC
43 $GSL_ODEIV_HADJ_NIL
44 $GSL_ODEIV_HADJ_DEC
45 $gsl_odeiv_control_standard
47 %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
49 __END__
51 =head1 NAME
53 Math::GSL::ODEIV - functions for solving ordinary differential equation (ODE) initial value problems
55 =head1 SYNOPSIS
57 use Math::GSL::ODEIV qw /:all/;
59 =head1 DESCRIPTION
61 Here is a list of all the functions in this module :
63 =over
65 =item * C<gsl_odeiv_step_alloc($T, $dim)> - This function returns a pointer to a newly allocated instance of a stepping function of type $T for a system of $dim dimensions.$T must be one of the step type constant above.
67 =item * C<gsl_odeiv_step_reset($s)> - This function resets the stepping function $s. It should be used whenever the next use of s will not be a continuation of a previous step.
69 =item * C<gsl_odeiv_step_free($s)> - This function frees all the memory associated with the stepping function $s.
71 =item * C<gsl_odeiv_step_name($s)> - This function returns a pointer to the name of the stepping function.
73 =item * C<gsl_odeiv_step_order($s)> - This function returns the order of the stepping function on the previous step. This order can vary if the stepping function itself is adaptive.
75 =item * C<gsl_odeiv_step_apply >
77 =item * C<gsl_odeiv_control_alloc($T)> - This function returns a pointer to a newly allocated instance of a control function of type $T. This function is only needed for defining new types of control functions. For most purposes the standard control functions described above should be sufficient. $T is a gsl_odeiv_control_type.
79 =item * C<gsl_odeiv_control_init($c, $eps_abs, $eps_rel, $a_y, $a_dydt) > - This function initializes the control function c with the parameters eps_abs (absolute error), eps_rel (relative error), a_y (scaling factor for y) and a_dydt (scaling factor for derivatives).
81 =item * C<gsl_odeiv_control_free >
83 =item * C<gsl_odeiv_control_hadjust >
85 =item * C<gsl_odeiv_control_name >
87 =item * C<gsl_odeiv_control_standard_new($eps_abs, $eps_rel, $a_y, $a_dydt)> - The standard control object is a four parameter heuristic based on absolute and relative errors $eps_abs and $eps_rel, and scaling factors $a_y and $a_dydt for the system state y(t) and derivatives y'(t) respectively. The step-size adjustment procedure for this method begins by computing the desired error level D_i for each component, D_i = eps_abs + eps_rel * (a_y |y_i| + a_dydt h |y'_i|) and comparing it with the observed error E_i = |yerr_i|. If the observed error E exceeds the desired error level D by more than 10% for any component then the method reduces the step-size by an appropriate factor, h_new = h_old * S * (E/D)^(-1/q) where q is the consistency order of the method (e.g. q=4 for 4(5) embedded RK), and S is a safety factor of 0.9. The ratio E/D is taken to be the maximum of the ratios E_i/D_i. If the observed error E is less than 50% of the desired error level D for the maximum ratio E_i/D_i then the algorithm takes the opportunity to increase the step-size to bring the error in line with the desired level, h_new = h_old * S * (E/D)^(-1/(q+1)) This encompasses all the standard error scaling methods. To avoid uncontrolled changes in the stepsize, the overall scaling factor is limited to the range 1/5 to 5.
89 =item * C<gsl_odeiv_control_y_new($eps_abs, $eps_rel)> - This function creates a new control object which will keep the local error on each step within an absolute error of $eps_abs and relative error of $eps_rel with respect to the solution y_i(t). This is equivalent to the standard control object with a_y=1 and a_dydt=0.
91 =item * C<gsl_odeiv_control_yp_new($eps_abs, $eps_rel)> - This function creates a new control object which will keep the local error on each step within an absolute error of $eps_abs and relative error of $eps_rel with respect to the derivatives of the solution y'_i(t). This is equivalent to the standard control object with a_y=0 and a_dydt=1.
93 =item * C<gsl_odeiv_control_scaled_new($eps_abs, $eps_rel, $a_y, $a_dydt, $scale_abs, $dim) > - This function creates a new control object which uses the same algorithm as gsl_odeiv_control_standard_new but with an absolute error which is scaled for each component by the array reference $scale_abs. The formula for D_i for this control object is, D_i = eps_abs * s_i + eps_rel * (a_y |y_i| + a_dydt h |y'_i|) where s_i is the i-th component of the array scale_abs. The same error control heuristic is used by the Matlab ode suite.
95 =item * C<gsl_odeiv_evolve_alloc($dim)> - This function returns a pointer to a newly allocated instance of an evolution function for a system of $dim dimensions.
97 =item * C<gsl_odeiv_evolve_apply >
99 =item * C<gsl_odeiv_evolve_reset($e)> - This function resets the evolution function $e. It should be used whenever the next use of $e will not be a continuation of a previous step.
101 =item * C<gsl_odeiv_evolve_free($e)> - This function frees all the memory associated with the evolution function $e.
103 =back
105 This module also includes the following constants :
107 =over
109 =item * C<$GSL_ODEIV_HADJ_INC>
111 =item * C<$GSL_ODEIV_HADJ_NIL>
113 =item * C<$GSL_ODEIV_HADJ_DEC>
115 =back
117 =head2 Step Type
119 =over
121 =item * C<$gsl_odeiv_step_rk2> - Embedded Runge-Kutta (2, 3) method.
123 =item * C<$gsl_odeiv_step_rk4> - 4th order (classical) Runge-Kutta. The error estimate is obtained by halving the step-size. For more efficient estimate of the error, use the Runge-Kutta-Fehlberg method described below.
125 =item * C<$gsl_odeiv_step_rkf45> - Embedded Runge-Kutta-Fehlberg (4, 5) method. This method is a good general-purpose integrator.
127 =item * C<$gsl_odeiv_step_rkck> - Embedded Runge-Kutta Cash-Karp (4, 5) method.
129 =item * C<$gsl_odeiv_step_rk8pd> - Embedded Runge-Kutta Prince-Dormand (8,9) method.
131 =item * C<$gsl_odeiv_step_rk2imp> - Implicit 2nd order Runge-Kutta at Gaussian points.
133 =item * C<$gsl_odeiv_step_rk2simp>
135 =item * C<$gsl_odeiv_step_rk4imp> - Implicit 4th order Runge-Kutta at Gaussian points.
137 =item * C<$gsl_odeiv_step_bsimp> - Implicit Bulirsch-Stoer method of Bader and Deuflhard. This algorithm requires the Jacobian.
139 =item * C<$gsl_odeiv_step_gear1> - M=1 implicit Gear method.
141 =item * C<$gsl_odeiv_step_gear2> - M=2 implicit Gear method.
143 =back
145 For more informations on the functions, we refer you to the GSL offcial
146 documentation: L<http://www.gnu.org/software/gsl/manual/html_node/>
148 Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want
151 =head1 AUTHORS
153 Jonathan Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
155 =head1 COPYRIGHT AND LICENSE
157 Copyright (C) 2008 Jonathan Leto and Thierry Moisan
159 This program is free software; you can redistribute it and/or modify it
160 under the same terms as Perl itself.
162 =cut