@Test public void testMultiply() throws Exception { DenseMatrix a = new DenseMatrix(N, M, generateRandomIntArray(N, M)); DenseMatrix b = new DenseMatrix(M, N, generateRandomIntArray(M, N)); long startTime = System.nanoTime(); DenseMatrix result = a.multiply(b); long estimatedTime = System.nanoTime() - startTime; System.out.println("Execution time(ms) slow multiply " + (estimatedTime / 1000000)); int[][] correct = new int[N][N]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { for (int k = 0; k < M; k++) { correct[i][j] += a.get(i, k) * b.get(k, j); } } } for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { assertTrue(result.get(i, j) == correct[i][j]); } } }