Armadillo

Description

Armadillo is a C++ linear algebra library (matrix maths) 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 integration with LAPACK.

User instructions

Armadillo is installed as a header-only library on the NFS server. Updated versions are released quite regularly, and can be installed on request. To use, for instance, Armadillo 7.960.1 first load the module:

$ module load armadillo/7.960.1

Armadillo can then be used by including the Armadillo header in C++ source files, as shown in the example given in the Armadillo documentation:

#include <iostream>
#include <armadillo>

using namespace std;
using namespace arma;

int main(int argc, char** argv)
{
  mat A = randu<mat>(4,5);
  mat B = randu<mat>(4,5);

  cout << A*trans(B) << endl;

  return 0;
}

The header files have been set to include the full functionality of Armadillo, and so a LAPACK and BLAS implementation must be included at link time. This can be provided either by the standard LAPACK and BLAS libraries or (for better performance) by the installed Intel Math Kernel Library libraries. The above example thus could be compiled with the gcc compilers using LAPACK or Intel Math Kernel Library to provide the BLAS and LAPACK implementations:

$ g++ example.cpp -llapack -lblas -lgfortran
$ g++ example.cpp -Wl,--start-group -lmkl_gf_lp64 -lmkl_sequential -lmkl_core -Wl,--end-group -lpthread

and similarly for use with the Intel Compilers, namely:

$ icpc example.cpp -llapack -lblas -lifcore
$ icpc example.cpp -mkl

Documentation is available at http://arma.sourceforge.net/docs.html.

License

GNU Lesser General Public License (LGPL) v3 (free in terms of speech and beer).

Admin notes

The compiled library is basically a container for a LAPACK and BLAS implementation so it is more flexible to leave Armadillo as a header library. Installation amounts to downloading and extracting the tarball from http://arma.sourceforge.net and enuring ARMA_USE_LAPACK and ARMA_USE_BLAS macros are defined in include/armadillo_bits/config.hpp (default on newer versions).