Hello C-programmers,

I have been using R for a while and am stuck because I don`t understand some C code that R is calling. Here is the problem:

In R, the following matrix (delay function) is created:

Code:

fractions <- c(0,0.09,0.41,1)
distance <- c(0,51,360,920)
delay <- cbind(fractions, distance)

the result in R looks like this:

fractions distance

[1,] 0.00 0

[2,] 0.09 51

[3,] 0.41 360

[4,] 1.00 920

This is fine. Now the delay matrix is sent to a c script using the command:

Code:

Result <- .C(“samplescript”,
PACKAGE =”samplepackage”,
as.double(as.matrix(delay))
as.integer(length(delay[,1])))

then in the c “samplescript”, the following lines are executed:

Code:

void param_init(double *delay, int nch)
/* reading delay function */
for(i=0; i<nch; i++){
params.d[i] = delay[i];
params.Ad_r[i] = delay[i+nch];
}

What are the values of Ad_r [i]? Is params.d [i] a vector or a matrix? I don`t understand what the C code does with the delay function.

Thank you for your help!