Program: 11554
Project: 11554
Buggy source:
/** 
 * Reconstruct full pol coherency matrix T3 using compact pol data. The random volume over ground (RVOG) model is assumed.
 * @param sourceProductType The compact pol source product type
 * @param idx Pixel index in source product
 * @param dataBuffers Source band data buffers
 * @param Tr Real part of the reconstructed T3 matrix
 * @param Ti Imaginary part of the reconstructed T3 matrix
 */
public static void reconstructCoherencyMatrixT3(final PolBandUtils.MATRIX sourceProductType,final int idx,final ProductData[] dataBuffers,final double[][] Tr,final double[][] Ti){
  final double[][] Cr=new double[2][2];
  final double[][] Ci=new double[2][2];
  final double[] kr=new double[2];
  final double[] ki=new double[2];
  final double[] g=new double[4];
  if (sourceProductType == PolBandUtils.MATRIX.C2) {
    getCovarianceMatrixC2(idx,dataBuffers,Cr,Ci);
    computeCompactPolStokesVector(Cr,Ci,g);
  }
 else   if (sourceProductType == PolBandUtils.MATRIX.COMPACT) {
    getCompactPolScatterVector(idx,dataBuffers,kr,ki);
    computeCompactPolStokesVector(kr,ki,g);
  }
  if (g[0] <= 0) {
    return;
  }
  final double m=Math.sqrt(g[1] * g[1] + g[2] * g[2] + g[3] * g[3]) / g[0];
  final double mv=0.5 * g[0] * (1 - m);
  final double ms=2.0 * g[0] * m;
  final double alpha=0.5 * Math.atan(Math.sqrt(g[1] * g[1] + g[2] * g[2]) / g[3]);
  final double phi=Math.acos(g[1] / Math.sqrt(g[1] * g[1] + g[2] * g[2]));
  final double cosAlpha=Math.cos(alpha);
  final double sinAlpha=Math.sin(alpha);
  final double cosPhi=Math.cos(phi);
  final double sinPhi=Math.sin(phi);
  Tr[0][0]=ms * cosAlpha * cosAlpha + 2.0 * mv;
  Ti[0][0]=0.0;
  Tr[0][1]=ms * cosAlpha * sinAlpha* cosPhi;
  Ti[0][1]=ms * cosAlpha * sinAlpha* sinPhi;
  Tr[0][2]=0.0;
  Ti[0][2]=0.0;
  Tr[1][0]=Tr[0][1];
  Ti[1][0]=-Ti[0][1];
  Tr[1][1]=ms * sinAlpha * sinAlpha + mv;
  Ti[1][1]=0.0;
  Tr[1][2]=0.0;
  Ti[1][2]=0.0;
  Tr[2][0]=0.0;
  Ti[2][0]=0.0;
  Tr[2][1]=0.0;
  Ti[2][1]=0.0;
  Tr[2][2]=mv;
  Ti[2][2]=0.0;
}

Fixed version (ground truth):
/** 
 * Reconstruct full pol coherency matrix T3 using compact pol data. The random volume over ground (RVOG) model is assumed.
 * @param sourceProductType The compact pol source product type
 * @param idx Pixel index in source product
 * @param dataBuffers Source band data buffers
 * @param Tr Real part of the reconstructed T3 matrix
 * @param Ti Imaginary part of the reconstructed T3 matrix
 */
public static void reconstructCoherencyMatrixT3(final PolBandUtils.MATRIX sourceProductType,final int idx,final ProductData[] dataBuffers,final double[][] Tr,final double[][] Ti){
  final double[][] Cr=new double[2][2];
  final double[][] Ci=new double[2][2];
  final double[] kr=new double[2];
  final double[] ki=new double[2];
  final double[] g=new double[4];
  if (sourceProductType == PolBandUtils.MATRIX.C2) {
    getCovarianceMatrixC2(idx,dataBuffers,Cr,Ci);
    computeCompactPolStokesVector(Cr,Ci,g);
  }
 else   if (sourceProductType == PolBandUtils.MATRIX.COMPACT) {
    getCompactPolScatterVector(idx,dataBuffers,kr,ki);
    computeCompactPolStokesVector(kr,ki,g);
  }
  if (g[0] <= 0 || g[3] == 0) {
    return;
  }
  final double m=Math.sqrt(g[1] * g[1] + g[2] * g[2] + g[3] * g[3]) / g[0];
  final double mv=0.5 * g[0] * (1 - m);
  final double ms=2.0 * g[0] * m;
  final double alpha=0.5 * Math.atan(Math.sqrt(g[1] * g[1] + g[2] * g[2]) / (-g[3]));
  final double phi=Math.acos(g[1] / Math.sqrt(g[1] * g[1] + g[2] * g[2]));
  final double cosAlpha=Math.cos(alpha);
  final double sinAlpha=Math.sin(alpha);
  final double cosPhi=Math.cos(phi);
  final double sinPhi=Math.sin(phi);
  Tr[0][0]=ms * cosAlpha * cosAlpha + 2.0 * mv;
  Ti[0][0]=0.0;
  Tr[0][1]=ms * cosAlpha * sinAlpha* cosPhi;
  Ti[0][1]=ms * cosAlpha * sinAlpha* sinPhi;
  Tr[0][2]=0.0;
  Ti[0][2]=0.0;
  Tr[1][0]=Tr[0][1];
  Ti[1][0]=-Ti[0][1];
  Tr[1][1]=ms * sinAlpha * sinAlpha + mv;
  Ti[1][1]=0.0;
  Tr[1][2]=0.0;
  Ti[1][2]=0.0;
  Tr[2][0]=0.0;
  Ti[2][0]=0.0;
  Tr[2][1]=0.0;
  Ti[2][1]=0.0;
  Tr[2][2]=mv;
  Ti[2][2]=0.0;
}