<div dir="ltr"><div><div><div>Hello Friends and Prof. Dirk<br><br></div>I am pasting here a code which has a for loop depending on another for loop. <br></div>I am getting zeros for cube c. I tried and searched a lot but did not get an example of this type. Would you please help in this regard?<br><br><br>#include <RcppArmadillo.h><br>using namespace Rcpp;<br>using namespace RcppArmadillo;<br>using namespace arma;<br>//[[Rcpp::depends(RcppArmadillo)]]<br>//[[Rcpp::export]]<br><br><br>arma::cube  exam(arma::vec a,  arma::mat b)<br>{<br>  int m = a.size();<br>  int n = b.n_rows;<br>  arma::cube c = zeros<cube>(n, m, n);<br>  for(int i=0; i<n; i++) {<br>    for(int j=0; j<m; j++) {<br>      for(int k=0; k<i; k++) {<br>          if(k==0) {<br>            c(i, j ,k) = c(i, j, k) + b(i, j);<br>          }<br>          else{<br>            c(i, j, k) = c(i, j, k) +  c(i-1, j, k) *b(i, j);<br>          }<br>         }<br>        }<br>      }<br>  return c;<br>}<br><br><br></div><div><div><div><div>Thank You<br></div><div>-- <br><div class="gmail_signature"><i><font face="comic sans ms,sans-serif">Amina Shahzadi</font></i></div>
</div></div></div></div></div>