Armadillo C++ linear algebra library Umair Muslim 341318 Overview - - PowerPoint PPT Presentation

armadillo
SMART_READER_LITE
LIVE PREVIEW

Armadillo C++ linear algebra library Umair Muslim 341318 Overview - - PowerPoint PPT Presentation

Armadillo C++ linear algebra library Umair Muslim 341318 Overview Introduction Libraries comparison Features History API Structural Representation Functionality overview Evaluation Conclusion 2 Armadillo by


slide-1
SLIDE 1

Armadillo C++ linear algebra library

Umair Muslim 341318

slide-2
SLIDE 2

Overview

 Introduction  Libraries comparison  Features  History  API

 Structural Representation  Functionality overview

 Evaluation  Conclusion

2 Armadillo by Umair Muslim

slide-3
SLIDE 3

Introduction

 A linear algebra library (matrix math’s) with high quality syntax  Well balanced between speed and syntax simplicity.  Similar syntax as Matlab  Why not Matlab?

 Proprietary program  Weak dynamically typed  Cross platform inconsistency

3 Armadillo by Umair Muslim

slide-4
SLIDE 4

Comparison with other Libraries

 Newmat

 Unclear license  Reimplementation instead of reuse of LAPACK  Lack high-performance

 uBLAS (Boost C++ lib)

 Less availability of basic functionality (e.g. Matrix inversion)

 IT++ (ITPP)

 Use restrictive GNU General Public License (GPL)

  • Any library under it becomes infected with GPL
  • Software must come with source code

4 Armadillo by Umair Muslim

slide-5
SLIDE 5

Features

 Simple syntax: Matlab or Octave.  Numerical type support.  Based on LAPACK library.  Fast matrix manipulation using template meta- programing.  Matrix save and load in file as Matlab  Interfacing with other libraries: via STL-iterators  Open source development  Cross-platform usability

5 Armadillo by Umair Muslim

slide-6
SLIDE 6

History

 Version 1.x

 Added some basic functions: .min(), .max(), .floor(), save/load

 Version 2.x

 Support for C++11  Exception handling: solve(), svd(), pinv(), syl() etc, std::runtime_error

 Version 3.x

 Added Constants: datum class.  Template meta-programming, matrix addition etc.

 Version 5.x

 Auto handling of 64 bit Integers

 Version 6.x

 Improved functionality while using Intel MKL, ATLAS & OpenBLAS, like norm(), accu() etc.

6 Armadillo by Umair Muslim

slide-7
SLIDE 7

Structural Representation

7 Armadillo by Umair Muslim

Base BaseCube Mat field Cube Mat Binary Op Mat Unary Op Cube Binary Op Cube Unary Op

Base Object Object classes Four Families

slide-8
SLIDE 8

Functionality overview

 Base datatypes

 Mat<type> : mat  Col<type> : colvec, vec  Row<type> : rowvec  Cube<type> : cube  Field<type> : field

 Operators: + - * / % == != <= >= < >  Functions: .transform(), .fill(), .diag(), .is_empty(), .print(), .save()/.load() . . . etc.  Generators: zeros, eye, ones, rand, randi, randu, . . . etc.

8 Armadillo by Umair Muslim

slide-9
SLIDE 9

Functionality overview

 Optimizations:

 SIMD vectorization

  • SSE2
  • Elementary expressions (matrix addition, multiplication by scaler etc.)
  • Using GCC 4.7+ with -03.
  • SSE3, SSE4 or AVX, -march=native

 Lazy evaluation

  • Template meta-programming
  • Evaluating mathematical expressions
  • trans ( X ) => Op< Mat, op_trans >
  • trans ( square ( X ) ) => Op< eOp< Mat, eop_square >, op_trans >

9

slide-10
SLIDE 10

Example 1 - PageRank

10

slide-11
SLIDE 11

Evaluation

 Speedup factor of Armadillo relative to other software  A, B, C, D and Q are NxN matrices, where N=500.  g++ example.cpp –o example –O2 –fwhole-program –l lib

11

Operation Formula Matlab Newmat IT++ Add & scalar mult. Q=0.1*A + 0.2*B + 0.3*C; 2.9 5.6 4.5 Traspose, matrix mult Q = Q + 0.1*A’ * 0.2 * B; 1.0 3.2 1.1 Submatrix copy A( 2:N, 2:N ) = B( 1:N-1, 1:N-1 ); 3.6 7.8 8.5 Direct element access for c = 1:N for r = 1:N Q(r,c) = A(N+1-r, c)+B(r, N+1-c) + C(N+1-r, N+1-c); end End 14.7 5.1 2.0

slide-12
SLIDE 12

Conclusion

 Problems with Matlab and other linear algebra libraries.  Provides balance between speed and syntax simplicity.  Template meta-programming.  Perform faster than Matlab, IT++ and Newmat libraries.

12

slide-13
SLIDE 13

THANK YOU.

Question please.

13

slide-14
SLIDE 14

Armadillo Optimization

14

7.72342 111.55206 0.55742 0.00904 1.15342 99.01259 0.22967 0.00248 20 40 60 80 100 120 Sum & Mult Trans & Mult SubMat copy Elem Access

slide-15
SLIDE 15

Armadillo Evaluation Imp

15

slide-16
SLIDE 16

IT++ Evaluation Imp

16

slide-17
SLIDE 17

Newmat Evaluation Imp

17

slide-18
SLIDE 18

File loading Implementaion

 Newmat IT++

18