Hi Dear

I am very new to use RcppArmadillo. I am trying to execute the following code. 
But I got the error

cannot convert 'arma::enable_if2<true, const 
arma::eOp<arma::eGlue<arma::Col<double>, arma::Col<double>, arma::eglue_plus>, 
arma::eop_exp> >::result {aka const arma::eOp<arma::eGlue<arma::Col<double>, 
arma::Col<double>, arma::eglue_plus>, arma::eop_exp>}' to 'double' in return
      return exp(alpha2+beta2);
                             ^
sample.cpp:36:1: warning: control reaches end of non-void function 
[-Wreturn-type]
 }



My code is  as follows: Any help in this regard.
Thank You



#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace RcppArmadillo;
//[[Rcpp::depends(RcppArmadillo)]]
//[[Rcpp::export]]
arma::duble 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);
                                   }
                      }
           }
}
}




        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to