<div dir="ltr"><div><div><div>Hello Dear<br><br></div>I am new user of RcppArmadillo and Rcpp.<br></div>I am using a sample function pasted here. I am haivng error given below: Any can help in this regard.<br><br>In function ‘arma::vec sample(arma::vec, arma::vec)’:<br>sample.cpp:23:35: error: could not convert ‘exp((alpha1.arma::Col<double>::<anonymous>.arma::Mat<eT>::operator()<double>(0u) + beta1.arma::Col<double>::<anonymous>.arma::Mat<eT>::operator()<double>(1u)))’ from ‘double’ to ‘arma::vec {aka arma::Col<double>}’<br> return exp(alpha1(0)+beta1(1));<br> ^<br>sample.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]<br> }<br> <br></div>My function sample.cpp is below.<br><div><br><br><br>#include <RcppArmadillo.h><br>using namespace Rcpp;<br>using namespace RcppArmadillo;<br>//[[Rcpp::depends(RcppArmadillo)]]<br>//[[Rcpp::export]]<br><br>arma::vec sample(arma::vec alpha, arma::vec beta)<br>{<br> int m = alpha.size();<br> arma::uvec index(m);<br> for(int i=0; i<m; i++)<br> {<br> index(i) = i;<br> }<br> for(int i=0; i<m; i++)<br> {<br> for(int j=0; j<m; j++)<br> {<br> if(i==j)<br> {<br> arma::vec alpha1 = alpha.elem(find(index !=j));<br> arma::vec beta1 = beta.elem(find(index!=j));<br> return exp(alpha1(0)+beta1(1));<br> }<br> else<br> {<br> arma::vec alpha2 = alpha.elem(find(index !=i && index !=j));<br> arma::vec beta2 = beta.elem(find(index !=i && index !=j));<br> return exp(alpha2+beta2);<br> }<br> }<br> }<br><br>}<br><br><br><br clear="all"><div><div><div><br>-- <br><div class="gmail_signature"><i><font face="comic sans ms,sans-serif">Amina Shahzadi</font></i></div>
</div></div></div></div></div>