Re: [Rcpp-devel] Variable for loop

2016-09-26 Thread Amina Shahzadi
Wa. ImpressiveI have tried it. It is giving the same answer I want. Now I learn it step by step how you did that. It is very different concept from what I was using in rcpp. Thank you so very much Avraham. On Tue, Sep 27, 2016 at 4:52 PM, Avraham Adler wrote: > Hello, Amina. > > It is mu

Re: [Rcpp-devel] Variable for loop

2016-09-26 Thread Avraham Adler
Hello, Amina. It is much, much, much easier to deal with small, simplified, examples, as Dirk and others have explained before. Changing your code to make n = 4 and the values seq(1, 12), we can see the pattern. For each slice, you are taking the product down the rows of "slice" number of entries.

Re: [Rcpp-devel] Variable for loop

2016-09-26 Thread Amina Shahzadi
Hi Dear This is the corresponding R code which I want to have the same result from rcpp code. set.seed(11) a = matrix(runif(30), nrow=10, ncol=3) n=10 m=3 b = array(as.double(0), dim = c(n, m, n)) for(i in 1:n){ for(j in 1:m){ for(q in 1:i){ if(q==1){ b[i, j, q] = a[i, j];

Re: [Rcpp-devel] Variable for loop

2016-09-26 Thread Avraham Adler
Please give a simple example of an input and its expected output. Unfortunately "run of a variable for loop" is too general for me to understand. Avi On Mon, Sep 26, 2016 at 10:07 PM, Amina Shahzadi wrote: > Hi Dear > > My purpose is to make run of a variable for loop. Here I have assumed else >

Re: [Rcpp-devel] Variable for loop

2016-09-26 Thread Amina Shahzadi
Hi Dear My purpose is to make run of a variable for loop. Here I have assumed else statement to be zero. Otherwise it could be anything for example in the following code. In this code, my main aim to run the slices loop according to rows. does it now look ok? Thank you #include using namespace

Re: [Rcpp-devel] Variable for loop

2016-09-26 Thread Avraham Adler
Hello. Once again, it is very unclear what you want to do. Can you please explain, in English not code what your procedure intends to do, the input you expect, and the output you expect? What it LOOKS like you want to do is to create an N x M x N cube where the first slice is your matrix and the

[Rcpp-devel] Variable for loop

2016-09-26 Thread Amina Shahzadi
Hi Dear I have a problem in using a variable for loop in using RcppArmadillo library. I have pasting here my code. It is executing but not giving the same results as its R code version gives. The results produced by it are really weird. I have checked it step by step. It is because of the for (int