Hello Dear I am new user of RcppArmadillo and Rcpp. I am using a sample function pasted here. I am haivng error given below: Any can help in this regard.
In function ‘arma::vec sample(arma::vec, arma::vec)’: 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>}’ return exp(alpha1(0)+beta1(1)); ^ sample.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type] } My function sample.cpp is below. #include <RcppArmadillo.h> using namespace Rcpp; using namespace RcppArmadillo; //[[Rcpp::depends(RcppArmadillo)]] //[[Rcpp::export]] arma::vec sample(arma::vec alpha, arma::vec beta) { int m = alpha.size(); arma::uvec index(m); for(int i=0; i<m; i++) { index(i) = i; } for(int i=0; i<m; i++) { for(int j=0; j<m; j++) { if(i==j) { arma::vec alpha1 = alpha.elem(find(index !=j)); arma::vec beta1 = beta.elem(find(index!=j)); return exp(alpha1(0)+beta1(1)); } else { arma::vec alpha2 = alpha.elem(find(index !=i && index !=j)); arma::vec beta2 = beta.elem(find(index !=i && index !=j)); return exp(alpha2+beta2); } } } } -- *Amina Shahzadi*
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel