1 // Only include if we have GSL
>= 1.12
2 // This needs to be conditional
3 #ifdef GSL_VERSION
&& GSL_VERSION == "1.12"
4 %include
"gsl_inline.h"
10 %typemap
(in
) double const
[] {
16 croak
("Math::GSL : $$1_name is not a reference!");
17 if
(SvTYPE
(SvRV
($input
)) != SVt_PVAV
)
18 croak
("Math::GSL : $$1_name is not an array ref!");
20 tempav
= (AV
*)SvRV
($input
);
22 $
1 = (double
*) malloc
((len
+1)*sizeof
(double
));
23 for
(i
= 0; i
<= len
; i
++) {
24 tv
= av_fetch
(tempav
, i
, 0);
25 $
1[i
] = (double
) SvNV
(*tv
);
29 %apply double const
[] {
30 size_t
*p
,double
*data
, double
*dest
, double
*f_in
, double
*f_out
,
31 double data
[], const double
* src
, double x
[], double a
[], double b
[] ,
32 const double
* x
, const double
* y
, const double
* w
, const double x_array
[],
33 const double xrange
[], const double yrange
[], double
* base
,
34 const double
* base
, const double xrange
[], const double yrange
[] ,
35 const double
* array
, const double data2
[], const double w
[] ,
36 float const
*A
, float const
*B
, float const
*C
, float
*C
, double
*v
,
37 gsl_complex_packed_array data
40 %apply int
*OUTPUT { size_t
*imin
, size_t
*imax
, size_t
*neval
};
41 %apply double
* OUTPUT {
42 double
* min_out
, double
* max_out
,
43 double
*abserr
, double
*result
46 static HV
* Callbacks
= (HV
*)NULL;
47 /* this function returns the value
48 of evaluating the function pointer
49 stored in func with argument x
51 double callthis
(double x
, int func
, void
*params
){
56 //fprintf
(stderr
, "LOOKUP CALLBACK\n");
57 sv
= hv_fetch
(Callbacks
, (char
*)func
, sizeof
(func
), FALSE );
58 if
(sv
== (SV
**)NULL) {
59 fprintf
(stderr
, "Math::GSL(callthis): %d not in Callbacks!\n", func
);
64 XPUSHs
(sv_2mortal
(newSVnv
((double
)x
)));
66 call_sv
(*sv
, G_SCALAR
);
71 %typemap
(in
) gsl_monte_function
* {
73 gsl_monte_function MF
;
78 croak
("Math::GSL : $$1_name is not a reference value!");
80 if
(Callbacks
== (HV
*)NULL)
82 fprintf
(stderr
,"STORE gsl_monte_function CALLBACK: %d\n", (int
)$input
);
83 hv_store
( Callbacks
, (char
*)&$input, sizeof($input), newSVsv($input), 0 );
86 MF.function
= &callthis;
89 %typemap
(in
) gsl_function
* {
96 croak
("Math::GSL : $$1_name is not a reference value!");
98 if
(Callbacks
== (HV
*)NULL)
100 //fprintf
(stderr
,"STORE CALLBACK: %d\n", (int
)$input
);
101 hv_store
( Callbacks
, (char
*)&$input, sizeof($input), newSVsv($input), 0 );
104 F.function
= &callthis;
108 %typemap
(in
) gsl_function_fdf
* {
109 fprintf
(stderr
, 'FDF_FUNC'
);