Search code examples
c++arraysperformanceeigen

Are 1d arrays faster than Eigen dynamic vectors?


I'm using large matrices (100x100 to 3000x3000) to do some claculations (a lot of sums and up to 120 matrix-vector multiplications), I'm using the Eigen Library for my vectors and matrices.

I was wondering how I could speed up my program. Should I keep using Eigen, use 1d arrays, use std::vector, or use some other library ?


Solution

  • Assuming you don't want to migrate to a GPU and if you want to trust Eigen's benchkmark page, Eigen is pretty fast. You specifically mentioned matrix vector products for which in the range you specified, Eigen is on top. Make sure that OpenMP is enabled as Eigen will take advantage of multiple cores. Likewise with vectorization.