I'm currently trying to convert matlab code to C++ using armadillo. I converted some matlab code by following the aramdillo documentation to C++. However the performance is disappointing compared to matlab.
In Matlab it takes about 0.1 sec to inverse a Matrix A of size (625x625) compared to over 3 seconds in C++.
In C++ I have tried both
solve()
as well as
inv()
I'm aware of the fact that inv produces less accurate results, thus I do not prefer to use it. Besides I really need the inverse of matrix A, as I use the diagonal elements later in the algorithm.
The code that's producing these results:
Matlab
x=A\b
invA = A\eye(size(A))
C++
arma::mat x = solve(A,b)
arma::mat invA = solve(A,eye(625,625))
The versions I'm using:
C++:
Visual Studio 2013
Armadillo 8.300.1
- Intel MKL 2018.1.156
Matlab:
matlab 2016b
version -blas
Intel(R) Math Kernel Library Version 11.3.1 Product Build 20151021 for Intel(R) 64 architecture applications, CNR branch AVX2
- version -lapack
Intel(R) Math Kernel Library Version 11.3.1 Product Build 20151021 for Intel(R) 64 architecture applications, CNR branch AVX2 Linear Algebra PACKage Version 3.5.0
Does anyone have an idea how to overcome this lack of speed in C++ using armadillo?