In instantiation of GSLBuilder in Build.PL, the value for the parameter include_dirs...
[Math-GSL.git] / swig / Poly.i
blob30079d6c01d085f4545ce9dc64b7ab59daea8670
1 %module "Math::GSL::Poly"
2 // this brakes stuff
3 // %include "typemaps.i"
4 %include "gsl_typemaps.i"
6 %{
7 #include "gsl/gsl_sys.h"
8 %}
10 %typemap(in) double * (double dvalue) {
11 SV* tempsv;
12 if (!SvROK($input)) {
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);
20 $1 = &dvalue;
23 #gsl_complex gsl_complex_poly_complex_eval (const gsl_complex c [], const int len, const gsl_complex z);
25 %typemap(argout) gsl_complex {
26 AV* tempav = newAV();
27 double x,y;
28 if (argvi >= items) {
29 EXTEND(sp,1);
31 //fprintf(stderr,"--> %g <--\n", GSL_REAL($1));
32 //fprintf(stderr,"--> %g <--\n", GSL_IMAG($1));
34 $result = sv_newmortal();
36 x = GSL_REAL($1);
37 y = GSL_IMAG($1);
39 /* the next 2 lines blow up
40 sv_setnv($result, x);
41 argvi++;
45 %typemap(argout) double * {
46 SV *tempsv;
47 tempsv = SvRV($input);
48 sv_setnv(tempsv, *$1);
51 %typemap(in) gsl_complex const [] {
52 AV *tempav;
53 I32 len;
54 int i, magic, stuff;
55 double x,y;
56 gsl_complex z;
57 SV **elem, **helem, **real, **imag;
58 HV *hash, *htmp;
59 SV *svtmp, tmp;
60 double result[2];
62 printf("gsl_complex typemap\n");
63 if (!SvROK($input))
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);
70 len = av_len(tempav);
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);
78 if ( magic != 0)
79 croak("FETCH magic failed!\n");
81 printf("magic = %d\n", magic);
82 if( *helem == NULL)
83 croak("Structure does not contain 'dat' element\n");
84 printf("helem is:\n");
85 //Perl_sv_dump(*helem);
86 if( i == 0){
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) );
92 $1[i] = 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"