DistributedRowMatrix implements VectorIterable, Configurable { public DistributedRowMatrix times(DistributedRowMatrix other) throws IOException { if (numRows != other.numRows()) { throw new CardinalityException(numRows, other.numRows()); } Path outPath = new Path(outputTmpBasePath.getParent(), "productWith-" + (System.nanoTime() & 0xFF)); Configuration initialConf = getConf() == null ? new Configuration() : getConf(); Configuration conf = MatrixMultiplicationJob.createMatrixMultiplyJobConf(initialConf, rowPath, other.rowPath, outPath, other.numCols); JobClient.runJob(new JobConf(conf)); DistributedRowMatrix out = new DistributedRowMatrix(outPath, outputTmpPath, numCols, other.numCols()); out.setConf(conf); return out; } DistributedRowMatrix(Path inputPath,
                              Path outputTmpPath,
                              int numRows,
                              int numCols);  DistributedRowMatrix(Path inputPath,
                              Path outputTmpPath,
                              int numRows,
                              int numCols,
                              boolean keepTempFiles); @Override Configuration getConf(); @Override void setConf(Configuration conf); Path getRowPath(); Path getOutputTempPath(); void setOutputTempPathString(String outPathString); @Override Iterator<MatrixSlice> iterateAll(); @Override int numSlices(); @Override int numRows(); @Override int numCols(); DistributedRowMatrix times(DistributedRowMatrix other); DistributedRowMatrix transpose(); @Override Vector times(Vector v); @Override Vector timesSquared(Vector v); @Override Iterator<MatrixSlice> iterator(); static final String KEEP_TEMP_FILES; }
@Test public void testMatrixTimesVector() throws Exception { Vector v = new RandomAccessSparseVector(50); v.assign(1.0); Matrix m = SolverTest.randomSequentialAccessSparseMatrix(100, 90, 50, 20, 1.0); DistributedRowMatrix dm = randomDistributedMatrix(100, 90, 50, 20, 1.0, false); Vector expected = m.times(v); Vector actual = dm.times(v); assertEquals(0.0, expected.getDistanceSquared(actual), EPSILON); }