[Rcpp-devel] R.e. element wise multiplication of a subcube and a row of a matrix

Christian Gunning xian at unm.edu
Mon Jan 9 12:56:54 CET 2017


> I am posting again a question about the subject cited. I tried to search
> this problem but did not find. My question is why we cannot multiply
> element wise a subcube and a row of a matrix.
>
> Any help would be appriciated. The following is sample code which is giving
> erros about the operand %.
>
>
> #include <RcppArmadillo.h>
> using namespace Rcpp;
> using namespace RcppArmadillo;
> using namespace arma;
> //[[Rcpp::depends(RcppArmadillo)]]
> //[[Rcpp::export]]
>
> arma::rowvec sub(arma::cube a, arma::mat b)
> {
>         rowvec x  =  a.subcube(0, 0, 0, 0, 2, 0)% b.row(0);
>         return x;
> }

Shaami,

When posting questions to the list, please include a complete working example.
Hint - how would I paste your example into R and get a result?
What do you expect the result to be?
How does the result differ from your expectations?

best,
Christian


More information about the Rcpp-devel mailing list