Reputation: 3376
Example in R:
A: a = matrix(1:100,10,10)
B: a = matrix(1:9,3,3)
C: a = matrix(1:400,20,20)
What is the equivalent rcpp code for this simple example?
a
is always one variable with mutable contents and size.
In A, I created the matrix a with this rcpp code:
NumericMatrix a(10,10)
And fill it with sequence of number from 1 to 100. I want to resize this matrix with a command like this:
a(3,3)
or
a(20,20)
and put 1 to 9 or 1 to 400 in it.
Upvotes: 4
Views: 388
Reputation: 3376
The RcppArmadillo can solve the problem:
arma::mat m1 = arma::eye<arma::mat>( 10, 10 ) ;
m1.set_size(20,20);
m1.set_size(3,3);
I do not know if it is possible in rcpp.
Upvotes: 2