#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
// [[Rcpp::export]]
arma::mat fed(arma::mat x){
arma::mat zz=x.shed_rows(0,2);
return(zz);
}
Just want remove some rows from matrix, get error as follows. conversion from 'void' to non-scalar type 'arma::Mat} requested'
Two points:
shed_rows()
method does not return anything. Instead it alters the matrix it acts on, c.f. the documentation.The following works:
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
// [[Rcpp::export]]
arma::mat fed(arma::mat x){
x.shed_rows(0,2);
return(x);
}
/*** R
fed(matrix(1:16, 4 ,4))
*/