1 %module
"Math::GSL::Poly"
3 // %include
"typemaps.i"
4 %include
"gsl_typemaps.i"
7 #include
"gsl/gsl_sys.h"
10 %typemap
(in
) double
* (double dvalue
) {
13 croak
("$input is not a reference!\n");
15 tempsv
= SvRV
($input
);
16 if
((!SvNOK
(tempsv
)) && (!SvIOK(tempsv))) {
17 croak
("$input is not a reference to number!\n");
19 dvalue
= SvNV
(tempsv
);
23 #gsl_complex gsl_complex_poly_complex_eval
(const gsl_complex c
[], const int len
, const gsl_complex z
);
25 %typemap
(argout
) gsl_complex
{
31 //fprintf
(stderr
,"--> %g <--\n", GSL_REAL
($
1));
32 //fprintf
(stderr
,"--> %g <--\n", GSL_IMAG
($
1));
34 $result
= sv_newmortal
();
39 /* the next
2 lines blow up
45 %typemap
(argout
) double
* {
47 tempsv
= SvRV
($input
);
48 sv_setnv
(tempsv
, *$
1);
51 %typemap
(in
) gsl_complex const
[] {
57 SV
**elem
, **helem
, **real
, **imag
;
62 printf
("gsl_complex typemap\n");
64 croak
("Math::GSL : $input is not a reference!");
65 if
(SvTYPE
(SvRV
($input
)) != SVt_PVAV
)
66 croak
("Math::GSL : $input is not an array ref!");
68 z
= gsl_complex_rect
(0,0);
69 tempav
= (AV
*)SvRV
($input
);
71 $
1 = (gsl_complex
*) malloc
((len
+1)*sizeof
(gsl_complex
));
72 for
(i
= 0; i
<= len
; i
++) {
73 elem
= av_fetch
(tempav
, i
, 0);
75 hash
= (HV
*) SvRV
(*elem
);
76 helem
= hv_fetch
(hash
, "dat", 3, 0);
77 magic
= mg_get
(*helem
);
79 croak
("FETCH magic failed!\n");
81 printf
("magic = %d\n", magic
);
83 croak
("Structure does not contain 'dat' element\n");
84 printf
("helem is:\n");
85 //Perl_sv_dump
(*helem
);
87 svtmp
= (SV
*)SvRV
(*helem
);
88 //Perl_sv_dump
(svtmp
);
90 printf
("re z = %f\n", GSL_REAL
(z
) );
91 printf
("im z = %f\n", GSL_IMAG
(z
) );
96 #include
"gsl/gsl_nan.h"
97 #include
"gsl/gsl_poly.h"
98 #include
"gsl/gsl_complex.h"
99 #include
"gsl/gsl_complex_math.h"
102 %include
"gsl/gsl_nan.h"
103 %include
"gsl/gsl_poly.h"
104 %include
"gsl/gsl_complex.h"
105 %include
"gsl/gsl_complex_math.h"
106 %include
"../pod/Poly.pod"