[Rcpp-devel] Initializing Armadillo vec/cube from NumericVector using as conversion
Dirk Eddelbuettel
edd at debian.org
Thu Sep 22 22:09:55 CEST 2016
Oh, and it should work the same for cube types:
R> cppFunction("void test2(arma::cube & x) { x(0,0,0) = 0.5; }",
R> depends="RcppArmadillo")
R> v <- array(sqrt(1:8), c(2, 2, 2))
R> v
, , 1
[,1] [,2]
[1,] 1.00000 1.73205
[2,] 1.41421 2.00000
, , 2
[,1] [,2]
[1,] 2.23607 2.64575
[2,] 2.44949 2.82843
R> test2(v)
R> v
, , 1
[,1] [,2]
[1,] 0.50000 1.73205
[2,] 1.41421 2.00000
, , 2
[,1] [,2]
[1,] 2.23607 2.64575
[2,] 2.44949 2.82843
R>
Proxy object that still connected to the outside object, unless a cast is
needed (int <-> double), or a copy is enforced (clone(), possibly via as<>()).
Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the Rcpp-devel
mailing list