Hello, I am trying to pass a array of references on array to a c subroutine: my @set_2d = ([0.0, 1.0], [1.1, 2.2], [3.1, 4.4]) ; test::test([EMAIL PROTECTED]) ;
in xs I put: typedef double floatArray ; void * floatArrayPtr (int num) { SV * mortal ; mortal = sv_2mortal (NEWSV (0, num * sizeof (floatArray))) ; return SvPVX (mortal) ; } double spectrum_2d (avref) AV * avref PREINIT: int len, ncols; int i, j ; SV ** elem ; floatMatrix *matrix ; AV** row ; CODE: len = av_len (avref) + 1 ; printf ("spectrum_2d: %d\n", len) ; ncols = 2 ; matrix = floatMatrixPtr (len) ; for (i = 0 ; i < len ; i++) { matrix [i] = floatArrayPtr (ncols) ; } for (i = 0 ; i < len ; i++) { row = av_fetch (avref, i , 0) ; if (row =! NULL) { for (j = 0 ; j < ncols ; j++) { elem = av_fetch (*row, j , 0) ; if (elem == NULL) { matrix [i] [j] = 0 ; } else { matrix [i] [j] = SvNV (*elem) ; } } } } RETVAL = 0 ; OUTPUT: RETVAL But it does not work, If somebody could tell me what is wrong ! Regards. -- --- ========================================================================== Patrick DUPRÉ | | Department of Chemistry | | Phone: (44)-(0)-1904-434384 The University of York | | Fax: (44)-(0)-1904-432516 Heslington | | York YO10 5DD United Kingdom | | email: [EMAIL PROTECTED] ==========================================================================
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/