// comparison of matrix products // armadillo vs. plain loop // Optimize as well as you can, e.g. // g++ -O3 -funroll-all-loops arma_matrix_speed.cpp -L/usr/lib64/atlas -lcblas #include #include #include using namespace std; using namespace arma; int main() { clock_t tic,toc; double time_unit=static_cast(CLOCKS_PER_SEC); unsigned n=1000,m=1200; // armadillo mat A = randu(n,m); // mat is double mat B = randu(m,n); mat C(n,n); tic=clock(); C = A*B; toc=clock(); cout <<" armadillo timing = "<< (toc-tic)/time_unit<<" sec"<