MatrixWritable implements Writable { public void set(Matrix matrix) { this.matrix = matrix; } MatrixWritable();  MatrixWritable(Matrix m); Matrix get(); void set(Matrix matrix); @Override void write(DataOutput out); @Override void readFields(DataInput in); static void readLabels(DataInput in,
                                Map<String, Integer> columnLabelBindings,
                                Map<String, Integer> rowLabelBindings); static void writeLabelBindings(DataOutput out,
                                        Map<String, Integer> columnLabelBindings,
                                        Map<String, Integer> rowLabelBindings); static Matrix readMatrix(DataInput in); static void writeMatrix(final DataOutput out, Matrix matrix);  }
@Test public void testSparseMatrixWritable() throws Exception { Matrix m = new SparseMatrix(5, 5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = Maps.newHashMap(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testSparseRowMatrixWritable() throws Exception { Matrix m = new SparseRowMatrix(5, 5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = Maps.newHashMap(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testDenseMatrixWritable() throws Exception { Matrix m = new DenseMatrix(5,5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = Maps.newHashMap(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testSparseMatrixWritable() throws Exception { Matrix m = new SparseMatrix(5, 5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = new HashMap<>(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testSparseRowMatrixWritable() throws Exception { Matrix m = new SparseRowMatrix(5, 5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = new HashMap<>(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }
@Test public void testDenseMatrixWritable() throws Exception { Matrix m = new DenseMatrix(5,5); m.set(1, 2, 3.0); m.set(3, 4, 5.0); Map<String, Integer> bindings = new HashMap<>(); bindings.put("A", 0); bindings.put("B", 1); bindings.put("C", 2); bindings.put("D", 3); bindings.put("default", 4); m.setRowLabelBindings(bindings); m.setColumnLabelBindings(bindings); doTestMatrixWritableEquals(m); }