Hi, I have C code to produce a lot of matrices to be analyzed. As these matrices are large (> 1000*10000) and are a lot (> 1000), I am thinking about how to pass them from C to R effectively.
Would you think about the following solution? In R, I create a wrapper function passDataFromCToR = function(row, col) { mat = matrix(0, row, col) .C("passDataFromCToR",mat)[[1]] } It wraps the following C function void passDataFromCToR (double *m, int *row, int* col){ mymat = f() // my c function to produce a matrix // then I copy mymat to m element by element via a loop } Then to use these functions, I would write in R mat = passDataFromCToR(1000, 10000) Two issues with this approach are that 1) I have to copy the data once and 2)to the worse, in R I have to know the dimension of the matrices to be passed from C. This information is not always available. I would appreciate if you share with me your thoughts on how to solve this problem better. thanks Jeff ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.