Re: [Rcpp-devel] R & RcppArmadillo decomposition disagreement

2013-05-31 Thread Dirk Eddelbuettel
On 31 May 2013 at 16:35, Colin Rundel wrote: | I think that I've actually found the issue, the liblapack.so and libblas.so installed in my /usr/lib/R/lib/ were actually from the revolution-mkl package and not from r-base-core. Once I purged that package everything seems to be working. Not sure

Re: [Rcpp-devel] R & RcppArmadillo decomposition disagreement

2013-05-31 Thread Colin Rundel
I think that I've actually found the issue, the liblapack.so and libblas.so installed in my /usr/lib/R/lib/ were actually from the revolution-mkl package and not from r-base-core. Once I purged that package everything seems to be working. Not sure what criteria the g++ linker was using to chose

Re: [Rcpp-devel] R & RcppArmadillo decomposition disagreement

2013-05-31 Thread Dirk Eddelbuettel
Hi Colin, On 31 May 2013 at 15:31, Colin Rundel wrote: | For certain operations R does _not_ go to lapack but uses its own. I can | never remember if chol() was one of them -- but this suggests it. As I | mentioned in my earlier email you probably really have to follow the chol() |

Re: [Rcpp-devel] R & RcppArmadillo decomposition disagreement

2013-05-31 Thread Simon Zehnder
Hi Colin, I also found an article referring to a blog of Dirk: http://techyoubaji.blogspot.de/2012/12/r-uses-different-blas-and-lapack.html Maybe it is interesting for you. Best Simon On May 31, 2013, at 9:55 PM, Simon Zehnder wrote: > Isn't this actually an option when installing R > (ht

Re: [Rcpp-devel] R & RcppArmadillo decomposition disagreement

2013-05-31 Thread Simon Zehnder
Isn't this actually an option when installing R (http://www.cran.r-project.org/doc/manuals/R-admin.html)? If it hasn't been explicitly stated in the configure stage of R via --with-lapack, R uses its internal routines. Best Simon On May 31, 2013, at 9:31 PM, Colin Rundel wrote: >> For cer

Re: [Rcpp-devel] Conversion of Rcpp::Vector Rcpp::List and Rcpp::Matrix to std objects - OpenMP

2013-05-31 Thread Simon Zehnder
Hi Asis, in addition to what Dirk said I can tell you, that at least Armadillo Objects do work accurate with OpenMP. I used in my code an '#pragma omp parallel for' directive on a lot of Armadillo matrices without any problems. Be aware of what clauses you use in your parallel setting. There

Re: [Rcpp-devel] R & RcppArmadillo decomposition disagreement

2013-05-31 Thread Colin Rundel
> For certain operations R does _not_ go to lapack but uses its own. I can > never remember if chol() was one of them -- but this suggests it. As I > mentioned in my earlier email you probably really have to follow the chol() > call all the way down (in the sources). I've followed both calls to t

Re: [Rcpp-devel] Conversion of Rcpp::Vector Rcpp::List and Rcpp::Matrix to std objects - OpenMP

2013-05-31 Thread Dirk Eddelbuettel
On 31 May 2013 at 18:00, Asis Hallab wrote: | Dear Rcpp Experts, | | in my current project I wanted to make use of OpenMP. That works. | Unfortunately it seems Rcpp Objects cannot be used inside a block | executed in parallel. I think if you're careful it may work. You definitely do not want

Re: [Rcpp-devel] Indexing a vector by a vector of indices

2013-05-31 Thread Dirk Eddelbuettel
On 31 May 2013 at 12:00, Søren Højsgaard wrote: | Dear all; | | In c++ I want to do: | x<-c(2,4,6,8,10) | i<- c(2,3,5) | x[i] | | I do: | | cat(" | #include | | using namespace Rcpp; | using namespace arma; | | // [[Rcpp::export]] | NumericVector select(NumericVector vec_, NumericVector idx_

[Rcpp-devel] Conversion of Rcpp::Vector Rcpp::List and Rcpp::Matrix to std objects - OpenMP

2013-05-31 Thread Asis Hallab
Dear Rcpp Experts, in my current project I wanted to make use of OpenMP. Unfortunately it seems Rcpp Objects cannot be used inside a block executed in parallel. Seg fault errors are the consequence, according to Dirk's reply in this thread http://lists.r-forge.r-project.org/pipermail/rcpp-devel/20

[Rcpp-devel] Indexing a vector by a vector of indices

2013-05-31 Thread Søren Højsgaard
Dear all; In c++ I want to do: x<-c(2,4,6,8,10) i<- c(2,3,5) x[i] I do: cat(" #include using namespace Rcpp; using namespace arma; // [[Rcpp::export]] NumericVector select(NumericVector vec_, NumericVector idx_){ arma::vec vv = Rcpp::as(vec_); arma::uvec ii = Rcpp::as(idx_); arma::vec

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Søren Højsgaard
Romain and Dirk: Thanks for your help and patience! Søren -Original Message- From: Dirk Eddelbuettel [mailto:[email protected]] Sent: 31. maj 2013 13:24 To: Søren Højsgaard Cc: Romain Francois; [email protected] Subject: Re: [Rcpp-devel] Turning a vector into a matrix

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Dirk Eddelbuettel
On 31 May 2013 at 10:28, Søren Højsgaard wrote: | Romain, | | Perhaps I now see the light at the end of the tunnel (hope it is not a train comming against me!): If I understand this correctly, the following | | > template | > Matrix vec2matrix2(Vector x, int nrow, int ncol) { | >return Mat

Re: [Rcpp-devel] R & RcppArmadillo decomposition disagreement

2013-05-31 Thread Dirk Eddelbuettel
On 31 May 2013 at 02:05, Colin Rundel wrote: | | > reference blas (packages libblas3 and liblapack) | > atlas (package libatlas3-base or a tuned variant) | > open-blas (package libopenblas-base) | | I had been playing around with update-alternatives to swap between the thre

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Søren Højsgaard
Romain, Perhaps I now see the light at the end of the tunnel (hope it is not a train comming against me!): If I understand this correctly, the following > template > Matrix vec2matrix2(Vector x, int nrow, int ncol) { >return Matrix(nrow, ncol, x.begin()); } should do the dispatching proper

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Romain Francois
Another way is to leverage our RCPP_RETURN_VECTOR macro, and use it with a functor instead of a function. The idea is to encapsulate the information (nrow and ncol) in the functor class: #include using namespace Rcpp ; class Vec2Matrix { public: Vec2Matrix(int nrow_, int ncol_): nrow(nrow

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Romain Francois
Ah ok, so you want to use this from R, I would suggest to Rcpp::export a dispatcher, something like this: #include using namespace Rcpp ; // the template template Matrix vec2matrix__impl(Vector x, int nrow, int ncol) { return Matrix(nrow, ncol, x.begin()); } // the exported dispatcher,used

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Søren Højsgaard
Romain, I actually already tried this in my file util.cpp but can't get it to work: #include using namespace Rcpp; // [[Rcpp::export]] NumericMatrix vec2matrix(NumericVector x, int nrow, int ncol) { return NumericMatrix(nrow, ncol, x.begin()); } // [[Rcpp::export]] template Matrix vec2ma

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Romain Francois
Hello Søren, This is easy templating: template Matrix vec2matrix(Vector x, int nrow, int ncol) { return Matrix(nrow, ncol, x.begin()); } will work for NumericVector, IntegerVector, CharacterVector, ... Romain Le 31/05/13 11:08, Søren Højsgaard a écrit : Dear all, Dirk: Thanks for t

Re: [Rcpp-devel] Turning a vector into a matrix

2013-05-31 Thread Søren Højsgaard
Dear all, Dirk: Thanks for the reply :). I shall dare to ask a "bonus question": I've played around with templating so that I get the right output type. I know (thanks to an earlier reply by Romain) how to do so using SEXP's but if I am constructing a utility function to be used on c++ object