[Rcpp-devel] Armadillo version in RcppArmadillo
Davor Cubranic
cubranic at stat.ubc.ca
Fri Jul 16 20:49:36 CEST 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
More information about the Rcpp-devel
mailing list