R and Armadillo Integration

The package brings the power of Armadillo to R.

package, programming , interface

Armadillo is a C++ linear algebra library, aiming towards a good balance between speed and ease of use. It provides efficient classes for vectors, matrices and cubes, as well as many functions which operate on the classes (eg. contiguous and non-contiguous submatrix views). Various matrix decompositions are provided, and an automatic expression evaluator (via template meta-programming) combines several operations to increase efficiency. The syntax (API) is deliberately similar to Matlab. It is useful for algorithm development directly in C++, or quick conversion of research code into production environments. Armadillo has been primarily developed at NICTA (Australia) by Conrad Sanderson, with contributions from around the world.


RcppArmadillo acts as a bridge between Rcpp and Armadillo, allowing the programmer to write code using Armadillo classes that integrate seemlessly with R via Rcpp.

Using RcppArmadillo

The simplest way to get started is to create a skeleton of a package using RcppArmadillo. This can be done conveniently by the RcppArmadillo.package.skeleton function. The important steps are

  • Include the RcppArmadillo.h header file, which also includes armadillo.h.
  • Import Rcpp, and LinkingTo Rcpp and RcppArmadillo by adding these lines to the DESCRIPTION file:
          Imports: Rcpp (>= 0.11.0)
          LinkingTo: Rcpp, RcppArmadillo
  • Link against the BLAS and LAPACK libraries, by adding this line in the Makevars and Makevars.win files:


Please use the Rcpp-devel mailing list on r-forge for questions about RcppArmadillo (subscribe first). http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Armadillo project: http://arma.sourceforge.net/ Conrad Sanderson, Armadillo: An Open Source C++ Linear Algebra Library for Fast Prototyping and Computationally Intensive Experiments. Technical Report, NICTA, 2010. Dirk Eddelbuettel and Conrad Sanderson, "RcppArmadillo: Accelerating R with high-performance C++ linear algebra", Computational Statistics and Data Analysis, 2014, 71, March, pages 1054-1063, http://dx.doi.org/10.1016/j.csda.2013.02.005. )

  • RcppArmadillo-package
  • RcppArmadillo
  • RcppArmadilloExample
Documentation reproduced from package RcppArmadillo, version, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.