MatrixView extends AbstractMatrix { @Override public Matrix assignColumn(int column, Vector other) { if (rowSize() != other.size()) { throw new CardinalityException(rowSize(), other.size()); } for (int row = 0; row < rowSize(); row++) { matrix.setQuick(row + offset[ROW], column + offset[COL], other .getQuick(row)); } return this; } MatrixView(Matrix matrix, int[] offset, int[] size); @Override Matrix clone(); @Override double getQuick(int row, int column); @Override Matrix like(); @Override Matrix like(int rows, int columns); @Override void setQuick(int row, int column, double value); @Override int[] getNumNondefaultElements(); @Override Matrix viewPart(int[] offset, int[] size); @Override Matrix assignColumn(int column, Vector other); @Override Matrix assignRow(int row, Vector other); @Override Vector viewColumn(int column); @Override Vector viewRow(int row);  }
@Test public void testAssignColumn() { double[] data = {2.1, 3.2, 4.3}; test.assignColumn(1, new DenseVector(data)); assertEquals("test[0][1]", 2.1, test.getQuick(0, 1), EPSILON); assertEquals("test[1][1]", 3.2, test.getQuick(1, 1), EPSILON); assertEquals("test[2][1]", 4.3, test.getQuick(2, 1), EPSILON); }
@Test(expected = CardinalityException.class) public void testAssignColumnCardinality() { double[] data = {2.1, 3.2}; test.assignColumn(1, new DenseVector(data)); }