1 %module
"Math::GSL::Deriv"
3 struct gsl_function_struct
5 double
(* function
) (double x
, void
* params
);
9 typedef struct gsl_function_struct gsl_function
;
10 #define GSL_FN_EVAL
(F
,x
) (*((F
)->function
))(x
,(F
)->params
)
14 %include
"gsl_typemaps.i"
16 static HV
* Callbacks
= (HV
*)NULL;
17 typedef struct callback_t
21 double xsquared
(double x
,void
*params
){
22 fprintf
(stderr
,"static xsquared!!\n");
26 %apply double
* OUTPUT { double
*abserr
, double
*result
};
28 int gsl_deriv_central
(const gsl_function
*f
,
30 double
*result
, double
*abserr
);
32 %typemap
(in
) gsl_function const
* {
33 fprintf
(stderr
,"typemap in!\n");
37 F.function
= &xsquared;
41 croak
("Math::GSL : not a reference value!");
43 if
(Callbacks
== (HV
*)NULL)
46 hv_store
( Callbacks
, (char
*)&$input, sizeof($input), newSVsv($input), 0 );
48 //Perl_sv_dump
( $input
);
49 // how to register callback ?
53 %typemap
(argout
) gsl_function const
* {
54 fprintf
(stderr
,"typemap out!\n");
56 sv
= hv_fetch
(Callbacks
, (char
*)&$input, sizeof($input), FALSE );
60 croak
("Math::GSL : Missing callback!\n");
68 XPUSHs
(sv_2mortal
(newSViv
((int
)$input
)));
72 fprintf
(stderr
, "\nCALLBACK!\n");
74 call_sv
(*sv
, G_SCALAR
); /* The money shot
*/
77 fprintf
(stderr
, "x = %.8f", x
);
85 $
1 = (double
*) $input
;
88 #include
"gsl/gsl_math.h"
89 #include
"gsl/gsl_deriv.h"
92 %include
"gsl/gsl_math.h"
93 %include
"gsl/gsl_deriv.h"
101 %EXPORT_TAGS
= ( all
=> [ @EXPORT_OK
] );
107 Math
::GSL
::Deriv
- Functions to compute numerical derivatives by finite differencing
111 This module is not yet implemented. Patches Welcome
!
113 use Math
::GSL
::Deriv qw
/:all
/;
117 Here is a list of all the functions in this module
:
121 =item
* C
<gsl_deriv_central
>
123 =item
* C
<gsl_deriv_backward
>
125 =item
* C
<gsl_deriv_forward
>
129 For more informations on the functions
, we refer you to the GSL offcial
130 documentation
: L
<http
://www.gnu.org
/software
/gsl
/manual
/html_node
/>
132 Tip
: search on google
: site
:http
://www.gnu.org
/software
/gsl
/manual
/html_node
/ name_of_the_function_you_want
137 Jonathan Leto
<jonathan@leto.net
> and Thierry Moisan
<thierry.moisan@gmail.com
>
139 =head1 COPYRIGHT
AND LICENSE
141 Copyright
(C
) 2008 Jonathan Leto and Thierry Moisan
143 This program is free software
; you can redistribute it and
/or modify it
144 under the same terms as Perl itself.