The matrix \* vector multiplication is incorrect, effectively treating the matrix as row major when it is column major. For example `for (int j = 0; j < N; j++) sum += a[i][j] * b[j];` should be `for (int j = 0; j < N; j++) sum += a[j][i] * b[j];`, etc.