1 %module "Math::GSL::Poly" 2 // this brakes stuff 3 // %include "typemaps.i" 4 %include "gsl_typemaps.i" 5 %include "renames.i" 6 7 %{ 8 #include "gsl/gsl_sys.h" 9 %} 10 11 %typemap(in) double * (double dvalue) { 12 SV* tempsv; 13 if (!SvROK($input)) { 14 croak("$input is not a reference!\n"); 15 } 16 tempsv = SvRV($input); 17 if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { 18 croak("$input is not a reference to number!\n"); 19 } 20 dvalue = SvNV(tempsv); 21 $1 = &dvalue; 22 } 23 24 /* gsl_complex gsl_complex_poly_complex_eval (const gsl_complex c [], const int len, const gsl_complex z); */ 25 26 %typemap(argout) gsl_complex { 27 AV* tempav = newAV(); 28 double x,y; 29 if (argvi >= items) { 30 EXTEND(sp,1); 31 } 32 //fprintf(stderr,"--> %g <--\n", GSL_REAL($1)); 33 //fprintf(stderr,"--> %g <--\n", GSL_IMAG($1)); 34 35 $result = sv_newmortal(); 36 37 x = GSL_REAL($1); 38 y = GSL_IMAG($1); 39 40 /* the next 2 lines blow up 41 sv_setnv($result, x); 42 argvi++; 43 */ 44 }; 45 46 %typemap(argout) double * { 47 SV *tempsv; 48 tempsv = SvRV($input); 49 sv_setnv(tempsv, *$1); 50 } 51 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]; 62 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!"); 68 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); 75 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"); 81 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); 90 } 91 printf("re z = %f\n", GSL_REAL(z) ); 92 printf("im z = %f\n", GSL_IMAG(z) ); 93 $1[i] = z; 94 } 95 } 96 %{ 97 #include "gsl/gsl_inline.h" 98 #include "gsl/gsl_nan.h" 99 #include "gsl/gsl_poly.h" 100 #include "gsl/gsl_complex.h" 101 #include "gsl/gsl_complex_math.h" 102 %} 103 104 %include "gsl/gsl_inline.h" 105 %include "gsl/gsl_nan.h" 106 %include "gsl/gsl_poly.h" 107 %include "gsl/gsl_complex.h" 108 %include "gsl/gsl_complex_math.h" 109 %include "../pod/Poly.pod" 110 111