Merge branch 'master' of http://leto.net/code/Math-GSL into bleed
[Math-GSL.git] / Deriv.i
blob4614ec5e688eacb6525dbe9b4b7ef0a35292797a
1 %module "Math::GSL::Deriv"
2 /*
3 struct gsl_function_struct
5 double (* function) (double x, void * params);
6 void * params;
7 };
9 typedef struct gsl_function_struct gsl_function ;
10 #define GSL_FN_EVAL(F,x) (*((F)->function))(x,(F)->params)
13 %include "typemaps.i"
14 %typemap(in) gsl_function * {
15 gsl_function F;
16 int count;
17 F.params = 0;
18 F.function = &xsquared;
20 if( !SvROK($input) ) {
21 croak("Math::GSL : not a reference value!");
23 //Perl_sv_dump( $input );
25 // does not work
26 //count = call_sv((SV*) $input, G_ARRAY);
27 $1 = &F;
31 typedef struct callback_t
33 SV * obj;
35 double xsquared(double x,void *params){
36 return x * x;
39 %typemap(in) void * {
40 printf("void * \n");
41 $1 = (double *) $input;
43 %typemap(in) double (*)(double,void *) {
44 fprintf(stderr,"input * %d \n", (int) $input);
45 //Perl_sv_dump( $input );
48 %apply double * OUTPUT { double *abserr, double *result };
51 #include "gsl/gsl_math.h"
52 #include "gsl/gsl_deriv.h"
55 %include "gsl/gsl_math.h"
56 %include "gsl/gsl_deriv.h"
58 %perlcode %{
59 @EXPORT_OK = qw/
60 gsl_deriv_central
61 gsl_deriv_backward
62 gsl_deriv_forward
64 %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );