Program: 57428
Project: 57428
Buggy source:
/** 
 * Perform one "good" dqd/dqds step. <p>This implementation is based on Beresford N. Parlett and Osni A. Marques paper <a href="http://www.netlib.org/lapack/lawnspdf/lawn155.pdf">An Implementation of the dqds Algorithm (Positive Case)</a> and on the corresponding LAPACK routine DLAZQ3.</p>
 * @param start start index
 * @param end end index
 * @return new end (maybe deflated)
 */
private int goodStep(final int start,final int end){
  g=0.0;
  int deflatedEnd=end;
  for (boolean deflating=true; deflating; ) {
    if (start >= deflatedEnd) {
      return deflatedEnd;
    }
    final int k=4 * deflatedEnd + pingPong - 1;
    if ((start == deflatedEnd - 1) || ((start != deflatedEnd - 2) && ((work[k - 5] <= TOLERANCE_2 * (sigma + work[k - 3])) || (work[k - 2 * pingPong - 4] <= TOLERANCE_2 * work[k - 7])))) {
      work[4 * deflatedEnd - 4]=sigma + work[4 * deflatedEnd - 4 + pingPong];
      deflatedEnd-=1;
    }
 else     if ((start == deflatedEnd - 2) || (work[k - 9] <= TOLERANCE_2 * sigma) || (work[k - 2 * pingPong - 8] <= TOLERANCE_2 * work[k - 11])) {
      if (work[k - 3] > work[k - 7]) {
        final double tmp=work[k - 3];
        work[k - 3]=work[k - 7];
        work[k - 7]=tmp;
      }
      if (work[k - 5] > TOLERANCE_2 * work[k - 3]) {
        double t=0.5 * ((work[k - 7] - work[k - 3]) + work[k - 5]);
        double s=work[k - 3] * (work[k - 5] / t);
        if (s <= t) {
          s=work[k - 3] * work[k - 5] / (t * (1 + Math.sqrt(1 + s / t)));
        }
 else {
          s=work[k - 3] * work[k - 5] / (t + Math.sqrt(t * (t + s)));
        }
        t=work[k - 7] + (s + work[k - 5]);
        work[k - 3]*=work[k - 7] / t;
        work[k - 7]=t;
      }
      work[4 * deflatedEnd - 8]=sigma + work[k - 7];
      work[4 * deflatedEnd - 4]=sigma + work[k - 3];
      deflatedEnd-=2;
    }
 else {
      deflating=false;
    }
  }
  final int l=4 * deflatedEnd + pingPong - 1;
  if ((dMin <= 0) || (deflatedEnd < end)) {
    if (flipIfWarranted(deflatedEnd,1)) {
      dMin2=Math.min(dMin2,work[l - 1]);
      work[l - 1]=Math.min(work[l - 1],Math.min(work[3 + pingPong],work[7 + pingPong]));
      work[l - 2 * pingPong]=Math.min(work[l - 2 * pingPong],Math.min(work[6 + pingPong],work[6 + pingPong]));
      qMax=Math.max(qMax,Math.max(work[3 + pingPong],work[7 + pingPong]));
      dMin=-0.0;
    }
  }
  if ((dMin < 0) || (MathUtils.SAFE_MIN * qMax < Math.min(work[l - 1],Math.min(work[l - 9],dMin2 + work[l - 2 * pingPong])))) {
    computeShiftIncrement(start,deflatedEnd,end - deflatedEnd);
    for (boolean loop=true; loop; ) {
      dqds(start,deflatedEnd);
      if ((dMin >= 0) && (dMin1 > 0)) {
        updateSigma(tau);
        return deflatedEnd;
      }
 else       if ((dMin < 0.0) && (dMin1 > 0.0) && (work[4 * deflatedEnd - 5 - pingPong] < TOLERANCE * (sigma + dN1))&& (Math.abs(dN) < TOLERANCE * sigma)) {
        work[4 * deflatedEnd - 3 - pingPong]=0.0;
        dMin=0.0;
        updateSigma(tau);
        return deflatedEnd;
      }
 else       if (dMin < 0.0) {
        if (tType < -22) {
          tau=0.0;
        }
 else         if (dMin1 > 0.0) {
          tau=(tau + dMin) * (1.0 - 2.0 * MathUtils.EPSILON);
          tType-=11;
        }
 else {
          tau*=0.25;
          tType-=12;
        }
      }
 else       if (Double.isNaN(dMin)) {
        tau=0.0;
      }
 else {
        loop=false;
      }
    }
  }
  dqd(start,deflatedEnd);
  return deflatedEnd;
}

Fixed version (ground truth):
/** 
 * Perform one "good" dqd/dqds step. <p>This implementation is based on Beresford N. Parlett and Osni A. Marques paper <a href="http://www.netlib.org/lapack/lawnspdf/lawn155.pdf">An Implementation of the dqds Algorithm (Positive Case)</a> and on the corresponding LAPACK routine DLAZQ3.</p>
 * @param start start index
 * @param end end index
 * @return new end (maybe deflated)
 */
private int goodStep(final int start,final int end){
  g=0.0;
  int deflatedEnd=end;
  for (boolean deflating=true; deflating; ) {
    if (start >= deflatedEnd) {
      return deflatedEnd;
    }
    final int k=4 * deflatedEnd + pingPong - 1;
    if ((start == deflatedEnd - 1) || ((start != deflatedEnd - 2) && ((work[k - 5] <= TOLERANCE_2 * (sigma + work[k - 3])) || (work[k - 2 * pingPong - 4] <= TOLERANCE_2 * work[k - 7])))) {
      work[4 * deflatedEnd - 4]=sigma + work[4 * deflatedEnd - 4 + pingPong];
      deflatedEnd-=1;
    }
 else     if ((start == deflatedEnd - 2) || (work[k - 9] <= TOLERANCE_2 * sigma) || (work[k - 2 * pingPong - 8] <= TOLERANCE_2 * work[k - 11])) {
      if (work[k - 3] > work[k - 7]) {
        final double tmp=work[k - 3];
        work[k - 3]=work[k - 7];
        work[k - 7]=tmp;
      }
      if (work[k - 5] > TOLERANCE_2 * work[k - 3]) {
        double t=0.5 * ((work[k - 7] - work[k - 3]) + work[k - 5]);
        double s=work[k - 3] * (work[k - 5] / t);
        if (s <= t) {
          s=work[k - 3] * work[k - 5] / (t * (1 + Math.sqrt(1 + s / t)));
        }
 else {
          s=work[k - 3] * work[k - 5] / (t + Math.sqrt(t * (t + s)));
        }
        t=work[k - 7] + (s + work[k - 5]);
        work[k - 3]*=work[k - 7] / t;
        work[k - 7]=t;
      }
      work[4 * deflatedEnd - 8]=sigma + work[k - 7];
      work[4 * deflatedEnd - 4]=sigma + work[k - 3];
      deflatedEnd-=2;
    }
 else {
      deflating=false;
    }
  }
  final int l=4 * deflatedEnd + pingPong - 1;
  if ((dMin <= 0) || (deflatedEnd < end)) {
    if (flipAllIfWarranted(deflatedEnd)) {
      dMin2=Math.min(dMin2,work[l - 1]);
      work[l - 1]=Math.min(work[l - 1],Math.min(work[3 + pingPong],work[7 + pingPong]));
      work[l - 2 * pingPong]=Math.min(work[l - 2 * pingPong],Math.min(work[6 + pingPong],work[6 + pingPong]));
      qMax=Math.max(qMax,Math.max(work[3 + pingPong],work[7 + pingPong]));
      dMin=-0.0;
    }
  }
  if ((dMin < 0) || (MathUtils.SAFE_MIN * qMax < Math.min(work[l - 1],Math.min(work[l - 9],dMin2 + work[l - 2 * pingPong])))) {
    computeShiftIncrement(start,deflatedEnd,end - deflatedEnd);
    for (boolean loop=true; loop; ) {
      dqds(start,deflatedEnd);
      if ((dMin >= 0) && (dMin1 > 0)) {
        updateSigma(tau);
        return deflatedEnd;
      }
 else       if ((dMin < 0.0) && (dMin1 > 0.0) && (work[4 * deflatedEnd - 5 - pingPong] < TOLERANCE * (sigma + dN1))&& (Math.abs(dN) < TOLERANCE * sigma)) {
        work[4 * deflatedEnd - 3 - pingPong]=0.0;
        dMin=0.0;
        updateSigma(tau);
        return deflatedEnd;
      }
 else       if (dMin < 0.0) {
        if (tType < -22) {
          tau=0.0;
        }
 else         if (dMin1 > 0.0) {
          tau=(tau + dMin) * (1.0 - 2.0 * MathUtils.EPSILON);
          tType-=11;
        }
 else {
          tau*=0.25;
          tType-=12;
        }
      }
 else       if (Double.isNaN(dMin)) {
        tau=0.0;
      }
 else {
        loop=false;
      }
    }
  }
  dqd(start,deflatedEnd);
  return deflatedEnd;
}