Re: [Rcpp-devel] "transposing" a list

2013-11-26 Thread Antonio Piccolboni
That worked, thanks Antonio On Tue, Nov 26, 2013 at 2:48 PM, Dirk Eddelbuettel wrote: > > On 26 November 2013 at 14:26, Antonio Piccolboni wrote: > | Hi all, > | I have a list of lists, the inner lists all of the same lengths. I would > like > | to create a new list of lists such that ll[[i]

Re: [Rcpp-devel] "transposing" a list

2013-11-26 Thread Dirk Eddelbuettel
On 26 November 2013 at 14:26, Antonio Piccolboni wrote: | Hi all, | I have a list of lists, the inner lists all of the same lengths. I would like | to create a new list  of lists such that ll[[i]][[j]] == tll[[j]][[i]]`, |  where the old one is ll and the new one is tll. In R this can be achieved

[Rcpp-devel] "transposing" a list

2013-11-26 Thread Antonio Piccolboni
Hi all, I have a list of lists, the inner lists all of the same lengths. I would like to create a new list of lists such that ll[[i]][[j]] == tll[[j]][[i]]`, where the old one is ll and the new one is tll. In R this can be achieved by the function f = splat(mapply.list) mapply.list = function

Re: [Rcpp-devel] RcppArmadillo matrix with writeable auxiliary memory

2013-11-26 Thread Steven Varga
arma::mat pointer method worked; while I trying to get the same result with arma::mat view without copying data, or passing the entire matrix seemed to be laborious. The following patter provides read/write access to some memory location using armadillo matrix operations. /* * Contact: Steven Va

Re: [Rcpp-devel] RcppArmadillo matrix with writeable auxiliary memory

2013-11-26 Thread Steven Varga
Thank you Simon for suggesting pointer then dereferencing it later in class methods. Dirk also suggested using matrix views which may have the same performance while keeping syntax neat. Will repost both working solution later on for the record. Thanks again, I found all suggestion very helpful,

Re: [Rcpp-devel] RcppArmadillo matrix with writeable auxiliary memory

2013-11-26 Thread Steven Varga
Thanks a lot again; I will look at the views and see how that works out. The matrix size is not modified inside of a layer but the content only (gradient) while the optimizer outside of the instances modifies the weight matrix accoding to gradients. Storing all layers gradients and weights at one

Re: [Rcpp-devel] RcppArmadillo matrix with writeable auxiliary memory

2013-11-26 Thread Dirk Eddelbuettel
Hi Steven On 25 November 2013 at 23:23, Steven Varga wrote: | Thank you Dirk for the quick response; | and for noting the memory handling. | | I am aware of it and there are other ways of obtaining a pointer to some memory | location. I used malloc/free to put focus on arma::mat copying data du

Re: [Rcpp-devel] RcppArmadillo matrix with writeable auxiliary memory

2013-11-26 Thread szehnder
Steve, If you want to use a variable being an arma::mat obejct with varying memory, you could use an arma::mat pointer. Otherwise if memory stays the same but should be reusable in R, Dirk's suggestion initialising memory in R and passing it to C++ is the most practicable way and very fast. B