def test_dgemm(): A = np.array([[0, 1, 2], [3, 4, 5]], dtype='f8') B = np.array([[0, 1], [2, 3], [4, 5]], dtype='f8') C = np.zeros((2, 2)) alpha = 2. beta = 3. dgemm(A, B, C, alpha, beta) C2 = np.zeros((2, 2)) assert_array_almost_equal(C, alpha * np.dot(A, B) + beta * C2)
print(b) print(ddot(a, b)) """ Level 3 alpha*dot(A,B) + beta*C """ A = np.array([[0, 1, 2], [3, 4, 5]], dtype='f8') B = np.array([[0, 1], [2, 3], [4, 5]], dtype='f8') C = np.zeros((2, 2)) alpha = 2. beta = 3. dgemm(A, B, C, alpha, beta) print(C) C = np.zeros((2, 2)) print(alpha * np.dot(A, B) + beta * C) A = np.random.rand(500, 400).astype('f8') B = np.random.rand(400, 300).astype('f8') C = np.zeros((500, 300), 'f8') C2 = np.zeros((500, 300), 'f8') times = [] for i in range(200): t0 = time() dgemm(A, B, C) t00 = time() - t0