@Override final public Matrix getSubMatrix( final int minRow, final int maxRow, final int minColumn, final int maxColumn) { checkSubmatrixRange(minRow, maxRow, minColumn, maxColumn); SparseMatrix result = new SparseMatrix(maxRow - minRow + 1, maxColumn - minColumn + 1); // You only need worry about the diagonal, so one of the extents will do for (int i = minRow; i <= maxRow; ++i) { // Check to make sure that this element of the diagonal is also in // the other extents if (i >= minColumn && i <= maxColumn) { // If it is, add it at the right place in the output result.setElement(i - minRow, i - minColumn, get(i, i)); } } return result; }
@Override final public Matrix getSubMatrix( final int minRow, final int maxRow, final int minColumn, final int maxColumn) { checkSubmatrixRange(minRow, maxRow, minColumn, maxColumn); SparseMatrix result = new SparseMatrix(maxRow - minRow + 1, maxColumn - minColumn + 1); // You only need worry about the diagonal, so one of the extents will do for (int i = minRow; i <= maxRow; ++i) { // Check to make sure that this element of the diagonal is also in // the other extents if (i >= minColumn && i <= maxColumn) { // If it is, add it at the right place in the output result.setElement(i - minRow, i - minColumn, get(i, i)); } } return result; }
@Override final public Matrix getSubMatrix( final int minRow, final int maxRow, final int minColumn, final int maxColumn) { checkSubmatrixRange(minRow, maxRow, minColumn, maxColumn); SparseMatrix result = new SparseMatrix(maxRow - minRow + 1, maxColumn - minColumn + 1); // You only need worry about the diagonal, so one of the extents will do for (int i = minRow; i <= maxRow; ++i) { // Check to make sure that this element of the diagonal is also in // the other extents if (i >= minColumn && i <= maxColumn) { // If it is, add it at the right place in the output result.setElement(i - minRow, i - minColumn, get(i, i)); } } return result; }