Armadillo C++ linear algebra library
Armadillo home page: http://arma.sourceforge.net/
armadillo-3.910.0 has been installed on the GPC. There is a module as well:
armadillo/3.910.0
You will, of course, need a compiler. We recommend you use the latest version of the Intel compiler we have available, which at present is
intel/13.1.1
Here is a Makefile that works on the GPC, with the intel and armadillo modules loaded,
and which compiles a program called "armadillotest.cxx":
<source lang="bash">
- For GPC:
- module load intel/13.1.1
- module load armadillo/3.910.0
- #
CXX=icpc
EXTRA_LIB_FLAGS = -L$(MKLROOT)/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm
LIB_FLAGS = $(EXTRA_LIB_FLAGS)
OPT = -O3
- ## As the Armadillo library uses recursive templates,
- ## compilation times depend on the level of optimisation:
- ##
- ## -O0: quick compilation, but the resulting program will be slow
- ## -O1: good trade-off between compilation time and execution speed
- ## -O2: produces programs which have almost all possible speedups,
- ## but compilation takes longer
CXXFLAGS = $(OPT) -I$(SCINET_ARMADILLO_INC)
all: armadillotest
armadillotest: armadillotest.cxx $(CXX) $(CXXFLAGS) $(EXTRAFLAGS) -o $@ $< $(LIB_FLAGS)
.PHONY: clean
clean:
</source>
This is the armadillotest.cxx code:
<source lang="cpp">
- include "armadillo"
- include <vector>
- include <ctime>
using namespace arma; using namespace std;
int main() { srand((unsigned)time(0)); mat X = randu<mat>(8, 9);
X.print("source");
mat U; vec s; mat V;
svd(U,s,V,X); // use standard algorithm by default
U.print("U"); s.print("s"); V.print("V"); return 0; }
</source>