Program: 57277
Project: 57277
Buggy source:
/** 
 * Perform a double QR step involving rows l:idx and columns m:n
 * @param l the index of the small sub-diagonal element
 * @param m the start index for the QR step
 * @param idx the current eigenvalue index
 * @param shift shift information holder
 * @param hVec the initial houseHolder vector
 */
private void performDoubleQRStep(final int l,final int m,final int idx,final ShiftInfo shift,final double[] hVec){
  final int n=matrixT.length;
  double p=hVec[0];
  double q=hVec[1];
  double r=hVec[2];
  for (int k=m; k <= idx - 1; k++) {
    boolean notlast=k != idx - 1;
    if (k != m) {
      p=matrixT[k][k - 1];
      q=matrixT[k + 1][k - 1];
      r=notlast ? matrixT[k + 2][k - 1] : 0.0;
      shift.x=FastMath.abs(p) + FastMath.abs(q) + FastMath.abs(r);
      if (!Precision.equals(shift.x,0.0,epsilon)) {
        p=p / shift.x;
        q=q / shift.x;
        r=r / shift.x;
      }
    }
    if (Precision.equals(shift.x,0.0,epsilon)) {
      break;
    }
    double s=FastMath.sqrt(p * p + q * q + r * r);
    if (Precision.compareTo(p,0.0,epsilon) < 0) {
      s=-s;
    }
    if (!Precision.equals(s,0.0,epsilon)) {
      if (k != m) {
        matrixT[k][k - 1]=-s * shift.x;
      }
 else       if (l != m) {
        matrixT[k][k - 1]=-matrixT[k][k - 1];
      }
      p=p + s;
      shift.x=p / s;
      shift.y=q / s;
      double z=r / s;
      q=q / p;
      r=r / p;
      for (int j=k; j < n; j++) {
        p=matrixT[k][j] + q * matrixT[k + 1][j];
        if (notlast) {
          p=p + r * matrixT[k + 2][j];
          matrixT[k + 2][j]=matrixT[k + 2][j] - p * z;
        }
        matrixT[k][j]=matrixT[k][j] - p * shift.x;
        matrixT[k + 1][j]=matrixT[k + 1][j] - p * shift.y;
      }
      for (int i=0; i <= FastMath.min(idx,k + 3); i++) {
        p=shift.x * matrixT[i][k] + shift.y * matrixT[i][k + 1];
        if (notlast) {
          p=p + z * matrixT[i][k + 2];
          matrixT[i][k + 2]=matrixT[i][k + 2] - p * r;
        }
        matrixT[i][k]=matrixT[i][k] - p;
        matrixT[i][k + 1]=matrixT[i][k + 1] - p * q;
      }
      final int high=matrixT.length - 1;
      for (int i=0; i <= high; i++) {
        p=shift.x * matrixP[i][k] + shift.y * matrixP[i][k + 1];
        if (notlast) {
          p=p + z * matrixP[i][k + 2];
          matrixP[i][k + 2]=matrixP[i][k + 2] - p * r;
        }
        matrixP[i][k]=matrixP[i][k] - p;
        matrixP[i][k + 1]=matrixP[i][k + 1] - p * q;
      }
    }
  }
  for (int i=m + 2; i <= idx; i++) {
    matrixT[i][i - 2]=0.0;
    if (i > m + 2) {
      matrixT[i][i - 3]=0.0;
    }
  }
}

Fixed version (ground truth):
/** 
 * Perform a double QR step involving rows l:idx and columns m:n
 * @param l the index of the small sub-diagonal element
 * @param m the start index for the QR step
 * @param idx the current eigenvalue index
 * @param shift shift information holder
 * @param hVec the initial houseHolder vector
 */
private void performDoubleQRStep(final int l,final int m,final int idx,final ShiftInfo shift,final double[] hVec){
  final int n=matrixT.length;
  double p=hVec[0];
  double q=hVec[1];
  double r=hVec[2];
  for (int k=m; k <= idx - 1; k++) {
    boolean notlast=k != idx - 1;
    if (k != m) {
      p=matrixT[k][k - 1];
      q=matrixT[k + 1][k - 1];
      r=notlast ? matrixT[k + 2][k - 1] : 0.0;
      shift.x=FastMath.abs(p) + FastMath.abs(q) + FastMath.abs(r);
      if (!Precision.equals(shift.x,0.0,epsilon)) {
        p=p / shift.x;
        q=q / shift.x;
        r=r / shift.x;
      }
    }
    if (Precision.equals(shift.x,0.0,epsilon)) {
      break;
    }
    double s=FastMath.sqrt(p * p + q * q + r * r);
    if (p < 0.0) {
      s=-s;
    }
    if (!Precision.equals(s,0.0,epsilon)) {
      if (k != m) {
        matrixT[k][k - 1]=-s * shift.x;
      }
 else       if (l != m) {
        matrixT[k][k - 1]=-matrixT[k][k - 1];
      }
      p=p + s;
      shift.x=p / s;
      shift.y=q / s;
      double z=r / s;
      q=q / p;
      r=r / p;
      for (int j=k; j < n; j++) {
        p=matrixT[k][j] + q * matrixT[k + 1][j];
        if (notlast) {
          p=p + r * matrixT[k + 2][j];
          matrixT[k + 2][j]=matrixT[k + 2][j] - p * z;
        }
        matrixT[k][j]=matrixT[k][j] - p * shift.x;
        matrixT[k + 1][j]=matrixT[k + 1][j] - p * shift.y;
      }
      for (int i=0; i <= FastMath.min(idx,k + 3); i++) {
        p=shift.x * matrixT[i][k] + shift.y * matrixT[i][k + 1];
        if (notlast) {
          p=p + z * matrixT[i][k + 2];
          matrixT[i][k + 2]=matrixT[i][k + 2] - p * r;
        }
        matrixT[i][k]=matrixT[i][k] - p;
        matrixT[i][k + 1]=matrixT[i][k + 1] - p * q;
      }
      final int high=matrixT.length - 1;
      for (int i=0; i <= high; i++) {
        p=shift.x * matrixP[i][k] + shift.y * matrixP[i][k + 1];
        if (notlast) {
          p=p + z * matrixP[i][k + 2];
          matrixP[i][k + 2]=matrixP[i][k + 2] - p * r;
        }
        matrixP[i][k]=matrixP[i][k] - p;
        matrixP[i][k + 1]=matrixP[i][k + 1] - p * q;
      }
    }
  }
  for (int i=m + 2; i <= idx; i++) {
    matrixT[i][i - 2]=0.0;
    if (i > m + 2) {
      matrixT[i][i - 3]=0.0;
    }
  }
}