[R] Cannot convert from unsigned int to double

Amina Shahzadi Shahzadi shaam249 at student.otago.ac.nz
Thu Sep 8 03:03:58 CEST 2016


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]]



More information about the R-help mailing list