Re: [Rcpp-devel] Eigen-like pointer mappings in Rcpp?

2015-02-17 Thread Dirk Eddelbuettel
On 17 February 2015 at 18:31, Yixuan Qiu wrote: | Oops sorry, should be begin(). data() is the Eigen method. Ah, indeed. And begin() has been there for a lng time. And we have shown the trick of initializing with it several dozen times too -- all the early RcppArmadillo docs show it. Dirk

Re: [Rcpp-devel] assert() for Rcpp?

2015-02-17 Thread JJ Allaire
I agree that having an assert which complies with CRAN standards would be valuable. One piece of immediate feedback on your initial implementation: you can't call Rf_error from C++ code (as it will bypass C++ destructors on the stack). Rather, you should throw Rcpp::exception. Whether assert shou

[Rcpp-devel] assert() for Rcpp?

2015-02-17 Thread Miratrix, Luke
Dirk Eddelbuettel and I were discussing how people do not seem to be putting assert() statements in their C code in Rcpp packages. I expect the reason is because assert() prints to cerr, which is a violation of the CRAN policies of proper packages. However, the assert() command is a simple macro

Re: [Rcpp-devel] Eigen-like pointer mappings in Rcpp?

2015-02-17 Thread Yixuan Qiu
Oops sorry, should be begin(). data() is the Eigen method. Best, Yixuan On Feb 17, 2015 6:12 PM, "Sparapani, Rodney" wrote: > 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 mod

Re: [Rcpp-devel] Eigen-like pointer mappings in Rcpp?

2015-02-17 Thread Dirk Eddelbuettel
On 17 February 2015 at 23:12, Sparapani, Rodney wrote: | That's exactly what I wanted! However, I can't seem to find that method | at http://dirk.eddelbuettel.com/code/rcpp/html The documentation is for version 0.11.4. | I'm using Rcpp 0.10.3 w/ 2.15.3 R and GCC 4.4.7 if it matters. Ouch. Yo

Re: [Rcpp-devel] Eigen-like pointer mappings in Rcpp?

2015-02-17 Thread Sparapani, Rodney
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::

Re: [Rcpp-devel] Eigen-like pointer mappings in Rcpp?

2015-02-17 Thread Yixuan Qiu
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 dire

[Rcpp-devel] Eigen-like pointer mappings in Rcpp?

2015-02-17 Thread Sparapani, Rodney
Hi Gang: I am working with some C++ code that uses pointers. I know I could change the code. But, I was wondering if there is an easy way to map the double pointer into the R data via Rcpp. I have been using RcppEigen to do that. For example... RcppExport SEXP myfunc(SEXP _n, SEXP _x) {