Program: 57276
Project: 57276
Buggy source:
/** 
 * Transform original matrix to Schur form.
 * @throws MaxCountExceededException if the transformation does not converge
 */
private void transform(){
  final int n=matrixT.length;
  final double norm=getNorm();
  final ShiftInfo shift=new ShiftInfo();
  int iteration=0;
  int idx=n - 1;
  while (idx >= 0) {
    final int l=findSmallSubDiagonalElement(idx,norm);
    if (l == idx) {
      matrixT[idx][idx]=matrixT[idx][idx] + shift.exShift;
      idx--;
      iteration=0;
    }
 else     if (l == idx - 1) {
      shift.w=matrixT[idx][idx - 1] * matrixT[idx - 1][idx];
      double p=(matrixT[idx - 1][idx - 1] - matrixT[idx][idx]) / 2.0;
      double q=p * p + shift.w;
      double z=FastMath.sqrt(FastMath.abs(q));
      matrixT[idx][idx]=matrixT[idx][idx] + shift.exShift;
      matrixT[idx - 1][idx - 1]=matrixT[idx - 1][idx - 1] + shift.exShift;
      shift.x=matrixT[idx][idx];
      if (q >= 0) {
        if (p >= 0) {
          z=p + z;
        }
 else {
          z=p - z;
        }
        shift.x=matrixT[idx][idx - 1];
        double s=FastMath.abs(shift.x) + FastMath.abs(z);
        p=shift.x / s;
        q=z / s;
        double r=FastMath.sqrt(p * p + q * q);
        p=p / r;
        q=q / r;
        for (int j=idx - 1; j < n; j++) {
          z=matrixT[idx - 1][j];
          matrixT[idx - 1][j]=q * z + p * matrixT[idx][j];
          matrixT[idx][j]=q * matrixT[idx][j] - p * z;
        }
        for (int i=0; i <= idx; i++) {
          z=matrixT[i][idx - 1];
          matrixT[i][idx - 1]=q * z + p * matrixT[i][idx];
          matrixT[i][idx]=q * matrixT[i][idx] - p * z;
        }
        for (int i=0; i <= n - 1; i++) {
          z=matrixP[i][idx - 1];
          matrixP[i][idx - 1]=q * z + p * matrixP[i][idx];
          matrixP[i][idx]=q * matrixP[i][idx] - p * z;
        }
      }
      idx-=2;
      iteration=0;
    }
 else {
      computeShift(l,idx,iteration,shift);
      if (++iteration > maxIterations) {
        throw new MaxCountExceededException(LocalizedFormats.CONVERGENCE_FAILED,maxIterations);
      }
      int m=idx - 2;
      final double[] hVec=new double[3];
      while (m >= l) {
        double z=matrixT[m][m];
        hVec[2]=shift.x - z;
        double s=shift.y - z;
        hVec[0]=(hVec[2] * s - shift.w) / matrixT[m + 1][m] + matrixT[m][m + 1];
        hVec[1]=matrixT[m + 1][m + 1] - z - hVec[2]- s;
        hVec[2]=matrixT[m + 2][m + 1];
        s=FastMath.abs(hVec[0]) + FastMath.abs(hVec[1]) + FastMath.abs(hVec[2]);
        if (m == l) {
          break;
        }
        for (int i=0; i < hVec.length; i++) {
          hVec[i]/=s;
        }
        final double lhs=FastMath.abs(matrixT[m][m - 1]) * (FastMath.abs(hVec[1]) + FastMath.abs(hVec[2]));
        final double rhs=FastMath.abs(hVec[0]) * (FastMath.abs(matrixT[m - 1][m - 1]) + FastMath.abs(z) + FastMath.abs(matrixT[m + 1][m + 1]));
        if (lhs < epsilon * rhs) {
          break;
        }
        m--;
      }
      performDoubleQRStep(l,m,idx,shift,hVec);
    }
  }
}

Fixed version (ground truth):
/** 
 * Transform original matrix to Schur form.
 * @throws MaxCountExceededException if the transformation does not converge
 */
private void transform(){
  final int n=matrixT.length;
  final double norm=getNorm();
  final ShiftInfo shift=new ShiftInfo();
  int iteration=0;
  int idx=n - 1;
  while (idx >= 0) {
    final int l=findSmallSubDiagonalElement(idx,norm);
    if (l == idx) {
      matrixT[idx][idx]=matrixT[idx][idx] + shift.exShift;
      idx--;
      iteration=0;
    }
 else     if (l == idx - 1) {
      shift.w=matrixT[idx][idx - 1] * matrixT[idx - 1][idx];
      double p=(matrixT[idx - 1][idx - 1] - matrixT[idx][idx]) / 2.0;
      double q=p * p + shift.w;
      double z=FastMath.sqrt(FastMath.abs(q));
      matrixT[idx][idx]=matrixT[idx][idx] + shift.exShift;
      matrixT[idx - 1][idx - 1]=matrixT[idx - 1][idx - 1] + shift.exShift;
      shift.x=matrixT[idx][idx];
      if (q >= 0) {
        if (p >= 0) {
          z=p + z;
        }
 else {
          z=p - z;
        }
        shift.x=matrixT[idx][idx - 1];
        double s=FastMath.abs(shift.x) + FastMath.abs(z);
        p=shift.x / s;
        q=z / s;
        double r=FastMath.sqrt(p * p + q * q);
        p=p / r;
        q=q / r;
        for (int j=idx - 1; j < n; j++) {
          z=matrixT[idx - 1][j];
          matrixT[idx - 1][j]=q * z + p * matrixT[idx][j];
          matrixT[idx][j]=q * matrixT[idx][j] - p * z;
        }
        for (int i=0; i <= idx; i++) {
          z=matrixT[i][idx - 1];
          matrixT[i][idx - 1]=q * z + p * matrixT[i][idx];
          matrixT[i][idx]=q * matrixT[i][idx] - p * z;
        }
        for (int i=0; i <= n - 1; i++) {
          z=matrixP[i][idx - 1];
          matrixP[i][idx - 1]=q * z + p * matrixP[i][idx];
          matrixP[i][idx]=q * matrixP[i][idx] - p * z;
        }
      }
      idx-=2;
      iteration=0;
    }
 else {
      computeShift(l,idx,iteration,shift);
      if (++iteration > MAX_ITERATIONS) {
        throw new MaxCountExceededException(LocalizedFormats.CONVERGENCE_FAILED,MAX_ITERATIONS);
      }
      int m=idx - 2;
      final double[] hVec=new double[3];
      while (m >= l) {
        double z=matrixT[m][m];
        hVec[2]=shift.x - z;
        double s=shift.y - z;
        hVec[0]=(hVec[2] * s - shift.w) / matrixT[m + 1][m] + matrixT[m][m + 1];
        hVec[1]=matrixT[m + 1][m + 1] - z - hVec[2]- s;
        hVec[2]=matrixT[m + 2][m + 1];
        s=FastMath.abs(hVec[0]) + FastMath.abs(hVec[1]) + FastMath.abs(hVec[2]);
        if (m == l) {
          break;
        }
        for (int i=0; i < hVec.length; i++) {
          hVec[i]/=s;
        }
        final double lhs=FastMath.abs(matrixT[m][m - 1]) * (FastMath.abs(hVec[1]) + FastMath.abs(hVec[2]));
        final double rhs=FastMath.abs(hVec[0]) * (FastMath.abs(matrixT[m - 1][m - 1]) + FastMath.abs(z) + FastMath.abs(matrixT[m + 1][m + 1]));
        if (lhs < epsilon * rhs) {
          break;
        }
        m--;
      }
      performDoubleQRStep(l,m,idx,shift,hVec);
    }
  }
}