<p dir="ltr">Oops sorry, should be begin(). data() is the Eigen method.<br></p>
<p dir="ltr">Best,<br>
Yixuan</p>
<div class="gmail_quote">On Feb 17, 2015 6:12 PM, "Sparapani, Rodney" <<a href="mailto:rsparapa@mcw.edu">rsparapa@mcw.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, 2015-02-17 at 15:57 -0500, Yixuan Qiu wrote:<br>
> Hello Rodney,<br>
><br>
> If all you need is to pass a pointer to the fit() function (assuming<br>
> fit() does not modify x) and get the result a, you do not need to make<br>
> a copy. Simply wrap _x by a NumericVector and call the data() method.<br>
><br>
> Rcpp::NumericVector x(_x);<br>
><br>
> double a = fit(x.data(), n);<br>
><br>
> You can even directly use the R API without creating an Rcpp object.<br>
><br>
> double a = fit(REAL(_x), n);<br>
><br>
><br>
> Best,<br>
><br>
> Yixuan<br>
<br>
Hi Yixuan:<br>
<br>
That's exactly what I wanted!  However, I can't seem to find that method<br>
at <a href="http://dirk.eddelbuettel.com/code/rcpp/html" target="_blank">http://dirk.eddelbuettel.com/code/rcpp/html</a><br>
<br>
Can you please point me to it?<br>
<br>
>From this...<br>
<br>
Rcpp::NumericVector x(_x);<br>
<br>
double a = fit(x.data(), n);<br>
<br>
I get...<br>
<br>
error: class Rcpp::NumericVector has no member named data<br>
<br>
Am I doing something dumb?<br>
<br>
I'm using Rcpp 0.10.3 w/ 2.15.3 R and GCC 4.4.7 if it matters.<br>
<br>
Thanks,<br>
<br>
Rodney<br>
<br>
</blockquote></div>