Skip to content
Prev 8538 / 10988 Next

[Rcpp-devel] Accessing list of list members to permute them

Hi, 

Perhaps you can use ListOf<NumericMatrix> instead of List, as output[i] does not know it is a matrix, so the operator()(int, int) don?t make sense. 

You?d need (untested, ont sure you can nest layers of ListOf) 

ListOf< NumericMatrix > x
ListOf< ListOf<NumericMatrix> > output ;


Otherwise, perhaps something like the more noisy code:

NumericMatrix output_i = output[i] ;
List x_k = x[k] ;
NumericMatrix x_k_0 = x_k[0] ;
output_i(j,k) = x_k_0(j,i) ;

Also, you need to actually creates the matrices in output. something like : 

List output(ni) ;
for (int i= 0 ; i<ni ; i++){
   output[i] = NumericMatrix( nj, nk ) ;
}

Romain