[Rcpp-devel] Deep copying a matrix

Dirk Eddelbuettel edd at debian.org
Thu Jul 14 20:52:44 CEST 2011


On 14 July 2011 at 14:39, Etienne B. Racine wrote:
| 
| Dirk Eddelbuettel wrote:
| 
| 
|     Doug first wrote:
| 
|     | >> I would rewrite your code fragment as
|     | >>
|     | >>    const Rcpp::NumericMatrix  m_source(origin);
|     | >>    Rcpp::NumericMatrix m_copy = Rcpp::clone(m_source);
| 
|     Seconded.
| 
|  
| 
|     If Etienne needs new behaviour very badly, he may have to look into
|     contributing it, or providing funding which may give a higher chance to
|     have
|     this getting push up on the priority list.
| 
| 
| No, I don't need it badly. 

:)  Cool.

| (I have more than enough features to learn from Rcpp
| !) I was trying to wrap my head around Rcpp and getting back to c++ after
| spending years in R.

I find Rcpp makes getting back to C++ so much easier.  If you have a
suggestion as to where this little casting issue could be documented more
easily, let us know.  There are arguably already too many features but then
there just so mnay use cases, things to cover, ... so the docs will always be
somewhat spotty.

Lastly, regarding the deep vs shallow copy: I actually changed my mind on
this and prefer shallow copies, esp once you pay attention to performance as
eg in simulation and frequently executed code paths.

Dirk

-- 
Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com


More information about the Rcpp-devel mailing list