[Rcpp-devel] Eigen-like pointer mappings in Rcpp?
Sparapani, Rodney
rsparapa at mcw.edu
Wed Feb 18 00:12:43 CET 2015
On Tue, 2015-02-17 at 15:57 -0500, Yixuan Qiu wrote:
> Hello Rodney,
>
> If all you need is to pass a pointer to the fit() function (assuming
> fit() does not modify x) and get the result a, you do not need to make
> a copy. Simply wrap _x by a NumericVector and call the data() method.
>
> Rcpp::NumericVector x(_x);
>
> double a = fit(x.data(), n);
>
> You can even directly use the R API without creating an Rcpp object.
>
> double a = fit(REAL(_x), n);
>
>
> Best,
>
> Yixuan
Hi Yixuan:
That's exactly what I wanted! However, I can't seem to find that method
at http://dirk.eddelbuettel.com/code/rcpp/html
Can you please point me to it?
From this...
Rcpp::NumericVector x(_x);
double a = fit(x.data(), n);
I get...
error: class Rcpp::NumericVector has no member named data
Am I doing something dumb?
I'm using Rcpp 0.10.3 w/ 2.15.3 R and GCC 4.4.7 if it matters.
Thanks,
Rodney
More information about the Rcpp-devel
mailing list