[Rd] .C and .Call: convolve example not working

From: Lars Wi▀ler <jahftw_at_googlemail.com>
Date: Thu, 11 Aug 2011 15:06:07 +0200

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):


a=array(1, c(4))
b=array(3, c(4))





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]);


[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_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 11 Aug 2011 - 21:27:31 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 12 Aug 2011 - 09:00:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive