Re: [Rcpp-devel] Working with indicators in Armadillo

2013-02-25 Thread Conrad S
On Sun, Feb 24, 2013 at 6:33 AM, Simon Zehnder wrote: > 1 arma::mat repS = arma::repmat(S, 1, K); > 2 arma::mat compM = arma::ones(S.n_rows, K); > 3 arma::rowvec par_post(K); > 4 > 5 for(unsigned int k = 0; k < K; ++k) { > 6 compM.col(k) = compM.col(k) * (k + 1); > 7 }

Re: [Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-03-02 Thread Conrad S
Hi everyone, In Armadillo 3.800 I've added .imbue(), allowing a matrix to be filled using a functor or C++11 lambda expression. This allows the use of the Mersenne twister random number engine built into C++11. For example: std::mt19937 engine; std::uniform_real_distribution distr(0.0, 1.0); ar

Re: [Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2013-03-11 Thread Conrad S
> #include > which is not expressive enough. I think we should go for something like boost > where we have to do > #include > but that would require a directory > (inst)/include/RcppArmadillo/RcppArmadillo/extensions/sample.h > > which reads silly. Hm. > Better suggestio

Re: [Rcpp-devel] fill a NumericMatrix row by row

2013-03-27 Thread Conrad S
There's an even simpler way when using Armadillo, so that no loop is required: http://arma.sourceforge.net/docs.html#each_colrow For example: mat X(4,5); rowvec r(5); X.each_row() = r; (btw, in general it's more efficient to access matrices as columns rather than rows). On Wed, Mar 27, 2013

Re: [Rcpp-devel] [rcpp-devel] arma::mat constructor vs Rcpp::as and interaction with .insert_col

2013-04-11 Thread Conrad S
On Fri, Apr 12, 2013 at 11:12 AM, Dale Smith wrote: > > fastLm(y, mat) # error is "error: Mat::init(): mismatch between size of > auxiliary memory and requested size" There is a further option within the Mat constructor, which when used should prevent this error. Specifically, we have: mat(aux_

Re: [Rcpp-devel] Best way to compute M'M if M is triangular using RcppArmadillo

2013-04-17 Thread Conrad S
On Wed, Apr 17, 2013 at 10:24 PM, F.Tusell wrote: > SEXP Prod1(SEXP M_) { > const mat M = as(M_) ; > mat prodM = M ; > prodM = trans(M) * M ; > return(wrap(prodM)) ; > } Why are you making a copy of M (as prodM) before doing the multiplication ? Why not just directly do "mat prodM = M.t(