Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a good C++ library for matrix operations

I need to do multiplication on matrices. I'm looking for a library that can do it fast. I'm using the Visual C++ 2008 compiler and I have a core i7 860 so if the library is optimized for my configuration it's perfect.

like image 989
user558209 Avatar asked Dec 30 '10 11:12

user558209


2 Answers

BLAS is a de facto Fortran standard for all basic linear algebra operations (essentially multiplications of matrices and vectors). There are numerous implementations available. For instance:

  • ATLAS is free and supposedly self-optimizing. You need to compile it yourself though.
  • Goto BLAS is maintained by Kazushige Goto at TACC. He is very good at getting the last performance bit out of modern processors. It is only for academic use though.
  • Intel MKL provides optimised BLAS for Intel processors. It is not free, even for academic use.

Then, you may want to use a C++ wrapper, for instance boost::ublas.

If you program on distributed systems, there are PBLAS and ScaLAPACK which enable the use of message passing for distributed linear algebra operations. On a multicore machine, usually implementations of BLAS (at least Intel MKL) use threads for large enough matrices.

If you want more advanced linear algebra routines (eigenvalues, linear systems, least square, ...), then there is the other de facto Fortran standard LAPACK. To my knowledge, there is nothing to integrate it elegantly with C++ other than calling the bare Fortran routines. You have to write some wrappers to hide the Fortran calls and provide a sound type-checking implementation.

like image 139
Alexandre C. Avatar answered Sep 28 '22 06:09

Alexandre C.


FWIW, Eigen 3 uses threads (OpenMP) for matrix products (in reply to above statement about Eigen not using threads).

like image 21
Benoit Jacob Avatar answered Sep 28 '22 08:09

Benoit Jacob