MatrixVectorMultiplier { public Vector<Integer> multiply(final Matrix<Integer> matrix, final Vector<Integer> vector) { final Vector<Integer> result = new ArrayVector<>(vector.size()); scheduler.loop(0, result.size(), new LoopStep() { @Override public void perform(int i) { result.set(i, 0); } }); scheduler.loop(0, result.size(), new LoopStep() { @Override public void perform(int i) { for (int j = 0; j < result.size(); j++) { result.set(i, result.get(i) + matrix.get(j, i) * vector.get(j)); } } }); return result; } MatrixVectorMultiplier(SchedulerFactory factory); Vector<Integer> multiply(final Matrix<Integer> matrix, final Vector<Integer> vector);  }
@Test(dataProvider = "getSchedulerFactory") public void testSerial(@SuppressWarnings("UnusedParameters") String name, SchedulerFactory factory) throws Exception { final MatrixVectorMultiplier multiplier = new MatrixVectorMultiplier(factory); final Vector<Integer> result = multiplier.multiply(matrix, vector); assertThat(result, is(notNullValue())); assertThat(result.size(), is(expected.size())); for (int i = 0; i < expected.size(); i++) { assertThat(result.get(i), is(expected.get(i))); } }