Dear R users, I want to call C code via the .C or .Call interface. This works fine with integer values but using doubles the array received in C will be set to zeros.
I have tried the convolve examples (Writing R extensions, chapter 5.2) and still the resulting array consists of zeros. My code (shortened for my purposes. Original did not work either): ------------------------------------------------------------ convolve.r a=array(1, c(4)) b=array(3, c(4)) print(a) print(b) .C("convolve", as.double(a), as.double(b)) ---------------------------------------------------------------- convolve.c void convolve(double* a, double* b){ int i; for(i=0;i<4;i++) Rprintf("a: %d", a[i]); for(i=0;i<4;i++) Rprintf("b: %d", b[i]); } -------------------------------------------------------------- ouput: [1] "starting C code..." [1] 1 1 1 1 [1] 3 3 3 3 a: 30467528 a: 0 a: 0 a: 0 b: 0 b: 0 b: 0 b: 0 Any suggestions as to why this is happening and what I am doing wrong would be much appreciated. I have tried .Call with conversion SEXP to double with REAL(a)/REAL(b) with the same results (the entry first entry of a has a different number, but is huge as well). I am quite astonished with the results I am getting. Thanks and regards, Lars Wissler ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel