I have some code that got broken by upgrading RcppArmadillo from 0.2.1 to 0.2.3. It looks like a problem in libArmadillo, and I'm going to file a bug with its developers. But I would like to confirm the version that is used by RcppArmadillo. Based on the Changelog on CRAN, it looks like RcppArmadillo 0.2.1 used Armadillo 0.9.8, and 0.2.3 upgraded to Armadillo 0.9.10. Is that correct? (FYI, the error is caused by code 'chol(m).diag()', for some 'mat m'. I get "const class arma::Op<arma::Mat<double>, arma::op_chol>? has no member named ?diag?".) Davor
[Rcpp-devel] Armadillo version in RcppArmadillo
8 messages · Davor Cubranic, Dirk Eddelbuettel, Romain Francois
On 15 July 2010 at 10:34, Davor Cubranic wrote:
| I have some code that got broken by upgrading RcppArmadillo from 0.2.1 to 0.2.3. It looks like a problem in libArmadillo, and I'm going to file a bug with its developers. But I would like to confirm the version that is used by RcppArmadillo. Based on the Changelog on CRAN, it looks like RcppArmadillo 0.2.1 used Armadillo 0.9.8, and 0.2.3 upgraded to Armadillo 0.9.10. Is that correct? | | (FYI, the error is caused by code 'chol(m).diag()', for some 'mat m'. I get "const class arma::Op<arma::Mat<double>, arma::op_chol>? has no member named ?diag?".) Can you do a two-step and assign the result of chol(m) to an arma::Mat and then run diag() on it?
Regards, Dirk
On 2010-07-15, at 10:55 AM, Dirk Eddelbuettel wrote:
(FYI, the error is caused by code 'chol(m).diag()', for some 'mat m'. I get "const class arma::Op<arma::Mat<double>, arma::op_chol>? has no member named ?diag?".)
Can you do a two-step and assign the result of chol(m) to an arma::Mat and then run diag() on it?
Yes, using "mat(chol(m)).diag()" fixes the error. Or is that less efficient than "mat c = chol(m); c.diag()"? I'm now going to try the most recent release of Armadillo (0.9.52) to see if the error is still there. Davor
On 2010-07-15, at 11:37 AM, Davor Cubranic wrote:
I'm now going to try the most recent release of Armadillo (0.9.52) to see if the error is still there.
Yep, still there.
On 15 July 2010 at 11:44, Davor Cubranic wrote:
| On 2010-07-15, at 11:37 AM, Davor Cubranic wrote:
| | > I'm now going to try the most recent release of Armadillo (0.9.52) to see if the error is still there. | | Yep, still there. Thanks for checking. Updating to Armadillo 0.9.52 is on the TODO list, but given that CRAN is effectively closed right now and useR! is next week, we're in no hurry. I'll try to get to it, maybe even while at useR!.
Regards, Dirk
On 2010-07-15, at 11:52 AM, Dirk Eddelbuettel wrote:
Thanks for checking. Updating to Armadillo 0.9.52 is on the TODO list, but given that CRAN is effectively closed right now and useR! is next week, we're in no hurry. I'll try to get to it, maybe even while at useR!.
No worries, there isn't much you can do in this case. Enjoy the conference!
Any ideas on why using an intermediary variable ("mat c = chol(m); c.diag()") seems to be slightly slower than wrapping Cholesky's result in a 'mat' constructor ("mat(chol(m)).diag()")?
Davor
Le 16/07/10 01:59, Davor Cubranic a ?crit :
On 2010-07-15, at 11:52 AM, Dirk Eddelbuettel wrote:
Thanks for checking. Updating to Armadillo 0.9.52 is on the TODO list, but given that CRAN is effectively closed right now and useR! is next week, we're in no hurry. I'll try to get to it, maybe even while at useR!.
No worries, there isn't much you can do in this case. Enjoy the conference!
Any ideas on why using an intermediary variable ("mat c = chol(m); c.diag()") seems to be slightly slower than wrapping Cholesky's result in a 'mat' constructor ("mat(chol(m)).diag()")?
Davor
Hi Davor,
Could you provide a reproducible example. With the last version of
inline, one can use cxxfunction to compile code that uses RcppArmadillo:
fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
int dim = as<int>( x ) ;
arma::mat z = as<double>(y) * arma::eye<arma::mat>( dim, dim ) ;
return wrap( arma::accu(z) ) ;
', plugin = "RcppArmadillo" )
fx( 2L, 5 )
Also, to reply to the question "what is the version of armadillo that is
embedded in RcppArmadillo", you can use :
> RcppArmadillo:::armadillo_version()
major minor patch
0 9 10
Romain
Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/bc8jNi : Rcpp 0.8.4 |- http://bit.ly/dz0RlX : bibtex 0.2-1 `- http://bit.ly/a5CK2h : Les estivales 2010
It was really a libArmadillo issue, so I reported it on their forum: https://sourceforge.net/apps/phpbb/arma/viewtopic.php?f=1&t=37. But here it is using 'inline':
f <- cxxfunction(signature(n='int'), '
int dim = as<int>(n);
arma::mat z = arma::rand(dim, dim);
return wrap(arma::chol(z).diag());
', plugin = 'RcppArmadillo')
file4431b782.cpp: In function ?SEXPREC* file4431b782(SEXPREC*)?:
file4431b782.cpp:32: error: ?const class arma::Op<arma::Mat<double>, arma::op_chol>? has no member named ?diag?
make: *** [file4431b782.o] Error 1
One of the Armadillo devs explained that it's because the 'chol' function was moved into the delayed evaluation framework, so it should be wrapped in 'mat' before the 'diag' member function can be called. So this is not really a bug, but a feature. :-)
Thanks for the tip about RcppArmadillo:::armadillo_version(),
Davor
On 2010-07-16, at 1:28 AM, Romain Francois wrote:
Le 16/07/10 01:59, Davor Cubranic a ?crit :
On 2010-07-15, at 11:52 AM, Dirk Eddelbuettel wrote:
Thanks for checking. Updating to Armadillo 0.9.52 is on the TODO list, but given that CRAN is effectively closed right now and useR! is next week, we're in no hurry. I'll try to get to it, maybe even while at useR!.
No worries, there isn't much you can do in this case. Enjoy the conference!
Any ideas on why using an intermediary variable ("mat c = chol(m); c.diag()") seems to be slightly slower than wrapping Cholesky's result in a 'mat' constructor ("mat(chol(m)).diag()")?
Davor
Hi Davor, Could you provide a reproducible example. With the last version of inline, one can use cxxfunction to compile code that uses RcppArmadillo: fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , ' int dim = as<int>( x ) ; arma::mat z = as<double>(y) * arma::eye<arma::mat>( dim, dim ) ; return wrap( arma::accu(z) ) ; ', plugin = "RcppArmadillo" ) fx( 2L, 5 ) Also, to reply to the question "what is the version of armadillo that is embedded in RcppArmadillo", you can use :
RcppArmadillo:::armadillo_version()
major minor patch 0 9 10 Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/bc8jNi : Rcpp 0.8.4 |- http://bit.ly/dz0RlX : bibtex 0.2-1 `- http://bit.ly/a5CK2h : Les estivales 2010