C++ linear algebra library

API Docs

  • Armadillo is a high quality C++ linear algebra library, aiming towards a good balance between speed and ease of use
  • Useful for algorithm development directly in C++, or quick conversion of research code into production environments; the syntax (API) is deliberately similar to Matlab
  • Can be used for machine learning, pattern recognition, signal processing, bioinformatics, statistics, econometrics, etc
  • Provides efficient classes for vectors, matrices and cubes, as well as 150+ associated functions (eg. contiguous and non-contiguous submatrix views)
  • Various matrix decompositions are provided through integration with LAPACK, or one of its high performance drop-in replacements (eg. multi-threaded Intel MKL, or AMD ACML, or OpenBLAS)
  • An automatic expression evaluator (via template meta-programming) combines several operations to increase efficiency
  • Integer, floating point and complex numbers are supported
  • The library is open-source software, distributed under a license useful in both open-source and proprietary contexts
  • Primarily developed at Data61 (Australia) by Conrad Sanderson, with contributions from around the world
  • download latest version  |  browse documentation  |  news



Version 6.100   (Midnight Blue)


NICTA has merged with CSIRO's Digital Productivity business unit, forming Data61


Version 5.600   (Molotov Cocktail Deluxe)


Version 5.500   (Molotov Cocktail)
  • expanded object constructors and generators to handle size() based specification of dimensions
  • faster handling of submatrix rows
  • faster clamp()
  • fixes for handling sparse matrices


Version 5.400   (Plutocracy Incorporated Deluxe)
  • added find_unique() for finding indices of unique values
  • added diff() for calculating differences between consecutive elements
  • added cumprod() for calculating cumulative product
  • added null() for finding the orthonormal basis of null space
  • expanded interp1() to handle repeated locations
  • expanded unique() to handle complex numbers
  • faster flipud()
  • faster row-wise cumsum()
  • fix for k-means clustering in gmm_diag class


Version 5.300   (Plutocracy Incorporated)


Version 5.200   (Boston Tea Smuggler)
  • added orth() for finding the orthonormal basis of the range space of a matrix
  • expanded element initialisation to handle nested initialiser lists (C++11)
  • workarounds for bugs in GCC, Intel and MSVC C++ compilers


Version 5.100   (Ankle Biter Deluxe)


Version 5.000   (Ankle Biter)
  • added spsolve() for solving sparse systems of linear equations
  • added svds() for singular value decomposition of sparse matrices
  • added nonzeros() for extracting non-zero values from matrices
  • added handling of diagonal views by sparse matrices
  • expanded repmat() to handle sparse matrices
  • expanded join_rows() and join_cols() to handle sparse matrices
  • sort_index() and stable_sort_index() have been placed in the delayed operations framework for increased efficiency
  • use of 64 bit integers is automatically enabled when using a C++11 compiler
  • workaround for a bug in recent releases of Apple Xcode
  • workaround for a bug in LAPACK 3.5


Version 4.650   (Intravenous Caffeine Injector)
  • added randg() for generating random values from gamma distributions (C++11 only)
  • added .head_rows() and .tail_rows() to submatrix views
  • added .head_cols() and .tail_cols() to submatrix views
  • expanded eigs_sym() to optionally calculate eigenvalues with smallest/largest algebraic values
  • fixes for handling of sparse matrices


Version 4.600   (Off The Reservation)
  • added .head() and .tail() to submatrix views
  • faster matrix transposes within compound expressions
  • faster accu() and norm() when compiling with -O3 -ffast-math -march=native (gcc and clang)
  • workaround for a bug in GCC 4.4


Version 4.550   (Singapore Sling Deluxe)
  • added matrix exponential function: expmat()
  • faster .log_p() and .avg_log_p() functions in the gmm_diag class when compiling with OpenMP enabled
  • faster handling of in-place addition/subtraction of expressions with an outer product


Version 4.500   (Singapore Sling)
  • faster handling of complex vectors by norm()
  • expanded chol() to optionally specify output matrix as upper or lower triangular
  • better handling of non-finite values when saving matrices as text files


Version 4.450   (Spring Hill Fort)
  • faster handling of matrix transposes within compound expressions
  • expanded symmatu()/symmatl() to optionally disable taking the complex conjugate of elements
  • expanded sort_index() to handle complex vectors
  • expanded the gmm_diag class with functions to generate random samples
  • disabled automatic detection of HDF5 to prevent compilation problems


MLPACK 1.0.10 released; MLPACK is a library for machine learning and pattern recognition, built on top of Armadillo


Version 4.400   (Winter Shark Alley)
  • faster handling of subvectors by dot()
  • faster handling of aliasing by submatrix views
  • expanded batch insertion constructors for sparse matrices to add values at repeated locations
  • added clamp() for clamping values to be between lower and upper limits
  • added gmm_diag class for statistical modelling using Gaussian Mixture Models (GMM);
    includes multi-threaded implementation of k-means clustering and Expectation Maximisation (EM) algorithms


Armadillo is used extensively in a self-driving car project at University of Ulm


Version 4.320   (Daintree Tea Raider)
  • expanded eigs_sym() and eigs_gen() to use an optional tolerance parameter
  • expanded eig_sym() to automatically fall back to standard decomposition method if divide-and-conquer fails
  • automatic installer enables use of C++11 random number generator when using gcc 4.8.3+ in C++11 mode


Scyllarus is a toolbox for processing hyper-spectral data, using Armadillo as the math library


Version 4.300   (Medieval Cornea Scraper)


Recent papers developed with the aid of Armadillo:


Version 4.200   (Flintlock Swoop)
  • faster transpose of sparse matrices
  • more efficient handling of aliasing during matrix multiplication
  • faster inverse of matrices marked as diagonal


Version 4.100   (Dirt Cruiser)
  • added normalise() for normalising vectors to unit p-norm
  • extended the field class to handle 3D layout
  • extended eigs_sym() and eigs_gen() to obtain eigenvalues of various forms (eg. largest or smallest magnitude)
  • automatic SIMD vectorisation of elementary expressions (eg. matrix addition) when using Clang 3.4+ with -O3 optimisation
  • faster handling of sparse submatrix views
  • workaround for a bug in LAPACK 3.4


Version 4.000   (Feral Steamroller)
  • added eigen decompositions of sparse matrices: eigs_sym() and eigs_gen()
  • added eigen decomposition for pair of matrices: eig_pair()
  • added simpler forms of eig_gen()
  • added condition number of matrices: cond()
  • expanded find() to handle cubes
  • expanded subcube views to access elements specified in a vector
  • template argument for running_stat_vec expanded to accept vector types
  • more robust fast inverse of 4x4 matrices
  • faster divide-and-conquer decompositions are now used by default for eig_sym(), pinv(), princomp(), rank(), svd(), svd_econ()
  • the form inv(sympd(X)) no longer assumes that X is positive definite; use inv_sympd() instead
  • added MEX connector for interfacing Octave/Matlab with Armadillo matrices (contributed by George Yammine)


Version 3.930   (Dragon's Back)
  • added divide-and-conquer variant of svd_econ(), for faster SVD
  • added divide-and-conquer variant of pinv(), for faster pseudo-inverse
  • added element-wise variants of min() and max()
  • added size() based specifications of submatrix view sizes
  • added randi() for generating matrices with random integer values
  • added inplace_trans() for memory efficient in-place transposes (contributed by Alexandre Drouin)
  • added more intuitive specification of sort direction in sort() and sort_index()
  • added more intuitive specification of method in det(), .i(), inv() and solve()
  • added more precise timer for the wall_clock class when using C++11


Version 3.920   (Agencia Nacional Stasi)
  • faster .zeros()
  • faster round(), exp2() and log2() when using C++11
  • added signum function: sign()
  • added move constructors when using C++11
  • added 2D fast Fourier transform: fft2()
  • added .tube() for easier extraction of vectors and subcubes from cubes
  • added specification of a fill type during construction of Mat, Col, Row and Cube classes, eg. mat X(4, 5, fill::zeros)


Version 3.910   (Pyrenees)
  • faster multiplication of a matrix with a transpose of itself, ie. X*X.t() and X.t()*X
  • added vectorise() for reshaping matrices into vectors
  • added all() and any() for indicating presence of elements satisfying a relational condition


The Tech Street Journal has an article on Armadillo


Version 3.900   (Bavarian Sunflower)
  • added automatic SSE2 vectorisation of elementary expressions (eg. matrix addition) when using GCC 4.7+ with -O3 optimisation
  • added support for saving & loading of cubes in HDF5 format, contributed by Szabolcs Horvat
  • faster median(), contributed by Ruslan Shestopalyuk
  • faster handling of compound expressions with transposes of submatrix rows
  • faster handling of compound expressions with transposes of complex vectors


Version 3.820   (Mt Cootha)
  • faster as_scalar() for compound expressions
  • faster transpose of small vectors
  • faster matrix-vector product for small vectors
  • faster multiplication of small fixed size matrices


Version 3.810   (Newell Highway)
  • added fast Fourier transform: fft()
  • added handling of .imbue() and .transform() by submatrices and subcubes
  • added batch insertion constructors for sparse matrices
  • minor fix for multiplication of complex sparse matrices
  • better detection of recent Intel MKL versions during installation


Version 3.800   (Miami Beach)
  • Armadillo is now licensed using the Mozilla Public License 2.0
  • added .imbue() for filling a matrix/cube with values provided by a functor or lambda expression
  • added .swap() for swapping contents with another matrix
  • added .transform() for transforming a matrix/cube using a functor or lambda expression
  • added round() for rounding matrix elements towards nearest integer
  • faster find()
  • fixes for handling non-square matrices by qr() and qr_econ()
  • minor fixes for handling empty matrices
  • reduction of pedantic compiler warnings


Recent papers developed with the aid of Armadillo:


Version 3.6   (Piazza del Duomo)
  • faster handling of compound expressions with submatrices and subcubes
  • added support for loading matrices as text files with NaN and Inf elements
  • added stable_sort_index(), which preserves the relative order of elements with equivalent values
  • added handling of sparse matrices by mean(), var(), norm(), abs(), square(), sqrt()
  • added saving and loading of sparse matrices in arma_binary format


Thomas Natschlaeger has provided bindings/interface to Python


Version 3.4   (Ku De Ta)


Version 3.2   (Creamfields)


Version 3.0   (Antarctic Chilli Ranch)

↓ earlier news ↓


Version 2.4   (Loco Lounge Lizard)
  • added shorter forms of transposes: .t() and .st()
  • added optional use of 64 bit indices, allowing matrices to have more than 4 billion elements
  • added experimental support for C++11 initialiser lists
  • faster pinv()
  • faster inplace transpose
  • faster handling of expressions with diagonal views
  • fixes for handling expressions with aliasing and submatrices
  • fixes for linking on Ubuntu and Debian systems
  • fixes for inconsistencies in interactions between matrices and cubes
  • refactored code to eliminate warnings when using the Clang C++ compiler
  • .print_trans() and .raw_print_trans() are deprecated


Version 2.2   (Blue Skies Debauchery)


Version 2.0   (Carnivorous Sugar Glider)


Version 1.2.0   (Unscrupulous Carbon Emitter)
  • Added ability to use Blas & Lapack libraries with capitalised function names
  • Reduction of pedantic compiler warnings


Version 1.1.92   (Jurassic Barbecue)
  • Bugfix in cor()
  • Automatic installation now requires CMake ≥ 2.6


Version 1.1.90   (Inside Job)


Version 1.1.8   (Kangaroo Steak)


Version 1.1.6   (Baby Carpet Shark)


Version 1.1.4   (Manta Lodge)
  • Faster sort()
  • Updated installation to detect recent versions of Intel's MKL
  • Added interpretation of arbitrary "flat" subcubes as matrices


Version 1.1.2   (Flood Kayak)
  • Faster prod()
  • Faster solve() for compound expressions
  • Fix for compilation using GCC's C++0x mode
  • Fix for matrix handling by subcubes


Version 1.1.0   (Climate Vandal)


Version 1.0.0   (Antipodean Antileech)
  • After 2½ years of collaborative development, we are proud to release the 1.0 milestone version
  • Many thanks are extended to all contributors and bug reporters


Version 0.9.92   (Wall Street Gangster)
  • Fixes for compilation issues under the Intel C++ compiler
  • Added matrix norms


Version 0.9.90   (Water Dragon)
  • Added unsafe_col()
  • Speedups and bugfixes in lu()
  • Minimisation of pedantic compiler warnings


Overview Tech Report


Version 0.9.80   (Chihuahua Muncher)


Version 0.9.70   (Subtropical Winter Safari)


Version 0.9.60   (Killer Bush Turkey)
  • More flexible reshape(), allowing significantly different matrix sizes
  • Added matrix initialisation via the << operator
  • Fixes for compilation issues under Mac OS X with GCC 4.2/4.0 hybrid


Version 0.9.52   (Monkey Wrench)
  • Bugfixes for saving complex cubes
  • Workarounds to remove warnings under certain dodgy compilers


Version 0.9.50   (Flying Spaghetti Monster)


Version 0.9.10   (Chilli Espresso)
  • Speedups for find() and relational operators
  • Speedups for expressions involving mixed matrix types
  • More consistent success indication by decomposition functions


Version 0.9.8   (Dog's Breakfast)
  • Added handling of interactions between complex scalars and non-complex matrices
  • Minor bugfixes for compilation issues under certain compilers


Version 0.9.6   (Chimerican Climate Cabal)


Version 0.9.4   (Cat Herder)
  • Added cross()
  • Bugfixes for inplace addition of particular vector multiplication expressions


NICTA at CeBIT in Hannover
Armadillo is used in NICTA's face-based identity inference product demonstrators (part of the Advanced Surveillance project). See this page for more info on NICTA's presence at CeBIT.


Version 0.9.2   (Cuban Cigar)
  • Minor speedups
  • Added princomp_cov()
  • Bugfixes in complex-number versions of several functions


Version 0.9.0   (Retoxed Feral)
  • Extended and overhauled expression evaluation framework, for more efficient handling of compound expressions
  • There is a small but important API change -- see the docs for details
  • Added a conversion table between Matlab/Octave and Armadillo syntax
  • Added saving/loading of matrices using streams
  • Added log_det(), princomp(), fliplr(), flipud()
  • More accurate var() and stddev()


Version 0.8.2   (Colombian Coffee)
  • Added as_scalar(), for forward compatibility with 0.9.x
  • Miscellaneous bugfixes


Version 0.8.0   (Restless Critter)
  • Added pinv(), rank(), kron(), prod(), eps(), shuffle()
  • Added ‘running_stat_vec’ class, for on-the-fly statistics of vectors
  • Improvements and bugfixes in handling of submatrix views
  • Speedups for some compound expressions
  • Initial support for dodgy compilers


Version 0.7.2   (Tequila Sunrise)
  • Added covariance and correlation functions
  • Added simpler form of lu()
  • Faster repmat() and reshape()
  • Better detection of external libraries during installation


Version 0.7.0   (Unshackled Mongrel)
  • Added the Cube class (aka "3D matrix" or a set of matrices with contiguous memory)
  • Added creation of Mat instances using auxiliary memory
  • Added repmat()
  • Bugfixes for det() and lu()


Version 0.6.12   (Ye Greene Beaste)
  • Added raw_print() and a collection of physical constants
  • Code cleanup for better conformance to the C++ standard
  • Miscellaneous documentation and installation improvements


Version 0.6.11
  • Bug fix for solve() when using complex numbers
  • More elaborate class destructors for better debugging of user code
  • Miscellaneous documentation and installation improvements


Version 0.6.10
  • Added eigen decomposition of generic (non-symmetric) matrices
  • Function eig() renamed to eig_sym()


Version 0.6.8
  • Better installation on MacOS X
  • Colour PPM images can now be loaded as fields of matrices


Version 0.6.6
  • Better installation on 64 bit systems, especially when using CMake 2.6
  • Fields of strings can be now loaded & saved as plain text files
  • Bug fix for template detection of combined multiply and addition operations


Version 0.6.4
  • Added running_stat class for on-the-fly statistics
  • Renamed main classes for better code readability
  • Performance tweaks, which can result in speedups of 30% for small matrices


Version 0.6.2
Fixes for interactions between matrices with different element types


Version 0.6.0
Added functionality:
  • solve(), for solving systems of linear equations
  • svd(), singular value decomposition
  • expressions can now have mixed matrix types
  • complex number versions of statistics functions
  • reworked operators, providing more flexibility

Bug fixes:
  • sign of scalar produced by det()
  • handling of single row and column submats by statistics functions


Version 0.5.2
Added functionality:
  • subfields
  • sort_index()

Bug fixes:
  • pow() applied to integer matrices (gcc < 4.3)
  • multiplication of submats with a scalar
  • missing division operators


Version 0.5.0
Added functionality:
  • Cholesky and QR decompositions
  • element-wise division
  • comparison operators
  • more elegant restriction of template parameters

Bug fixes:
  • handling of diagonal matrices created from vectors
  • compilation of examples under MacOS X

Other changes:
  • faster matrix inverse
  • license change to LGPL v3+
  • updated and re-arranged documentation
  • easier installation when using the .tar.gz package


Version 0.4.0
Bug fixes and added functionality:
  • easier configuration and installation
  • statistics functions
  • more functions for handling complex numbers


Version 0.3.0
Added functionality:
  • handling of complex numbers as well as other types
  • added trigonometric functions


Version 0.2.1
Fixes for several minor bugs.


Version 0.2.0
More functionality, bug fixes and improved user documentation.


Version 0.1.0
Initial proof-of-concept release.

Get Armadillo C++ matrix library at Fast, secure and Free Open Source software downloads