Program: 57490
Project: 57490
Buggy source:
/** 
 * {@inheritDoc} 
 */
public RealMatrix getSubMatrix(final int startRow,final int endRow,final int startColumn,final int endColumn) throws MatrixIndexException {
  checkSubMatrixIndex(startRow,endRow,startColumn,endColumn);
  final DenseRealMatrix out=new DenseRealMatrix(endRow - startRow + 1,endColumn - startColumn + 1);
  final int blockStartRow=startRow / BLOCK_SIZE;
  final int rowsShift=startRow % BLOCK_SIZE;
  final int blockStartColumn=startColumn / BLOCK_SIZE;
  final int columnsShift=startColumn % BLOCK_SIZE;
  for (int iBlock=0, pBlock=blockStartRow; iBlock < out.blockRows; ++iBlock, ++pBlock) {
    final int iHeight=out.blockHeight(iBlock);
    for (int jBlock=0, qBlock=blockStartColumn; jBlock < out.blockColumns; ++jBlock, ++qBlock) {
      final int jWidth=out.blockWidth(jBlock);
      final int outIndex=iBlock * out.blockColumns + jBlock;
      final double[] outBlock=out.blocks[outIndex];
      final int index=pBlock * blockColumns + qBlock;
      final int width=blockWidth(index);
      final int heightExcess=iHeight + rowsShift - BLOCK_SIZE;
      final int widthExcess=jWidth + columnsShift - BLOCK_SIZE;
      if (heightExcess > 0) {
        if (widthExcess > 0) {
          final int width2=blockWidth(index + 1);
          copyBlockPart(blocks[index],width,rowsShift,BLOCK_SIZE,columnsShift,BLOCK_SIZE,outBlock,jWidth,0,0);
          copyBlockPart(blocks[index + 1],width2,rowsShift,BLOCK_SIZE,0,widthExcess,outBlock,jWidth,0,jWidth - widthExcess);
          copyBlockPart(blocks[index + blockColumns],width,0,heightExcess,columnsShift,BLOCK_SIZE,outBlock,jWidth,iHeight - heightExcess,0);
          copyBlockPart(blocks[index + blockColumns + 1],width2,0,heightExcess,0,widthExcess,outBlock,jWidth,iHeight - heightExcess,jWidth - widthExcess);
        }
 else {
          copyBlockPart(blocks[index],width,rowsShift,BLOCK_SIZE,columnsShift,jWidth + columnsShift,outBlock,jWidth,0,0);
          copyBlockPart(blocks[index + blockColumns],width,0,heightExcess,columnsShift,jWidth + columnsShift,outBlock,jWidth,iHeight - heightExcess,0);
        }
      }
 else {
        if (widthExcess > 0) {
          final int width2=blockWidth(index + 1);
          copyBlockPart(blocks[index],width,rowsShift,iHeight + rowsShift,columnsShift,BLOCK_SIZE,outBlock,jWidth,0,0);
          copyBlockPart(blocks[index + 1],width2,rowsShift,iHeight + rowsShift,0,widthExcess,outBlock,jWidth,0,jWidth - widthExcess);
        }
 else {
          copyBlockPart(blocks[index],width,rowsShift,iHeight + rowsShift,columnsShift,jWidth + columnsShift,outBlock,jWidth,0,0);
        }
      }
    }
  }
  return out;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public RealMatrix getSubMatrix(final int startRow,final int endRow,final int startColumn,final int endColumn) throws MatrixIndexException {
  checkSubMatrixIndex(startRow,endRow,startColumn,endColumn);
  final DenseRealMatrix out=new DenseRealMatrix(endRow - startRow + 1,endColumn - startColumn + 1);
  final int blockStartRow=startRow / BLOCK_SIZE;
  final int rowsShift=startRow % BLOCK_SIZE;
  final int blockStartColumn=startColumn / BLOCK_SIZE;
  final int columnsShift=startColumn % BLOCK_SIZE;
  for (int iBlock=0, pBlock=blockStartRow; iBlock < out.blockRows; ++iBlock, ++pBlock) {
    final int iHeight=out.blockHeight(iBlock);
    for (int jBlock=0, qBlock=blockStartColumn; jBlock < out.blockColumns; ++jBlock, ++qBlock) {
      final int jWidth=out.blockWidth(jBlock);
      final int outIndex=iBlock * out.blockColumns + jBlock;
      final double[] outBlock=out.blocks[outIndex];
      final int index=pBlock * blockColumns + qBlock;
      final int width=blockWidth(qBlock);
      final int heightExcess=iHeight + rowsShift - BLOCK_SIZE;
      final int widthExcess=jWidth + columnsShift - BLOCK_SIZE;
      if (heightExcess > 0) {
        if (widthExcess > 0) {
          final int width2=blockWidth(qBlock + 1);
          copyBlockPart(blocks[index],width,rowsShift,BLOCK_SIZE,columnsShift,BLOCK_SIZE,outBlock,jWidth,0,0);
          copyBlockPart(blocks[index + 1],width2,rowsShift,BLOCK_SIZE,0,widthExcess,outBlock,jWidth,0,jWidth - widthExcess);
          copyBlockPart(blocks[index + blockColumns],width,0,heightExcess,columnsShift,BLOCK_SIZE,outBlock,jWidth,iHeight - heightExcess,0);
          copyBlockPart(blocks[index + blockColumns + 1],width2,0,heightExcess,0,widthExcess,outBlock,jWidth,iHeight - heightExcess,jWidth - widthExcess);
        }
 else {
          copyBlockPart(blocks[index],width,rowsShift,BLOCK_SIZE,columnsShift,jWidth + columnsShift,outBlock,jWidth,0,0);
          copyBlockPart(blocks[index + blockColumns],width,0,heightExcess,columnsShift,jWidth + columnsShift,outBlock,jWidth,iHeight - heightExcess,0);
        }
      }
 else {
        if (widthExcess > 0) {
          final int width2=blockWidth(qBlock + 1);
          copyBlockPart(blocks[index],width,rowsShift,iHeight + rowsShift,columnsShift,BLOCK_SIZE,outBlock,jWidth,0,0);
          copyBlockPart(blocks[index + 1],width2,rowsShift,iHeight + rowsShift,0,widthExcess,outBlock,jWidth,0,jWidth - widthExcess);
        }
 else {
          copyBlockPart(blocks[index],width,rowsShift,iHeight + rowsShift,columnsShift,jWidth + columnsShift,outBlock,jWidth,0,0);
        }
      }
    }
  }
  return out;
}