@Test(expected = IndexException.class) public void testViewPartIndexOver() { int[] offset = {1, 1}; int[] size = {2, 2}; test.viewPart(offset, size); }
@Override public Matrix viewPart(int[] offset, int[] size) { if (offset[ROW] < 0) { throw new IndexException(offset[ROW], 0); } if (offset[ROW] + size[ROW] > rowSize()) { throw new IndexException(offset[ROW] + size[ROW], rowSize()); } if (offset[COL] < 0) { throw new IndexException(offset[COL], 0); } if (offset[COL] + size[COL] > columnSize()) { throw new IndexException(offset[COL] + size[COL], columnSize()); } int[] origin = this.offset.clone(); origin[ROW] += offset[ROW]; origin[COL] += offset[COL]; return new MatrixView(matrix, origin, size); }
MatrixView extends AbstractMatrix { @Override public Matrix viewPart(int[] offset, int[] size) { if (offset[ROW] < 0) { throw new IndexException(offset[ROW], 0); } if (offset[ROW] + size[ROW] > rowSize()) { throw new IndexException(offset[ROW] + size[ROW], rowSize()); } if (offset[COL] < 0) { throw new IndexException(offset[COL], 0); } if (offset[COL] + size[COL] > columnSize()) { throw new IndexException(offset[COL] + size[COL], columnSize()); } int[] origin = this.offset.clone(); origin[ROW] += offset[ROW]; origin[COL] += offset[COL]; return new MatrixView(matrix, origin, size); } }
MatrixView extends AbstractMatrix { @Override public Matrix viewPart(int[] offset, int[] size) { if (offset[ROW] < 0) { throw new IndexException(offset[ROW], 0); } if (offset[ROW] + size[ROW] > rowSize()) { throw new IndexException(offset[ROW] + size[ROW], rowSize()); } if (offset[COL] < 0) { throw new IndexException(offset[COL], 0); } if (offset[COL] + size[COL] > columnSize()) { throw new IndexException(offset[COL] + size[COL], columnSize()); } int[] origin = this.offset.clone(); origin[ROW] += offset[ROW]; origin[COL] += offset[COL]; return new MatrixView(matrix, origin, size); } MatrixView(Matrix matrix, int[] offset, int[] size); }
MatrixView extends AbstractMatrix { @Override public Matrix viewPart(int[] offset, int[] size) { if (offset[ROW] < 0) { throw new IndexException(offset[ROW], 0); } if (offset[ROW] + size[ROW] > rowSize()) { throw new IndexException(offset[ROW] + size[ROW], rowSize()); } if (offset[COL] < 0) { throw new IndexException(offset[COL], 0); } if (offset[COL] + size[COL] > columnSize()) { throw new IndexException(offset[COL] + size[COL], columnSize()); } int[] origin = this.offset.clone(); origin[ROW] += offset[ROW]; origin[COL] += offset[COL]; return new MatrixView(matrix, origin, size); } 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); @Override MatrixFlavor getFlavor(); }
MatrixView extends AbstractMatrix { @Override public Matrix viewPart(int[] offset, int[] size) { if (offset[ROW] < 0) { throw new IndexException(offset[ROW], 0); } if (offset[ROW] + size[ROW] > rowSize()) { throw new IndexException(offset[ROW] + size[ROW], rowSize()); } if (offset[COL] < 0) { throw new IndexException(offset[COL], 0); } if (offset[COL] + size[COL] > columnSize()) { throw new IndexException(offset[COL] + size[COL], columnSize()); } int[] origin = this.offset.clone(); origin[ROW] += offset[ROW]; origin[COL] += offset[COL]; return new MatrixView(matrix, origin, size); } 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); @Override MatrixFlavor getFlavor();  }