• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

cmake_aux/H16-Jun-2016-539426

examples/H03-May-2022-247164

include/H16-Jun-2016-198,528128,350

mex_interface/H03-May-2022-1,145834

misc/H03-May-2022-451420

src/H03-May-2022-3,1862,255

tests1/H03-May-2022-2817

tests2/H03-May-2022-37,51527,017

README.mdH A D16-Jun-201618.8 KiB483333

configureH A D16-Jun-2016428 2416

README.md

1### Armadillo: C++ Library for Linear Algebra & Scientific Computing
2http://arma.sourceforge.net
3
4Copyright 2008-2021 Conrad Sanderson (http://conradsanderson.id.au)
5Copyright 2008-2016 National ICT Australia (NICTA)
6Copyright 2017-2021 Data61 / CSIRO
7
8---
9
10### Quick Links
11
12- [download latest stable release](http://arma.sourceforge.net/download.html)
13- [documentation for functions and classes](http://arma.sourceforge.net/docs.html)
14- [bug reports & questions](http://arma.sourceforge.net/faq.html)
15
16---
17
18### Contents
19
201.  [Introduction](#1-introduction)
212.  [Citation Details](#2-citation-details)
223.  [Distribution License](#3-distribution-license)
23
244.  [Prerequisites](#4-prerequisites)
25
265.  [Linux and macOS: Installation](#5-linux-and-macos-installation)
276.  [Linux and macOS: Compiling and Linking](#6-linux-and-macos-compiling-and-linking)
28
297.  [Windows: Installation](#7-windows-installation)
308.  [Windows: Compiling and Linking](#8-windows-compiling-and-linking)
31
329.  [Support for OpenBLAS and Intel MKL](#9-support-for-openblas-and-intel-mkl)
3310. [Support for ATLAS](#10-support-for-atlas)
3411. [Caveat on use of C++11 auto Keyword](#11-caveat-on-use-of-c11-auto-keyword)
3512. [Support for OpenMP](#12-support-for-openmp)
36
3713. [Documentation of Functions and Classes](#13-documentation-of-functions-and-classes)
3814. [API Stability and Versioning](#14-api-stability-and-versioning)
3915. [Bug Reports and Frequently Asked Questions](#15-bug-reports-and-frequently-asked-questions)
40
4116. [MEX Interface to Octave/Matlab](#16-mex-interface-to-octavematlab)
4217. [Related Software Using Armadillo](#17-related-software-using-armadillo)
43
44---
45
46### 1. Introduction
47
48Armadillo is a high quality C++ library for linear algebra and scientific computing,
49aiming towards a good balance between speed and ease of use.
50
51It's useful for algorithm development directly in C++,
52and/or quick conversion of research code into production environments.
53It has high-level syntax and functionality which is deliberately similar to Matlab.
54
55The library provides efficient classes for vectors, matrices and cubes,
56as well as 200+ associated functions covering essential and advanced functionality
57for data processing and manipulation of matrices.
58
59Various matrix decompositions (eigen, SVD, QR, etc) are provided through
60integration with LAPACK, or one of its high performance drop-in replacements
61(eg. OpenBLAS, Intel MKL, Apple Accelerate framework, etc).
62
63A sophisticated expression evaluator (via C++ template meta-programming)
64automatically combines several operations (at compile time) to increase speed
65and efficiency.
66
67The library can be used for machine learning, pattern recognition, computer vision,
68signal processing, bioinformatics, statistics, finance, etc.
69
70Authors:
71  * Conrad Sanderson - http://conradsanderson.id.au
72  * Ryan Curtin      - http://ratml.org
73
74---
75
76### 2: Citation Details
77
78Please cite the following papers if you use Armadillo in your research and/or software.
79Citations are useful for the continued development and maintenance of the library.
80
81  * Conrad Sanderson and Ryan Curtin.
82    Armadillo: a template-based C++ library for linear algebra.
83    Journal of Open Source Software, Vol. 1, pp. 26, 2016.
84
85  * Conrad Sanderson and Ryan Curtin.
86    A User-Friendly Hybrid Sparse Matrix Class in C++.
87    Lecture Notes in Computer Science (LNCS), Vol. 10931, pp. 422-430, 2018.
88
89---
90
91### 3: Distribution License
92
93Armadillo can be used in both open-source and proprietary (closed-source) software.
94
95Armadillo is licensed under the Apache License, Version 2.0 (the "License").
96A copy of the License is included in the "LICENSE.txt" file.
97
98Any software that incorporates or distributes Armadillo in source or binary form
99must include, in the documentation and/or other materials provided with the software,
100a readable copy of the attribution notices present in the "NOTICE.txt" file.
101See the License for details. The contents of the "NOTICE.txt" file are for
102informational purposes only and do not modify the License.
103
104---
105
106### 4: Prerequisites
107
108Armadillo 10.x requires a C++ compiler that supports at least the C++11 standard.
109Use Armadillo 9.900 if your compiler only supports the old C++98/C++03 standards.
110
111On Linux-based systems, install the GCC C++ compiler, which is available as a pre-built package.
112The package name might be `g++` or `gcc-c++` depending on your system.
113
114On macOS systems, a C++ compiler can be obtained by first installing Xcode (version 8 or later)
115and then running the following command in a terminal window:
116
117    xcode-select --install
118
119On Windows systems, the MinGW toolset or Visual Studio C++ 2019 (MSVC) can be used.
120
121The functionality of Armadillo is partly dependent on other libraries:
122OpenBLAS (or standard BLAS) and LAPACK (for dense matrices),
123as well as ARPACK and SuperLU (for sparse matrices).
124Caveat: only SuperLU versions 5.2.x can be used.
125On macOS, the Accelerate framework can be used for BLAS and LAPACK functions.
126
127Armadillo can work without the above libraries, but its functionality will be reduced.
128Basic functionality will be available (eg. matrix addition and multiplication),
129but operations such as eigen decomposition and system solvers will not be.
130Matrix multiplication may not be as fast (mainly for large matrices).
131
132---
133
134### 5: Linux and macOS: Installation
135
136Armadillo can be installed in several ways: either manually or via cmake, with or without root access.
137The cmake based installation is preferred.
138The cmake tool can be downloaded from http://www.cmake.org
139or (preferably) installed using the package manager on your system;
140on macOS systems, cmake can be installed through MacPorts or Homebrew.
141
142Before installing Armadillo, first install OpenBLAS and LAPACK, and optionally ARPACK and SuperLU.
143It is also necessary to install the corresponding development files for each library.
144For example, when installing the `libopenblas` package, also install the `libopenblas-dev` package.
145
146
147#### 5a: Installation via CMake
148
149The cmake based installer detects which relevant libraries
150are installed on your system (eg. OpenBLAS, LAPACK, SuperLU, ARPACK, etc)
151and correspondingly modifies Armadillo's configuration.
152The installer also generates the Armadillo runtime library,
153which is a wrapper for all the detected libraries,
154and provides a thread-safe random number generator.
155
156Change into the directory that was created by unpacking the armadillo archive
157(eg. `cd armadillo-10.6.1`) and then run cmake using:
158
159    cmake .
160
161**NOTE:** the full stop (.) separated from `cmake` by a space is important.
162
163On macOS, to enable the detection of OpenBLAS,
164use the additional `ALLOW_OPENBLAS_MACOS` option when running cmake:
165
166    cmake -DALLOW_OPENBLAS_MACOS=ON .
167
168Depending on your installation, OpenBLAS may masquerade as standard BLAS.
169To detect standard BLAS and LAPACK, use the `ALLOW_BLAS_LAPACK_MACOS` option:
170
171    cmake -DALLOW_BLAS_LAPACK_MACOS=ON .
172
173By default, cmake assumes that the Armadillo runtime library and the corresponding header files
174will be installed in the default system directory (eg. in the `/usr` hierarchy in Linux-based systems).
175To install the library and headers in an alternative directory,
176use the additional option `CMAKE_INSTALL_PREFIX` in this form:
177
178    cmake . -DCMAKE_INSTALL_PREFIX:PATH=alternative_directory
179
180If cmake needs to be re-run, it's a good idea to first delete the `CMakeCache.txt` file
181(not `CMakeLists.txt`).
182
183**Caveat:** if Armadillo is installed in a non-system directory,
184make sure that the C++ compiler is configured to use the `lib` and `include`
185sub-directories present within this directory.
186Note that the `lib` directory might be named differently on your system.
187On recent 64 bit Debian & Ubuntu systems it is `lib/x86_64-linux-gnu`.
188On recent 64 bit Fedora & RHEL systems it is `lib64`.
189
190If you have sudo access (ie. root/administrator/superuser privileges)
191and didn't use the `CMAKE_INSTALL_PREFIX` option, run the following command:
192
193    sudo make install
194
195If you don't have sudo access, make sure to use the `CMAKE_INSTALL_PREFIX` option
196and run the following command:
197
198    make install
199
200
201#### 5b: Manual Installation
202
203Manual installation involves simply copying the `include/armadillo` header
204**and** the associated `include/armadillo_bits` directory to a location
205such as `/usr/include/` which is searched by your C++ compiler.
206If you don't have sudo access or don't have write access to `/usr/include/`,
207use a directory within your own home directory (eg. `/home/blah/include/`).
208
209If required, modify `include/armadillo_bits/config.hpp`
210to indicate which libraries are currently available on your system.
211Comment or uncomment the following lines:
212
213    #define ARMA_USE_LAPACK
214    #define ARMA_USE_BLAS
215    #define ARMA_USE_ARPACK
216    #define ARMA_USE_SUPERLU
217
218If support for sparse matrices is not needed, ARPACK and SuperLU are not necessary.
219
220Note that the manual installation will not generate the Armadillo runtime library,
221and hence you will need to link your programs directly with OpenBLAS, LAPACK, etc.
222
223---
224
225### 6: Linux and macOS: Compiling and Linking
226
227If you have installed Armadillo via the cmake installer,
228use the following command to compile your programs:
229
230    g++ prog.cpp -o prog -O2 -std=c++11 -larmadillo
231
232If you have installed Armadillo manually, link with OpenBLAS and LAPACK
233instead of the Armadillo runtime library:
234
235    g++ prog.cpp -o prog -O2 -std=c++11 -lopenblas -llapack
236
237If you have manually installed Armadillo in a non-standard location,
238such as `/home/blah/include/`, you will need to make sure
239that your C++ compiler searches `/home/blah/include/`
240by explicitly specifying the directory as an argument/option.
241For example, using the `-I` switch in GCC and Clang:
242
243    g++ prog.cpp -o prog -O2 -std=c++11 -I /home/blah/include/ -lopenblas -llapack
244
245If you're getting linking issues (unresolved symbols),
246enable the `ARMA_DONT_USE_WRAPPER` option:
247
248    g++ prog.cpp -o prog -O2 -std=c++11 -I /home/blah/include/ -DARMA_DONT_USE_WRAPPER -lopenblas -llapack
249
250If you don't have OpenBLAS, on Linux change `-lopenblas` to `-lblas`;
251on macOS change `-lopenblas -llapack` to `-framework Accelerate`
252
253The `examples` directory contains a short example program that uses Armadillo.
254
255We recommend that compilation is done with optimisation enabled,
256in order to make best use of the extensive template meta-programming
257techniques employed in Armadillo.
258For GCC and Clang compilers use `-O2` or `-O3` to enable optimisation.
259
260For more information on compiling and linking, see the Questions page:
261http://arma.sourceforge.net/faq.html
262
263---
264
265### 7: Windows: Installation
266
267The installation is comprised of 3 steps:
268
269* Step 1:
270  Copy the entire `include` folder to a convenient location
271  and tell your compiler to use that location for header files
272  (in addition to the locations it uses already).
273  Alternatively, the `include` folder can be used directly.
274
275* Step 2:
276  If required, modify `include/armadillo_bits/config.hpp`
277  to indicate which libraries are currently available on your system:
278
279    #define ARMA_USE_LAPACK
280    #define ARMA_USE_BLAS
281    #define ARMA_USE_ARPACK
282    #define ARMA_USE_SUPERLU
283
284  If support for sparse matrices is not needed, ARPACK or SuperLU are not necessary.
285
286* Step 3:
287  Configure your compiler to link with LAPACK and BLAS
288  (and optionally ARPACK and SuperLU).
289  Note that OpenBLAS can be used as a high-performance substitute
290  for both LAPACK and BLAS.
291
292---
293
294### 8: Windows: Compiling and Linking
295
296Within the `examples` folder, the MSVC project named `example1_win64`
297can be used to compile `example1.cpp`.
298The project needs to be compiled as a 64 bit program:
299the active solution platform must be set to x64, instead of win32.
300
301The MSVC project was tested on Windows 10 (64 bit) with Visual Studio C++ 2019.
302Adaptations may be required for 32 bit systems, later versions of Windows and/or the compiler.
303For example, options such as `ARMA_BLAS_LONG` and `ARMA_BLAS_UNDERSCORE`,
304defined in `include/armadillo_bits/config.hpp`, may need to be either enabled or disabled.
305
306The folder `examples/lib_win64` contains a copy of lib and dll files
307obtained from a pre-compiled release of OpenBLAS:
308https://github.com/xianyi/OpenBLAS/releases/
309The compilation was done by a third party.  USE AT YOUR OWN RISK.
310
311**Caveat:**
312for any high performance scientific/engineering workloads,
313we strongly recommend using a Linux-based operating system:
314  * Fedora  http://fedoraproject.org/
315  * Ubuntu  http://www.ubuntu.com/
316  * CentOS  http://centos.org/
317
318---
319
320### 9: Support for OpenBLAS and Intel MKL
321
322Armadillo can use OpenBLAS or Intel Math Kernel Library (MKL) as high-speed
323replacements for BLAS and LAPACK. In essence this involves linking with the
324replacement libraries instead of BLAS and LAPACK.
325
326Minor modifications to `include/armadillo_bits/config.hpp` may be required
327to ensure Armadillo uses the same integer sizes and style of function names
328as used by the replacement libraries. Specifically, the following defines
329may need to be enabled or disabled:
330
331    ARMA_USE_WRAPPER
332    ARMA_BLAS_CAPITALS
333    ARMA_BLAS_UNDERSCORE
334    ARMA_BLAS_LONG
335    ARMA_BLAS_LONG_LONG
336
337See the documentation for more information on the above defines.
338
339On Linux-based systems, MKL might be installed in a non-standard location such as `/opt`
340which can cause problems during linking.
341Before installing Armadillo, the system should know where the MKL libraries are located.
342For example, `/opt/intel/mkl/lib/intel64/`.
343This can be achieved by setting the `LD_LIBRARY_PATH` environment variable,
344or for a more permanent solution, adding the directory locations to `/etc/ld.so.conf`.
345It may also be possible to store a text file with the locations
346in the `/etc/ld.so.conf.d` directory. For example, `/etc/ld.so.conf.d/mkl.conf`.
347If `/etc/ld.so.conf` is modified or `/etc/ld.so.conf.d/mkl.conf` is created,
348`/sbin/ldconfig` must be run afterwards.
349
350Below is an example of `/etc/ld.so.conf.d/mkl.conf`
351where Intel MKL is installed in `/opt/intel`
352
353    /opt/intel/lib/intel64
354    /opt/intel/mkl/lib/intel64
355
356If MKL is installed and it is persistently giving problems during linking,
357Support for MKL can be disabled by editing the CMakeLists.txt file,
358deleting CMakeCache.txt and re-running the cmake based installation.
359Comment out the line containing:
360
361    INCLUDE(ARMA_FindMKL)
362
363---
364
365### 10: Support for ATLAS
366
367If OpenBLAS is not available, Armadillo can use the ATLAS library for faster versions
368of a subset of LAPACK and BLAS functions.
369LAPACK should still be installed to obtain full functionality.
370The minimum recommended version of ATLAS is 3.10.
371
372---
373
374### 11: Caveat on use of C++11 auto Keyword
375
376Use of the C++11 `auto` keyword is not recommended with Armadillo objects and expressions.
377
378Armadillo has a template meta-programming framework which creates lots of short lived temporaries
379that are not properly handled by `auto`.
380
381---
382
383### 12: Support for OpenMP
384
385Armadillo can use OpenMP to automatically speed up computationally
386expensive element-wise functions such as exp(), log(), cos(), etc.
387This requires a C++11/C++14 compiler with OpenMP 3.1+ support.
388
389For GCC and Clang compilers, use the following options to enable both C++11 and OpenMP:
390`-std=c++11 -fopenmp`
391
392---
393
394### 13: Documentation of Functions and Classes
395
396The documentation of Armadillo functions and classes is available at:
397http://arma.sourceforge.net/docs.html
398
399The documentation is also in the `docs.html` file distributed with Armadillo.
400Use a web browser to view it.
401
402---
403
404### 14: API Stability and Versioning
405
406Each release of Armadillo has its public API (functions, classes, constants)
407described in the accompanying API documentation (docs.html) specific
408to that release.
409
410Each release of Armadillo has its full version specified as A.B.C,
411where A is a major version number, B is a minor version number,
412and C is a patch level (indicating bug fixes).
413
414Within a major version (eg. 7), each minor version has a public API that
415strongly strives to be backwards compatible (at the source level) with the
416public API of preceding minor versions. For example, user code written for
417version 7.100 should work with version 7.200, 7.300, 7.400, etc. However,
418as later minor versions may have more features (API extensions) than
419preceding minor versions, user code specifically written for version 7.400
420may not work with 7.300.
421
422An increase in the patch level, while the major and minor versions are retained,
423indicates modifications to the code and/or documentation which aim to fix bugs
424without altering the public API.
425
426We don't like changes to existing public API and strongly prefer not to break
427any user software. However, to allow evolution, we reserve the right to
428alter the public API in future major versions of Armadillo while remaining
429backwards compatible in as many cases as possible (eg. major version 8 may
430have slightly different public API than major version 7).
431
432**CAVEAT:** any function, class, constant or other code _not_ explicitly described
433in the public API documentation is considered as part of the underlying internal
434implementation details, and may change or be removed without notice.
435(In other words, don't use internal functionality).
436
437---
438
439### 15: Bug Reports and Frequently Asked Questions
440
441Armadillo has gone through extensive testing and has been successfully
442used in production environments. However, as with almost all software,
443it's impossible to guarantee 100% correct functionality.
444
445If you find a bug in the library or the documentation, we are interested
446in hearing about it. Please make a _small_ and _self-contained_ program
447which exposes the bug, and then send the program source and the bug description
448to the developers. The small program must have a main() function and use only
449functions/classes from Armadillo and the standard C++ library (no other libraries).
450
451The contact details are at:
452http://arma.sourceforge.net/contact.html
453
454Further information about Armadillo is on the frequently asked questions page:
455http://arma.sourceforge.net/faq.html
456
457---
458
459### 16: MEX Interface to Octave/Matlab
460
461The `mex_interface` folder contains examples of how to interface
462Octave/Matlab with C++ code that uses Armadillo matrices.
463
464---
465
466### 17: Related Software Using Armadillo
467
468* ensmallen: fast non-linear numerical optimisation library
469  http://ensmallen.org/
470
471* MLPACK: extensive library of machine learning algorithms
472  http://mlpack.org
473
474* CARMA: bidirectional interface between Python and Armadillo
475  https://github.com/RUrlus/carma
476
477* RcppArmadillo: integration of Armadillo with the R system and environment
478  http://dirk.eddelbuettel.com/code/rcpp.armadillo.html
479
480* PyArmadillo: linear algebra library for Python
481  https://pyarma.sourceforge.io
482
483