Merge branch 'master' into bleed
[Math-GSL.git] / GSL.i
blob83ee57fc7cacd28a63979be9cf238c6ac7e8dfdf
1 %typemap(in) double const [] {
2 AV *tempav;
3 I32 len;
4 int i;
5 SV **tv;
6 if (!SvROK($input))
7 croak("$input is not a reference!");
8 if (SvTYPE(SvRV($input)) != SVt_PVAV)
9 croak("$input is not an array!");
11 tempav = (AV*)SvRV($input);
12 len = av_len(tempav);
13 $1 = (double *) malloc((len+1)*sizeof(double));
14 for (i = 0; i <= len; i++) {
15 tv = av_fetch(tempav, i, 0);
16 $1[i] = (double) SvNV(*tv);
18 $1[i] = GSL_NAN;
21 %typemap(freearg) double const [] {
22 free($1);
25 %typemap(in) double * (double dvalue) {
26 SV* tempsv;
27 if (!SvROK($input)) {
28 croak("$input is not a reference!\n");
30 tempsv = SvRV($input);
31 if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) {
32 croak("$input is not a reference!\n");
34 dvalue = SvNV(tempsv);
35 $1 = &dvalue;
38 %typemap(argout) double * {
39 SV *tempsv;
40 tempsv = SvRV($input);
41 sv_setnv(tempsv, *$1);