A novice question as I learn the Rcpp classes / data structures: Is there a member function to erase a row / column for an object of class Rcpp::NumericMatrix
?
How about using RcppArmadillo? I think the intention of the code would be much clearer...
#include
// [[Rcpp::depends(RcppArmadillo)]]
using namespace arma;
// [[Rcpp::export]]
mat sub1( mat x, uword e) {
x.shed_col(e-1);
x.shed_row(e-1);
return x;
}
/*** R
sub1( matrix(1:9,3), 2 )
*/
> sub1( matrix(1:9,3), 2 )
[,1] [,2]
[1,] 1 7
[2,] 3 9