Thank you for welcoming me. Your help will be appreciatable. My problem is still there and getting the following error. sample.cpp: In function ‘double sample(arma::vec, arma::vec)’: sample.cpp:29:29: error: cannot convert ‘arma::enable_if2<true, const arma::eOp< arma::eGlue<arma::Col<double>, arma::Col<double>, arma::eglue_plus>, arma::eop_e xp> >::result {aka const arma::eOp<arma::eGlue<arma::Col<double>, arma::Col<doub le>, arma::eglue_plus>, arma::eop_exp>}’ to ‘double’ in return return exp(alpha2+beta2); ^ sample.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-typ e] }
My sample code is #include <RcppArmadillo.h> using namespace Rcpp; using namespace RcppArmadillo; //[[Rcpp::depends(RcppArmadillo)]] //[[Rcpp::export]] double 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); } } } } Thank you -- *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