Finish pod separation and add stub tests for remaining subsystems
[Math-GSL.git] / swig / Poly.i
blob8656cd2792ca0bdb486f7aa4a60db6bca6b13259
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 %}
9 %include "gsl/gsl_sys.h"
11 %typemap(in) double * (double dvalue) {
12 SV* tempsv;
13 if (!SvROK($input)) {
14 croak("$input is not a reference!\n");
16 tempsv = SvRV($input);
17 if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) {
18 croak("$input is not a reference to number!\n");
20 dvalue = SvNV(tempsv);
21 $1 = &dvalue;
24 #gsl_complex gsl_complex_poly_complex_eval (const gsl_complex c [], const int len, const gsl_complex z);
26 %typemap(argout) gsl_complex {
27 AV* tempav = newAV();
28 double x,y;
29 if (argvi >= items) {
30 EXTEND(sp,1);
32 //fprintf(stderr,"--> %g <--\n", GSL_REAL($1));
33 //fprintf(stderr,"--> %g <--\n", GSL_IMAG($1));
35 $result = sv_newmortal();
37 x = GSL_REAL($1);
38 y = GSL_IMAG($1);
40 /* the next 2 lines blow up
41 sv_setnv($result, x);
42 argvi++;
46 %typemap(argout) double * {
47 SV *tempsv;
48 tempsv = SvRV($input);
49 sv_setnv(tempsv, *$1);
52 %typemap(in) gsl_complex const [] {
53 AV *tempav;
54 I32 len;
55 int i, magic, stuff;
56 double x,y;
57 gsl_complex z;
58 SV **elem, **helem, **real, **imag;
59 HV *hash, *htmp;
60 SV *svtmp, tmp;
61 double result[2];
63 printf("gsl_complex typemap\n");
64 if (!SvROK($input))
65 croak("Math::GSL : $input is not a reference!");
66 if (SvTYPE(SvRV($input)) != SVt_PVAV)
67 croak("Math::GSL : $input is not an array ref!");
69 z = gsl_complex_rect(0,0);
70 tempav = (AV*)SvRV($input);
71 len = av_len(tempav);
72 $1 = (gsl_complex *) malloc((len+1)*sizeof(gsl_complex));
73 for (i = 0; i <= len; i++) {
74 elem = av_fetch(tempav, i, 0);
76 hash = (HV*) SvRV(*elem);
77 helem = hv_fetch(hash, "dat", 3, 0);
78 magic = mg_get(*helem);
79 if ( magic != 0)
80 croak("FETCH magic failed!\n");
82 printf("magic = %d\n", magic);
83 if( *helem == NULL)
84 croak("Structure does not contain 'dat' element\n");
85 printf("helem is:\n");
86 //Perl_sv_dump(*helem);
87 if( i == 0){
88 svtmp = (SV*)SvRV(*helem);
89 //Perl_sv_dump(svtmp);
91 printf("re z = %f\n", GSL_REAL(z) );
92 printf("im z = %f\n", GSL_IMAG(z) );
93 $1[i] = z;
97 #include "gsl/gsl_nan.h"
98 #include "gsl/gsl_poly.h"
99 #include "gsl/gsl_complex.h"
100 #include "gsl/gsl_complex_math.h"
103 %include "gsl/gsl_nan.h"
104 %include "gsl/gsl_poly.h"
105 %include "gsl/gsl_complex.h"
106 %include "gsl/gsl_complex_math.h"
107 %include "../pod/Poly.pod"