Program: 11504
Project: 11504
Buggy source:
/** 
 * Called by the framework in order to compute the stack of tiles for the given target bands. <p>The default implementation throws a runtime exception with the message "not implemented".</p>
 * @param targetTiles     The current tiles to be computed for each target band.
 * @param targetRectangle The area in pixel coordinates to be computed (same for all rasters in <code>targetRasters</code>).
 * @param pm              A progress monitor which should be used to determine computation cancelation requests.
 * @throws org.esa.beam.framework.gpf.OperatorException if an error occurs during computation of the target rasters.
 */
@Override public void computeTileStack(Map<Band,Tile> targetTiles,Rectangle targetRectangle,ProgressMonitor pm) throws OperatorException {
  try {
    final int x0=targetRectangle.x;
    final int y0=targetRectangle.y;
    final int w=targetRectangle.width;
    final int h=targetRectangle.height;
    final int maxY=y0 + h;
    final int maxX=x0 + w;
    final double[][] C3r=new double[3][3];
    final double[][] C3i=new double[3][3];
    final double[][] C4r=new double[4][4];
    final double[][] C4i=new double[4][4];
    final double[][] T3r=new double[3][3];
    final double[][] T3i=new double[3][3];
    final double[][] T4r=new double[4][4];
    final double[][] T4i=new double[4][4];
    for (    final PolBandUtils.QuadSourceBand bandList : srcBandList) {
      final Tile[] sourceTiles=new Tile[bandList.srcBands.length];
      final ProductData[] dataBuffers=new ProductData[bandList.srcBands.length];
      for (int i=0; i < bandList.srcBands.length; i++) {
        sourceTiles[i]=getSourceTile(bandList.srcBands[i],targetRectangle);
        dataBuffers[i]=sourceTiles[i].getDataBuffer();
      }
      final TileIndex trgIndex=new TileIndex(sourceTiles[0]);
      double theta, t11, t12Re, t12Im, t13Re, t13Im, t22, t23Re, t23Im, t33, c, s, c2, s2, s4, cs;
      for (int y=y0; y < maxY; ++y) {
        trgIndex.calculateStride(y);
        for (int x=x0; x < maxX; ++x) {
          final int idx=trgIndex.getIndex(x);
          if (sourceProductType == PolBandUtils.MATRIX.T3) {
            PolOpUtils.getCoherencyMatrixT3(idx,dataBuffers,T3r,T3i);
          }
 else           if (sourceProductType == PolBandUtils.MATRIX.T4) {
            PolOpUtils.getCoherencyMatrixT4(idx,dataBuffers,T4r,T4i);
            PolOpUtils.t4ToT3(T4r,T4i,T3r,T3i);
          }
 else           if (sourceProductType == PolBandUtils.MATRIX.C3) {
            PolOpUtils.getCovarianceMatrixC3(idx,dataBuffers,C3r,C3i);
            PolOpUtils.c3ToT3(C3r,C3i,T3r,T3i);
          }
 else           if (sourceProductType == PolBandUtils.MATRIX.C4) {
            PolOpUtils.getCovarianceMatrixC4(idx,dataBuffers,C4r,C4i);
            PolOpUtils.c4ToT4(C4r,C4i,T4r,T4i);
            PolOpUtils.t4ToT3(T4r,T4i,T3r,T3i);
          }
          theta=estimateOrientationAngle(T3r[1][2],T3r[1][1],T3r[2][2]);
          c=FastMath.cos(2 * theta);
          s=FastMath.sin(2 * theta);
          c2=c * c;
          s2=s * s;
          cs=c * s;
          t11=T3r[0][0];
          t12Re=T3r[0][1] * c - T3r[0][2] * s;
          t12Im=T3i[0][1] * c - T3i[0][2] * s;
          t13Re=T3r[0][1] * s + T3r[0][2] * c;
          t13Im=T3i[0][1] * s + T3i[0][2] * c;
          t22=T3r[1][1] * c2 + T3r[2][2] * s2 - 2 * T3r[1][2] * cs;
          t23Re=T3r[1][2] * (c2 - s2) + (T3r[1][1] - T3r[2][2]) * cs;
          t23Im=T3i[1][2];
          t33=T3r[1][1] * s2 + T3r[2][2] * c2 + 2 * T3r[1][2] * cs;
          for (          Band targetBand : bandList.targetBands) {
            final String targetBandName=targetBand.getName();
            final Tile targetTile=targetTiles.get(targetBand);
            if (targetBandName.contains("String_Node_Str")) {
              targetTile.getDataBuffer().setElemFloatAt(idx,(float)t11);
            }
 else             if (targetBandName.contains("String_Node_Str")) {
              targetTile.getDataBuffer().setElemFloatAt(idx,(float)t12Re);
            }
 else             if (targetBandName.contains("String_Node_Str")) {
              targetTile.getDataBuffer().setElemFloatAt(idx,(float)t12Im);
            }
 else             if (targetBandName.contains("String_Node_Str")) {
              targetTile.getDataBuffer().setElemFloatAt(idx,(float)t13Re);
            }
 else             if (targetBandName.contains("String_Node_Str")) {
              targetTile.getDataBuffer().setElemFloatAt(idx,(float)t13Im);
            }
 else             if (targetBandName.contains("String_Node_Str")) {
              targetTile.getDataBuffer().setElemFloatAt(idx,(float)t22);
            }
 else             if (targetBandName.contains("String_Node_Str")) {
              targetTile.getDataBuffer().setElemFloatAt(idx,(float)t23Re);
            }
 else             if (targetBandName.contains("String_Node_Str")) {
              targetTile.getDataBuffer().setElemFloatAt(idx,(float)t23Im);
            }
 else             if (targetBandName.contains("String_Node_Str")) {
              targetTile.getDataBuffer().setElemFloatAt(idx,(float)t33);
            }
          }
        }
      }
    }
  }
 catch (  Throwable e) {
    OperatorUtils.catchOperatorException(getId(),e);
  }
 finally {
    pm.done();
  }
}

Fixed version (ground truth):
/** 
 * Called by the framework in order to compute the stack of tiles for the given target bands. <p>The default implementation throws a runtime exception with the message "not implemented".</p>
 * @param targetTiles     The current tiles to be computed for each target band.
 * @param targetRectangle The area in pixel coordinates to be computed (same for all rasters in <code>targetRasters</code>).
 * @param pm              A progress monitor which should be used to determine computation cancelation requests.
 * @throws org.esa.beam.framework.gpf.OperatorException if an error occurs during computation of the target rasters.
 */
@Override public void computeTileStack(Map<Band,Tile> targetTiles,Rectangle targetRectangle,ProgressMonitor pm) throws OperatorException {
  try {
    final int x0=targetRectangle.x;
    final int y0=targetRectangle.y;
    final int w=targetRectangle.width;
    final int h=targetRectangle.height;
    final int maxY=y0 + h;
    final int maxX=x0 + w;
    final double[][] C3r=new double[3][3];
    final double[][] C3i=new double[3][3];
    final double[][] C4r=new double[4][4];
    final double[][] C4i=new double[4][4];
    final double[][] T3r=new double[3][3];
    final double[][] T3i=new double[3][3];
    final double[][] T4r=new double[4][4];
    final double[][] T4i=new double[4][4];
    final TileIndex tgtIndex=new TileIndex(targetTiles.get(getTargetProduct().getBandAt(0)));
    for (    final PolBandUtils.QuadSourceBand bandList : srcBandList) {
      final Tile[] sourceTiles=new Tile[bandList.srcBands.length];
      final ProductData[] dataBuffers=new ProductData[bandList.srcBands.length];
      for (int i=0; i < bandList.srcBands.length; i++) {
        sourceTiles[i]=getSourceTile(bandList.srcBands[i],targetRectangle);
        dataBuffers[i]=sourceTiles[i].getDataBuffer();
      }
      final TileIndex srcIndex=new TileIndex(sourceTiles[0]);
      final ProductData[] targetDataBuffers=new ProductData[9];
      for (      final Band targetBand : bandList.targetBands) {
        final String targetBandName=targetBand.getName();
        final ProductData dataBuffer=targetTiles.get(targetBand).getDataBuffer();
        if (PolBandUtils.isBandForMatrixElement(targetBandName,"String_Node_Str"))         targetDataBuffers[0]=dataBuffer;
 else         if (PolBandUtils.isBandForMatrixElement(targetBandName,"String_Node_Str"))         targetDataBuffers[1]=dataBuffer;
 else         if (PolBandUtils.isBandForMatrixElement(targetBandName,"String_Node_Str"))         targetDataBuffers[2]=dataBuffer;
 else         if (PolBandUtils.isBandForMatrixElement(targetBandName,"String_Node_Str"))         targetDataBuffers[3]=dataBuffer;
 else         if (PolBandUtils.isBandForMatrixElement(targetBandName,"String_Node_Str"))         targetDataBuffers[4]=dataBuffer;
 else         if (PolBandUtils.isBandForMatrixElement(targetBandName,"String_Node_Str"))         targetDataBuffers[5]=dataBuffer;
 else         if (PolBandUtils.isBandForMatrixElement(targetBandName,"String_Node_Str"))         targetDataBuffers[6]=dataBuffer;
 else         if (PolBandUtils.isBandForMatrixElement(targetBandName,"String_Node_Str"))         targetDataBuffers[7]=dataBuffer;
 else         if (PolBandUtils.isBandForMatrixElement(targetBandName,"String_Node_Str"))         targetDataBuffers[8]=dataBuffer;
      }
      final double[][] Tr=new double[3][3];
      final double[][] Ti=new double[3][3];
      int srcIdx, tgtIdx;
      double theta, c, s, c2, s2, cs;
      for (int y=y0; y < maxY; ++y) {
        srcIndex.calculateStride(y);
        tgtIndex.calculateStride(y);
        for (int x=x0; x < maxX; ++x) {
          srcIdx=srcIndex.getIndex(x);
          tgtIdx=tgtIndex.getIndex(x);
          if (sourceProductType == PolBandUtils.MATRIX.FULL) {
            PolOpUtils.getT3(srcIdx,sourceProductType,dataBuffers,T3r,T3i);
          }
 else           if (sourceProductType == PolBandUtils.MATRIX.T3) {
            PolOpUtils.getCoherencyMatrixT3(srcIdx,dataBuffers,T3r,T3i);
          }
 else           if (sourceProductType == PolBandUtils.MATRIX.T4) {
            PolOpUtils.getCoherencyMatrixT4(srcIdx,dataBuffers,T4r,T4i);
            PolOpUtils.t4ToT3(T4r,T4i,T3r,T3i);
          }
 else           if (sourceProductType == PolBandUtils.MATRIX.C3) {
            PolOpUtils.getCovarianceMatrixC3(srcIdx,dataBuffers,C3r,C3i);
            PolOpUtils.c3ToT3(C3r,C3i,T3r,T3i);
          }
 else           if (sourceProductType == PolBandUtils.MATRIX.C4) {
            PolOpUtils.getCovarianceMatrixC4(srcIdx,dataBuffers,C4r,C4i);
            PolOpUtils.c4ToT4(C4r,C4i,T4r,T4i);
            PolOpUtils.t4ToT3(T4r,T4i,T3r,T3i);
          }
          theta=estimateOrientationAngle(T3r[1][2],T3r[1][1],T3r[2][2]);
          c=FastMath.cos(2 * theta);
          s=FastMath.sin(2 * theta);
          c2=c * c;
          s2=s * s;
          cs=c * s;
          Tr[0][0]=T3r[0][0];
          Tr[0][1]=T3r[0][1] * c - T3r[0][2] * s;
          Ti[0][1]=T3i[0][1] * c - T3i[0][2] * s;
          Tr[0][2]=T3r[0][1] * s + T3r[0][2] * c;
          Ti[0][2]=T3i[0][1] * s + T3i[0][2] * c;
          Tr[1][1]=T3r[1][1] * c2 + T3r[2][2] * s2 - 2 * T3r[1][2] * cs;
          Tr[1][2]=T3r[1][2] * (c2 - s2) + (T3r[1][1] - T3r[2][2]) * cs;
          Ti[1][2]=T3i[1][2];
          Tr[2][2]=T3r[1][1] * s2 + T3r[2][2] * c2 + 2 * T3r[1][2] * cs;
          saveT3(Tr,Ti,tgtIdx,targetDataBuffers);
        }
      }
    }
  }
 catch (  Throwable e) {
    OperatorUtils.catchOperatorException(getId(),e);
  }
 finally {
    pm.done();
  }
}