c++ - error when passing `arma::cube`argument to function using RcppArmadillo -
i getting following error when trying compile using sourcecpp
rcpp
package:
`my path r/.../rcpp/internal/exporter.h` no matching function call 'arma::cube<double>::cube(sexprec*&)'
the object cube
armadillo
equivalent of array
in r
.
edit: note problem seems function can't accept arma::cube
object argument. if change arma::cube b
by arma::mat b
it work:
#include <rcpparmadillo.h> // [[rcpp::depends(rcpparmadillo)]] using namespace arma; // [[rcpp::export]] arma::cube ssmooth(arma::mat a, arma::cube b) { int ns = a.n_rows; int nk = a.n_cols; int np = b.n_rows; arma::mat c = zeros<mat>(nk, ns); arma::cube d = zeros<cube>(nk, nk, ns); return d; }
i appreciate hint.
a basic example works:
r> cppfunction("arma::cube getcube(int n) { arma::cube a(n,n,n);\ a.zeros(); return a; }", depends="rcpparmadillo") r> getcube(2) , , 1 [,1] [,2] [1,] 0 0 [2,] 0 0 , , 2 [,1] [,2] [1,] 0 0 [2,] 0 0 r>
so either doing wrong or installation off.
Comments
Post a Comment