Why is the GNU scientific library matrix multiplication slower than numpy.matmul?
12
2
Why is it that the matrix multiplication with Numpy is much faster than gsl_blas_sgemm from GSL, for instance: import numpy as np import time N = 1000 M = np.zeros(shape=(N, N), dtype=np.float) for i in range(N): for j in range(N): M[i, j] = 0.23 + 100*i + j tic = time.time() np.matmul(M, M) toc = time.time() print(toc - tic) gives something between 0.017 - 0.019 seconds, while in C++: #include <chrono> #include <iostream> #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> using namespace std::chrono; int main(void) { int N = 1000; gsl_matrix_float* M = gsl_matrix_float_alloc(N, N); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { gsl_matrix_float_set(M, i, j, 0.23 ...