Site icon R-bloggers

RcppArmadillo 0.2.1

[This article was first published on Romain Francois, Professional R Enthusiast, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Armadillo

Armadillo is a C++ linear algebra library aiming towards a good balance between speed and ease of use. Integer, floating point and complex numbers are supported, as well as a subset of trigonometric and statistics functions. Various matrix decompositions are provided through optional integration with LAPACK and ATLAS libraries.

A delayed evaluation approach is employed (during compile time) to combine several operations into one and reduce (or eliminate) the need for temporaries. This is accomplished through recursive templates and template meta-programming.

This library is useful if C++ has been decided as the language of choice (due to speed and/or integration capabilities), rather than another language like Matlab or Octave. It is distributed under a license that is useful in both open-source and commercial contexts.

Armadillo is primarily developed by Conrad Sanderson at NICTA (Australia), with contributions from around the world.

RcppArmadillo

RcppArmadillo is an R package that facilitates using Armadillo classes in R packages through Rcpp. It achieves the integration by extending Rcpp’s data interchange concepts to Armadillo classes.

Example

Here is a simple implementation of a fast linear regression (provided by RcppArmadillo via the fastLm() function):

Note however that you may not want to compute a linear regression fit this way in order to protect from numerical inaccuracies on rank-deficient problems. The help page for fastLm() provides an example.

Using RcppArmadillo in other packages

RcppArmadillo is designed so that its classes can be used from other packages.

Using RcppArmadillo requires:

RcppArmadillo contains a function RcppArmadillo.package.skeleton, modelled after package.skeleton from the utils package in base R, that creates a skeleton of a package using RcppArmadillo, including example code.

Quality Assurance

RcppArmadillo uses the RUnit package by Matthias Burger et al to provide unit testing. RcppArmadillo currently has 19 unit tests (called from 8 unit test functions).

Source code for unit test functions are stored in the unitTests directory of the installed package and the results are collected in the RcppArmadillo-unitTests vignette.

We run unit tests before sending the package to CRAN on as many systems as possible, including Mac OSX (Snow Leopard), Debian, Ubuntu, Fedora 12 (64bit), Win 32 and Win64.

Unit tests can also be run from the installed package by executing

RcppArmadillo:::test()

where an output directory can be provided as an optional first argument.

Links

Support

Questions about RcppArmadillo should be directed to the Rcpp-devel mailing list at https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Questions about Armadillo itself should be directed to its forum http://sourceforge.net/apps/phpbb/arma/

 -- Romain Francois, Montpellier, France
    Dirk Eddelbuettel, Chicago, IL, USA
    Doug Bates, Madison, WI, USA

    May 2010

To leave a comment for the author, please follow the link and comment on their blog: Romain Francois, Professional R Enthusiast.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.