[Rcpp-devel] Error still there

Amina Shahzadi aminashahzadi at gmail.com
Tue Sep 13 02:37:51 CEST 2016


My main objective is to index some elements of a given vector and then
taking exponent.

Great Prof. Dirk. I have just minimized example and got the solution. I
would like to share my minimized code.

Thank You all.

#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace RcppArmadillo;
//[[Rcpp::depends(RcppArmadillo)]]
//[[Rcpp::export]]

arma::vec sample(arma::vec alpha)
{
        int m = alpha.size();
        arma::uvec index(m);
        arma::vec a(m);
        for(int i=0; i<m; i++)
        {
                index(i) = i;
        }
        for(int i=0; i<m; i++)
        {
                arma::vec alpha1 = alpha.elem(find(index !=i));
                a(i) = exp(alpha1(0));
        }

        return a;
}


On Tue, Sep 13, 2016 at 12:21 PM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> On 12 September 2016 at 19:05, Avraham Adler wrote:
> | What exactly is it that you are trying to do?
>
> Also review some resources on 'minimally reproducible example' as eg
>
> http://stackoverflow.com/questions/5963269/how-to-make-
> a-great-r-reproducible-example
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
>



-- 
*Amina Shahzadi*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20160913/9a021767/attachment.html>


More information about the Rcpp-devel mailing list