Improved intro examples in Math::GSL and fixed return signature of gsl_deriv_* functions
[Math-GSL.git] / Deriv.i
blobeac03aa0c69bb4f6e53d9198289b084c31d297be
1 %module "Math::GSL::Deriv"
2 // Danger Will Robinson, for realz!
4 %include "typemaps.i"
5 %include "gsl_typemaps.i"
6 %typemap(argout) (const gsl_function *f,
7 double x, double h,
8 double *result, double *abserr) {
9 SV ** sv;
10 //AV* av = newAV();
12 sv = hv_fetch(Callbacks, (char*)&$input, sizeof($input), FALSE );
13 if (sv == (SV**)NULL)
14 croak("Math::GSL(argout) : Missing callback!\n");
15 dSP;
17 PUSHMARK(SP);
18 // these are the arguments passed to the callback
19 XPUSHs(sv_2mortal(newSViv((int)$2)));
20 PUTBACK;
22 /* This actually calls the perl subroutine */
23 call_sv(*sv, G_SCALAR);
25 //av_push(av, newSVnv((double) *$4));
26 //av_push(av, newSVnv((double) *$5));
27 //$result = sv_2mortal( newRV_noinc( (SV*) av) );
28 $result = sv_newmortal();
29 sv_setnv($result, (double) *$4);
30 argvi++;
31 sv_setnv($result, (double) *$5);
32 argvi++;
34 if (argvi >= items) {
35 EXTEND(SP,1);
40 %typemap(in) void * {
41 $1 = (double *) $input;
44 #include "gsl/gsl_math.h"
45 #include "gsl/gsl_deriv.h"
48 %include "gsl/gsl_math.h"
49 %include "gsl/gsl_deriv.h"
51 %perlcode %{
52 @EXPORT_OK = qw/
53 gsl_deriv_central
54 gsl_deriv_backward
55 gsl_deriv_forward
57 %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
59 __END__
61 =head1 NAME
63 Math::GSL::Deriv - Numerical Derivatives
65 =head1 SYNOPSIS
68 use Math::GSL::Deriv qw /:all/;
70 =head1 DESCRIPTION
72 Here is a list of all the functions in this module :
74 =over
76 =item * C<gsl_deriv_central>
78 =item * C<gsl_deriv_backward>
80 =item * C<gsl_deriv_forward>
82 =back
84 For more informations on the functions, we refer you to the GSL offcial
85 documentation: L<http://www.gnu.org/software/gsl/manual/html_node/>
87 Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want
90 =head1 AUTHORS
92 Jonathan Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
94 =head1 COPYRIGHT AND LICENSE
96 Copyright (C) 2008 Jonathan Leto and Thierry Moisan
98 This program is free software; you can redistribute it and/or modify it
99 under the same terms as Perl itself.
101 =cut