Dirk Eddelbuettel: RcppArmadillo 0.1.0
Besides the new RcppExamples,
another new package RcppArmadillo got spun out of
Rcpp
with the
recent release 0.7.8 of Rcpp.
Romain and I already had
an example of a simple but fast linear model fit using the (very clever)
Armadillo C++ library by Conrad Sanderson.
In fact, I had used this as a motivational example of why
Rcpp
rocks in a
recent talk to the ACM chapter at U of Chicago which,
thanks to David Smith at REvo,
got some further exposure.
Now this example is more refined as further glue got added. Given
that both Armadillo and
Rcpp make use of
C++ templates, the actual amount of code in RcppArmadillo is not that large:
just over 200 lines in a header file, and a little less for some testing accessor
and example functions in a source file. And this makes for some really nice
example code: the 'fast regression' example becomes this (where I simply
removed two blocks with conditional on the Armadillo version):
#include <RcppArmadillo.h> extern "C" SEXP fastLm(SEXP ys, SEXP Xs) Rcpp::NumericVector yr(ys); // creates Rcpp vector from SEXP Rcpp::NumericMatrix Xr(Xs); // creates Rcpp matrix from SEXP int n = Xr.nrow(), k = Xr.ncol(); arma::mat X(Xr.begin(), n, k, false); // reuses memory and avoids extra copy arma::colvec y(yr.begin(), yr.size(), false); arma::colvec coef = solve(X, y); // fit model y ~ X arma::colvec resid = y - X*coef; // residuals double sig2 = arma::as_scalar( trans(resid)*resid/(n-k) ); // std.error of estimate arma::colvec stderrest = sqrt( sig2 * diagvec( arma::inv(arma::trans(X)*X)) ); Rcpp::Pairlist res(Rcpp::Named( "coefficients", coef), Rcpp::Named( "stderr", stderrest)); return res;No extra copies! Armadillo instantiates directly from the underlying R objects for the vector and matrix, solves the regression equations, computes the standard error of the estimates and returns the two vectors. Leaving us to write about eleven lines of code. Moreover, as Armadillo is well designed and uses template meta-programming to avoid extra copies (see these lecture notes for details), it is about as efficient as it can be (and will use Atlas or other BLAS where available). And, this is just one example. Rcpp should be suitable for other C++ libraries, and provides an easy to use seamless interface between C++ and R. However, we should note that (at about the last minute) we found out about some unit test failures in OS X as well as some issues in a Debian chroot -- cran2deb ran into some build issues on i386 and amd64 in the testing chroot even this 'it all works' swimmingly on our Debian, Ubuntu and Fedora build environments. A follow-up with fixes for either Rcpp and/or RcppArmadillo appears likely.
Update: The build issues seems to be with 64-bit systems and everything appears cool in 32-bit.
I m happy to announce that after the filing of an
Today I took a break before my usual lunchtime to go to the movies
I remember reading it without really understanding its nonsensical violence at first. And, as I said, Fontanarrosa is a very loved cartoonist - In Mexico I think we were much more acquinted with Boogie than with
I'm looking for a way to do free hosting. But I mean free as in freedom, not free as in beer. Let me explain.
By the time this blog entry goes live I'll be running upon my new machine. The migration process was mostly straightfoward and followed my plan:
Just a kind thank you note to the gThumb authors for completely breaking my workflow by re-inventing the paradigm used to save imported pictures. Until now, all my pictures landed in a predictable location, using a predictable filename pattern that was easily searchable. Not anymore. Now, files land into my home directory, according to some recursive folder pattern that further complicates searching for files and requires a few more clicks to accomplish. Dammit! Couldn't you at least make this configurable, so that those of us who prefer to retain the old paradigm can?!
Note: re-inventing an application's paradigms is always a very bad idea. If you're a software developer who is reading this, please keep it in mind and go scratch your itch to change the world somewhere else. Thank you.
Post Scriptum
Many thanks to Damon Lynch for pointing me to his own professional picture importer called
I am still being plagued by the burdens of real life so most development is taking place after the kids ("It should have mermaids! And Spiderman!") have gone to sleep. By the time I finished up yesterday, I was too tired to blog so this is is a combined report on the last two days.
I decided not to bother with Javascript as I want to try a different project for the plasmoid competition. So I'm back to C++ and ncurses. At this point my '@' can move across the dungeon which at the moment a very simplistic 10 10 grid where every space is a 'room'. Rooms are populated with monsters, treasure and items though at the moment only the monsters can do anything and by anything I mean fighting. My combat system is based on 
I just updated to the latest beta of 

For the first time since I got involved in Ruby maintenance in Debian & Ubuntu, we are seriously at risk of not being able to release working Ruby interpreters in both Ubuntu Lucid and Debian Squeeze, because of two pretty serious issues.
Ruby 1.8(.7.249) randomly hangs with eglibc 2.11
That issue was found by Google folks, because Puppet was hanging. After a lot of (quite heated) discussion, it was found that the problem is caused by something in eglibc 2.11: the problem can t be reproduced in a Debian unstable chroot (with eglibc 2.10), but is reproducible if you just upgrade glibc to 2.11 (which is in Debian experimental).
It is not clear at all whether it is a glibc bug, or a ruby bug: Ruby has shown in the past that it was making some assumptions on the behaviour of pthread. It is possible that a valid change in glibc conflicts with an assumption made by Ruby.
Still, I wonder why Ubuntu chose to release with eglibc 2.11, while Debian still only has 2.10 in unstable, and Ubuntu doesn t really have a lot of people with deep glibc knowledge. (Update: I assumed we would release squeeze with 2.10, but the eglibc maintainers plan to release 2.11 in squeeze.)
That issue is tracked in Launchpad as