[Rcpp-devel] What's the most efficient way to convert a NumericVector to an array of doubles

2013-06-29 Thread Anwar Ludin
Hello, I need to interface some R code with a numerical library containing functions taking as input double* What is the most efficient way to create an array of doubles from a NumericVector. I was thinking of something like: // input is of type Rcpp::NumericVector and passed from R std:

Re: [Rcpp-devel] What's the most efficient way to convert a NumericVector to an array of doubles

2013-06-29 Thread Romain Francois
Hello, just use: double* values = input.begin() ; A NumericVector uses R allocated memory, and R allocates an array of doubles to store a numeric vector. You then need to remember you dońt own the pointer. So make sure your code does not eg delete[] it. The code you've used was very inef

Re: [Rcpp-devel] What's the most efficient way to convert a NumericVector to an array of doubles

2013-06-29 Thread Anwar Ludin
Romain, Thanks a lot for the clarifications! Anwar On Jun 29, 2013, at 12:35 PM, Romain Francois wrote: > Hello, > > just use: > > double* values = input.begin() ; > > A NumericVector uses R allocated memory, and R allocates an array of doubles > to store a numeric vector. > > You the