Program: 11497
Project: 11497
Buggy source:
private void computePartialTile2(final int subSwathIndex,final int burstIndex,Rectangle targetRectangle,final Map<Band,Tile> targetTileMap) throws Exception {
  try {
    final int cohx0=targetRectangle.x - (cohWinRg - 1) / 2;
    final int cohy0=targetRectangle.y - (cohWinAz - 1) / 2;
    final int cohw=targetRectangle.width + cohWinRg - 1;
    final int cohh=targetRectangle.height + cohWinAz - 1;
    final Rectangle rect=new Rectangle(cohx0,cohy0,cohw,cohh);
    final BorderExtender border=BorderExtender.createInstance(BorderExtender.BORDER_ZERO);
    final int y0=targetRectangle.y;
    final int yN=y0 + targetRectangle.height - 1;
    final int x0=targetRectangle.x;
    final int xN=targetRectangle.x + targetRectangle.width - 1;
    final long minLine=burstIndex * subSwath[subSwathIndex - 1].linesPerBurst;
    final long maxLine=minLine + subSwath[subSwathIndex - 1].linesPerBurst - 1;
    final long minPixel=0;
    final long maxPixel=subSwath[subSwathIndex - 1].samplesPerBurst - 1;
    Band targetBand_I;
    Band targetBand_Q;
    for (    String ifgKey : targetMap.keySet()) {
      final ProductContainer product=targetMap.get(ifgKey);
      final Tile mstTileReal=getSourceTile(product.sourceMaster.realBand,rect,border);
      final Tile mstTileImag=getSourceTile(product.sourceMaster.imagBand,rect,border);
      final ComplexDoubleMatrix dataMaster=TileUtilsDoris.pullComplexDoubleMatrix(mstTileReal,mstTileImag);
      final Tile slvTileReal=getSourceTile(product.sourceSlave.realBand,rect,border);
      final Tile slvTileImag=getSourceTile(product.sourceSlave.imagBand,rect,border);
      final ComplexDoubleMatrix dataSlave=TileUtilsDoris.pullComplexDoubleMatrix(slvTileReal,slvTileImag);
      ComplexDoubleMatrix dataMaster2=null, dataSlave2=null;
      if (includeCoherence) {
        dataMaster2=new ComplexDoubleMatrix(mstTileReal.getHeight(),mstTileReal.getWidth());
        dataSlave2=new ComplexDoubleMatrix(slvTileReal.getHeight(),slvTileReal.getWidth());
        dataMaster2.copy(dataMaster);
        dataSlave2.copy(dataSlave);
      }
      if (subtractFlatEarthPhase) {
        DoubleMatrix rangeAxisNormalized=DoubleMatrix.linspace(x0,xN,dataMaster.columns);
        rangeAxisNormalized=normalizeDoubleMatrix(rangeAxisNormalized,minPixel,maxPixel);
        DoubleMatrix azimuthAxisNormalized=DoubleMatrix.linspace(y0,yN,dataMaster.rows);
        azimuthAxisNormalized=normalizeDoubleMatrix(azimuthAxisNormalized,minLine,maxLine);
        final String polynomialName=product.sourceSlave.name + "String_Node_Str" + (subSwathIndex - 1)+ "String_Node_Str"+ burstIndex;
        final DoubleMatrix polyCoeffs=flatEarthPolyMap.get(polynomialName);
        final DoubleMatrix realReferencePhase=PolyUtils.polyval(azimuthAxisNormalized,rangeAxisNormalized,polyCoeffs,PolyUtils.degreeFromCoefficients(polyCoeffs.length));
        final ComplexDoubleMatrix complexReferencePhase=new ComplexDoubleMatrix(MatrixFunctions.cos(realReferencePhase),MatrixFunctions.sin(realReferencePhase));
        dataSlave.muli(complexReferencePhase);
      }
      dataMaster.muli(dataSlave.conji());
      targetBand_I=targetProduct.getBand(product.getBandName(Unit.REAL));
      Tile tileOutReal=targetTileMap.get(targetBand_I);
      targetBand_Q=targetProduct.getBand(product.getBandName(Unit.IMAGINARY));
      Tile tileOutImag=targetTileMap.get(targetBand_Q);
      DoubleMatrix cohMatrix=null;
      ProductData samplesCoh=null;
      if (includeCoherence) {
        for (int i=0; i < dataMaster.length; i++) {
          double tmp=norm(dataMaster2.get(i));
          dataMaster2.put(i,dataMaster2.get(i).mul(dataSlave2.get(i).conj()));
          dataSlave2.put(i,new ComplexDouble(norm(dataSlave2.get(i)),tmp));
        }
        cohMatrix=SarUtils.coherence2(dataMaster2,dataSlave2,cohWinAz,cohWinRg);
        final Band targetBandCoh=targetProduct.getBand(product.getBandName(Unit.COHERENCE));
        final Tile tileOutCoh=targetTileMap.get(targetBandCoh);
        samplesCoh=tileOutCoh.getDataBuffer();
      }
      final ProductData samplesReal=tileOutReal.getDataBuffer();
      final ProductData samplesImag=tileOutImag.getDataBuffer();
      final DoubleMatrix dataReal=dataMaster.real();
      final DoubleMatrix dataImag=dataMaster.imag();
      final int maxX=targetRectangle.x + targetRectangle.width;
      final int maxY=targetRectangle.y + targetRectangle.height;
      final TileIndex tgtIndex=new TileIndex(tileOutReal);
      for (int y=targetRectangle.y; y < maxY; y++) {
        tgtIndex.calculateStride(y);
        final int yy=y - targetRectangle.y;
        for (int x=targetRectangle.x; x < maxX; x++) {
          final int trgIndex=tgtIndex.getIndex(x);
          final int xx=x - targetRectangle.x;
          samplesReal.setElemFloatAt(trgIndex,(float)dataReal.get(yy,xx));
          samplesImag.setElemFloatAt(trgIndex,(float)dataImag.get(yy,xx));
          if (samplesCoh != null) {
            samplesCoh.setElemFloatAt(trgIndex,(float)cohMatrix.get(yy,xx));
          }
        }
      }
    }
  }
 catch (  Throwable e) {
    OperatorUtils.catchOperatorException(getId(),e);
  }
}

Fixed version (ground truth):
private void computePartialTile2(final int subSwathIndex,final int burstIndex,Rectangle targetRectangle,final Map<Band,Tile> targetTileMap) throws Exception {
  try {
    final int rgOffset=(cohWinRg - 1) / 2;
    final int azOffset=(cohWinAz - 1) / 2;
    final int cohx0=targetRectangle.x - rgOffset;
    final int cohy0=targetRectangle.y - azOffset;
    final int cohw=targetRectangle.width + cohWinRg - 1;
    final int cohh=targetRectangle.height + cohWinAz - 1;
    final Rectangle rect=new Rectangle(cohx0,cohy0,cohw,cohh);
    final BorderExtender border=BorderExtender.createInstance(BorderExtender.BORDER_ZERO);
    final int y0=rect.y;
    final int yN=y0 + rect.height - 1;
    final int x0=rect.x;
    final int xN=rect.x + rect.width - 1;
    final long minLine=burstIndex * subSwath[subSwathIndex - 1].linesPerBurst;
    final long maxLine=minLine + subSwath[subSwathIndex - 1].linesPerBurst - 1;
    final long minPixel=0;
    final long maxPixel=subSwath[subSwathIndex - 1].samplesPerBurst - 1;
    Band targetBand_I;
    Band targetBand_Q;
    for (    String ifgKey : targetMap.keySet()) {
      final ProductContainer product=targetMap.get(ifgKey);
      final Tile mstTileReal=getSourceTile(product.sourceMaster.realBand,rect,border);
      final Tile mstTileImag=getSourceTile(product.sourceMaster.imagBand,rect,border);
      final ComplexDoubleMatrix dataMaster=TileUtilsDoris.pullComplexDoubleMatrix(mstTileReal,mstTileImag);
      final Tile slvTileReal=getSourceTile(product.sourceSlave.realBand,rect,border);
      final Tile slvTileImag=getSourceTile(product.sourceSlave.imagBand,rect,border);
      final ComplexDoubleMatrix dataSlave=TileUtilsDoris.pullComplexDoubleMatrix(slvTileReal,slvTileImag);
      ComplexDoubleMatrix dataMaster2=null, dataSlave2=null;
      if (includeCoherence) {
        dataMaster2=new ComplexDoubleMatrix(mstTileReal.getHeight(),mstTileReal.getWidth());
        dataSlave2=new ComplexDoubleMatrix(slvTileReal.getHeight(),slvTileReal.getWidth());
        dataMaster2.copy(dataMaster);
        dataSlave2.copy(dataSlave);
      }
      if (subtractFlatEarthPhase) {
        DoubleMatrix rangeAxisNormalized=DoubleMatrix.linspace(x0,xN,dataMaster.columns);
        rangeAxisNormalized=normalizeDoubleMatrix(rangeAxisNormalized,minPixel,maxPixel);
        DoubleMatrix azimuthAxisNormalized=DoubleMatrix.linspace(y0,yN,dataMaster.rows);
        azimuthAxisNormalized=normalizeDoubleMatrix(azimuthAxisNormalized,minLine,maxLine);
        final String polynomialName=product.sourceSlave.name + "String_Node_Str" + (subSwathIndex - 1)+ "String_Node_Str"+ burstIndex;
        final DoubleMatrix polyCoeffs=flatEarthPolyMap.get(polynomialName);
        final DoubleMatrix realReferencePhase=PolyUtils.polyval(azimuthAxisNormalized,rangeAxisNormalized,polyCoeffs,PolyUtils.degreeFromCoefficients(polyCoeffs.length));
        final ComplexDoubleMatrix complexReferencePhase=new ComplexDoubleMatrix(MatrixFunctions.cos(realReferencePhase),MatrixFunctions.sin(realReferencePhase));
        dataSlave.muli(complexReferencePhase);
      }
      dataMaster.muli(dataSlave.conji());
      targetBand_I=targetProduct.getBand(product.getBandName(Unit.REAL));
      Tile tileOutReal=targetTileMap.get(targetBand_I);
      targetBand_Q=targetProduct.getBand(product.getBandName(Unit.IMAGINARY));
      Tile tileOutImag=targetTileMap.get(targetBand_Q);
      DoubleMatrix cohMatrix=null;
      ProductData samplesCoh=null;
      if (includeCoherence) {
        for (int i=0; i < dataMaster.length; i++) {
          double tmp=norm(dataMaster2.get(i));
          dataMaster2.put(i,dataMaster2.get(i).mul(dataSlave2.get(i).conj()));
          dataSlave2.put(i,new ComplexDouble(norm(dataSlave2.get(i)),tmp));
        }
        cohMatrix=SarUtils.coherence2(dataMaster2,dataSlave2,cohWinAz,cohWinRg);
        final Band targetBandCoh=targetProduct.getBand(product.getBandName(Unit.COHERENCE));
        final Tile tileOutCoh=targetTileMap.get(targetBandCoh);
        samplesCoh=tileOutCoh.getDataBuffer();
      }
      final ProductData samplesReal=tileOutReal.getDataBuffer();
      final ProductData samplesImag=tileOutImag.getDataBuffer();
      final DoubleMatrix dataReal=dataMaster.real();
      final DoubleMatrix dataImag=dataMaster.imag();
      final int maxX=targetRectangle.x + targetRectangle.width;
      final int maxY=targetRectangle.y + targetRectangle.height;
      final TileIndex tgtIndex=new TileIndex(tileOutReal);
      for (int y=targetRectangle.y; y < maxY; y++) {
        tgtIndex.calculateStride(y);
        final int yy=y - targetRectangle.y;
        for (int x=targetRectangle.x; x < maxX; x++) {
          final int trgIndex=tgtIndex.getIndex(x);
          final int xx=x - targetRectangle.x;
          samplesReal.setElemFloatAt(trgIndex,(float)dataReal.get(yy + azOffset,xx + rgOffset));
          samplesImag.setElemFloatAt(trgIndex,(float)dataImag.get(yy + azOffset,xx + rgOffset));
          if (samplesCoh != null) {
            samplesCoh.setElemFloatAt(trgIndex,(float)cohMatrix.get(yy,xx));
          }
        }
      }
    }
  }
 catch (  Throwable e) {
    OperatorUtils.catchOperatorException(getId(),e);
  }
}