[Rcpp-devel] Filling NumericMatrix with NumericVectors with apply by row/column?

Christian Gunning xian at unm.edu
Tue Sep 21 11:46:55 CEST 2010


> You can always attach dimensions later:
>
> ret.attr( "dim" ) = Dimension( 2, 2, 2) ;

Ah, yes.  Thanks.

> You can however Rcpp::wrap a cube. It is safer because the memory gets
> copied, but less efficient, because the memory is copied.

Got it.  I erroneously assumed an implicit wrap somewhere.

> Sure. I need to think a little bit more about how to do Rcpp::Array, etc ...
> because an Array could have an arbitrary number of dimensions.
> Perhaps embedding information into the class would work.
>
> // make an array of 3 dimensions, etc ...
> Rcpp::Array<3> ret( y ) ;

Yes, I've been thinking similarly about an Indexer class.  Accounting
for a variable number of dimensions looks unpleasantly messy.

>> * What about "ret = ret * as<int>(x);" causes ret to lose it's dimension?
>
> Omission, lack of time, I'm not using arrays all that much personally, etc

Oh, I was thinking more along the lines of "by what mechanism is
dimension lost" than "why is grass green" :)

-Christian



-- 
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!


More information about the Rcpp-devel mailing list