Question

Is element wise multiplication (%) speed in armadillo depends whether LAPACK/BLAS is installed? Im currently running armadillo without them installed and speed is awful. Ok here is the simplest code, which takes eternity to calculate

    #include <iostream>
    #include "conio.h"


    #include "armadillo"

    using namespace arma;
    using namespace std;

    int main(int argc, char** argv)
    {


    int n=250; 
    mat X=ones(n,n);

    mat quan;



  for (int xi=1;xi<=256;xi++)
  {  
          quan = exp(X)%exp(X);
  }



  getch();


  return 0;
  }
Was it helpful?

Solution

Make sure you have optimisation flags enabled in your compiler settings (eg. in GCC or Clang, use -O2 or -O3). Armadillo makes use of template metaprogramming, and like any C++ template library, this absolutely requires optimisation enabled within the compiler to be effective. For example, this also applies to C++ template libraries such as Boost.

OTHER TIPS

Why are you calculating exp(X) twice? You're not benchmarking elementwise multiplication; you're apparently benchmarking exp(). Also, why are you not using expmat() or expmat_sym()?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top