title: How can I multiply an Armadillo matrix with a NumericVector obtained from qnorm()?
body: <p>When I try to multiply an arma::mat and a NumericVector in Rcpp using operator*, I get the following error:</p>
  <pre><code>no match for operator*
  </code></pre>
  <p>Here is an example of what I'm trying to multiply:</p>
  <pre><code>NumericVector exampleNumericVector(L-1);
  arma::mat exampleMatrix(L-1,L-1);
  exampleMatrix*(Rcpp::qnorm(exampleNumericVector,0,1,true,false));
  </code></pre>
  <p>I have tried looking through the <em>excellent</em> Armadillo documentation, and the closest I could find to a solution is the prod() function, but this has not corrected my issue. I tried overloading the operator*, as well. However, this was also unsuccessful.</p>
  <p><strong>Update: Reproducible example</strong></p>
  <pre><code>// [[Rcpp::depends(RcppArmadillo)]]
  #include &lt;RcppArmadillo.h&gt;
  #include &lt;RcppArmadilloExtensions/sample.h&gt;
  
  using namespace Rcpp;
  using namespace arma;
  
  // [[Rcpp::export]]
  arma::vec foo(Rcpp::NumericVector x) {
    // [[Rcpp::depends(RcppArmadillo)]]
    Rcpp::NumericVector y = Rcpp::qnorm(x, 0, 1, true, false);
    int n = y.size();
    arma::mat M(n,n);
    M.fill(1.0);                  // nonsense content, we don't care
    arma::vec v(y);               // instantiate Arma vec from Rcpp vec
    arma::vec res = M * v;
    return res;
  }
  
  // [[Rcpp::export]]
  Rcpp::List foo(const int n, const int M, const int L, const double mu){
    
    // initialize variables
    arma::mat P = arma::zeros(M,L);
    arma::mat SigInvTmp = arma::zeros(L-1,L-1);
    double muTmp = 0;
    double s2Tmp = 0;
    arma::mat Sig = arma::zeros(L,L);
    arma::mat Sigee = arma::zeros(L-1,L-1);
    arma::mat Sigie = arma::zeros(1,L-1);
    arma::mat Sigei = arma::zeros(L-1,1);
    Rcpp::NumericVector Pie(L-1);
    
    for(int i = 0; i &lt; M; i++){
      
      arma::uvec iIdx(1); // vector of index to take for i
      iIdx(0) = i;
      
      for(int l = 0; l &lt; L; l++){
        
        srand(time(0)); 
        
        // We need to get the vector of indices excluding l
        arma::uvec idx(L-1); // vector of indices to subset by
        arma::uword ii = 0;  // the integer we'll add at each elem of idx
        for (arma::uword j = 0; j &lt; (L-1); ++j) {
          if (ii == l) {   // if ii equals l, we need to skip l
            ii += 1;     
          }
          idx[j] = ii;     // then we store ii for this elem
          ii += 1;         // and increment ii
        }
        
        // Single index for l
        arma::uvec lIdx(1); // vector of index to take for l
        lIdx(0) = l;
        
        Sigee = Sig.submat(idx,idx);
        Sigie = Sig.submat(lIdx,idx);
        Sigei = Sig.submat(idx,lIdx);
        Pie = P.submat(iIdx,idx);
        
        SigInvTmp = inv(Sigee);
        arma::vec qnormVec = foo(Pie);
        muTmp = mu + as_scalar(Sigie*SigInvTmp*(qnormVec-mu));
        s2Tmp = sqrt(as_scalar(Sig(l,l)-Sigie*SigInvTmp*Sigei));
      }
    }
    return Rcpp::List::create(Rcpp::Named(&quot;mu&quot;) = muTmp, Rcpp::Named(&quot;s2&quot;) = s2Tmp);
  }
  </code></pre>