nus-yam/ex-repair huggingface dataset:
Program: 57272
Project: 57272
Buggy source:
/** 
 * Gets the block diagonal matrix D of the decomposition. D is a block diagonal matrix. Real eigenvalues are on the diagonal while complex values are on 2x2 blocks { {real +imaginary}, {-imaginary, real} }.
 * @return the D matrix.
 * @see #getRealEigenvalues()
 * @see #getImagEigenvalues()
 */
public RealMatrix getD(){
  if (cachedD == null) {
    cachedD=MatrixUtils.createRealDiagonalMatrix(realEigenvalues);
    for (int i=0; i < imagEigenvalues.length; i++) {
      if (Precision.compareTo(imagEigenvalues[i],0.0,epsilon) > 0) {
        cachedD.setEntry(i,i + 1,imagEigenvalues[i]);
      }
 else       if (Precision.compareTo(imagEigenvalues[i],0.0,epsilon) < 0) {
        cachedD.setEntry(i,i - 1,imagEigenvalues[i]);
      }
    }
  }
  return cachedD;
}

Fixed version (ground truth):
/** 
 * Gets the block diagonal matrix D of the decomposition. D is a block diagonal matrix. Real eigenvalues are on the diagonal while complex values are on 2x2 blocks { {real +imaginary}, {-imaginary, real} }.
 * @return the D matrix.
 * @see #getRealEigenvalues()
 * @see #getImagEigenvalues()
 */
public RealMatrix getD(){
  if (cachedD == null) {
    cachedD=MatrixUtils.createRealDiagonalMatrix(realEigenvalues);
    for (int i=0; i < imagEigenvalues.length; i++) {
      if (Precision.compareTo(imagEigenvalues[i],0.0,EPSILON) > 0) {
        cachedD.setEntry(i,i + 1,imagEigenvalues[i]);
      }
 else       if (Precision.compareTo(imagEigenvalues[i],0.0,EPSILON) < 0) {
        cachedD.setEntry(i,i - 1,imagEigenvalues[i]);
      }
    }
  }
  return cachedD;
}
Program: 57273
Project: 57273
Buggy source:
/** 
 * Raise a double to an int power.
 * @param d Number to raise.
 * @param e Exponent.
 * @return d<sup>e</sup>
 */
public static double pow(double d,int e){
  if (e == 0) {
    return 1.0;
  }
 else   if (e < 0) {
    e=-e;
    d=1.0 / d;
  }
  double result=1;
  double d2p=d;
  while (e != 0) {
    if ((e & 0x1) != 0) {
      result*=d2p;
    }
    d2p*=d2p;
    e=e >> 1;
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Raise a double to an int power.
 * @param d Number to raise.
 * @param e Exponent.
 * @return d<sup>e</sup>
 */
public static double pow(double d,int e){
  if (e == 0) {
    return 1.0;
  }
 else   if (e < 0) {
    e=-e;
    d=1.0 / d;
  }
  final int splitFactor=0x8000001;
  final double cd=splitFactor * d;
  final double d1High=cd - (cd - d);
  final double d1Low=d - d1High;
  double resultHigh=1;
  double resultLow=0;
  double d2p=d;
  double d2pHigh=d1High;
  double d2pLow=d1Low;
  while (e != 0) {
    if ((e & 0x1) != 0) {
      final double tmpHigh=resultHigh * d2p;
      final double cRH=splitFactor * resultHigh;
      final double rHH=cRH - (cRH - resultHigh);
      final double rHL=resultHigh - rHH;
      final double tmpLow=rHL * d2pLow - (((tmpHigh - rHH * d2pHigh) - rHL * d2pHigh) - rHH * d2pLow);
      resultHigh=tmpHigh;
      resultLow=resultLow * d2p + tmpLow;
    }
    final double tmpHigh=d2pHigh * d2p;
    final double cD2pH=splitFactor * d2pHigh;
    final double d2pHH=cD2pH - (cD2pH - d2pHigh);
    final double d2pHL=d2pHigh - d2pHH;
    final double tmpLow=d2pHL * d2pLow - (((tmpHigh - d2pHH * d2pHigh) - d2pHL * d2pHigh) - d2pHH * d2pLow);
    final double cTmpH=splitFactor * tmpHigh;
    d2pHigh=cTmpH - (cTmpH - tmpHigh);
    d2pLow=d2pLow * d2p + tmpLow + (tmpHigh - d2pHigh);
    d2p=d2pHigh + d2pLow;
    e=e >> 1;
  }
  return resultHigh + resultLow;
}
Program: 57274
Project: 57274
Buggy source:
@Test public void testIntPow(){
  final double base=1.23456789;
  final int maxExp=300;
  for (int i=0; i < maxExp; i++) {
    final double expected=FastMath.pow(base,(double)i);
    Assert.assertEquals("String_Node_Str" + i,expected,FastMath.pow(base,i),60 * Math.ulp(expected));
  }
}

Fixed version (ground truth):
@Test public void testIntPow(){
  final int maxExp=300;
  DfpField field=new DfpField(40);
  final double base=1.23456789;
  Dfp baseDfp=field.newDfp(base);
  Dfp dfpPower=field.getOne();
  for (int i=0; i < maxExp; i++) {
    Assert.assertEquals("String_Node_Str" + i,dfpPower.toDouble(),FastMath.pow(base,i),0.6 * FastMath.ulp(dfpPower.toDouble()));
    dfpPower=dfpPower.multiply(baseDfp);
  }
}
Program: 57278
Project: 57278
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public double dotProduct(RealVector v){
  if (v instanceof ArrayRealVector) {
    final double[] vData=((ArrayRealVector)v).data;
    checkVectorDimensions(vData.length);
    double dot=0;
    for (int i=0; i < data.length; i++) {
      dot+=data[i] * vData[i];
    }
    return dot;
  }
 else {
    checkVectorDimensions(v);
    double dot=0;
    Iterator<Entry> it=v.sparseIterator();
    while (it.hasNext()) {
      final Entry e=it.next();
      dot+=data[e.getIndex()] * e.getValue();
    }
    return dot;
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public double dotProduct(RealVector v){
  if (v instanceof ArrayRealVector) {
    final double[] vData=((ArrayRealVector)v).data;
    checkVectorDimensions(vData.length);
    double dot=0;
    for (int i=0; i < data.length; i++) {
      dot+=data[i] * vData[i];
    }
    return dot;
  }
  return super.dotProduct(v);
}
Program: 57279
Project: 57279
Buggy source:
/** 
 * @param Umin smallest Mann-Whitney U value
 * @param n1 number of subjects in first sample
 * @param n2 number of subjects in second sample
 * @return two-sided asymptotic p-value
 * @throws ConvergenceException if the p-value can not be computeddue to a convergence error
 * @throws MaxCountExceededException if the maximum number ofiterations is exceeded
 */
private double calculateAsymptoticPValue(final double Umin,final int n1,final int n2) throws ConvergenceException, MaxCountExceededException {
  final double n1n2prod=n1 * n2;
  final double EU=n1n2prod / 2.0;
  final double VarU=n1n2prod * (n1 + n2 + 1) / 12.0;
  final double z=(Umin - EU) / FastMath.sqrt(VarU);
  final NormalDistribution standardNormal=new NormalDistribution(0,1);
  return 2 * standardNormal.cumulativeProbability(z);
}

Fixed version (ground truth):
/** 
 * @param Umin smallest Mann-Whitney U value
 * @param n1 number of subjects in first sample
 * @param n2 number of subjects in second sample
 * @return two-sided asymptotic p-value
 * @throws ConvergenceException if the p-value can not be computeddue to a convergence error
 * @throws MaxCountExceededException if the maximum number ofiterations is exceeded
 */
private double calculateAsymptoticPValue(final double Umin,final int n1,final int n2) throws ConvergenceException, MaxCountExceededException {
  final long n1n2prod=(long)n1 * n2;
  final double EU=n1n2prod / 2.0;
  final double VarU=n1n2prod * (n1 + n2 + 1) / 12.0;
  final double z=(Umin - EU) / FastMath.sqrt(VarU);
  final NormalDistribution standardNormal=new NormalDistribution(0,1);
  return 2 * standardNormal.cumulativeProbability(z);
}
Program: 57280
Project: 57280
Buggy source:
/** 
 * @param Umin smallest Mann-Whitney U value
 * @param n1 number of subjects in first sample
 * @param n2 number of subjects in second sample
 * @return two-sided asymptotic p-value
 * @throws ConvergenceException if the p-value can not be computeddue to a convergence error
 * @throws MaxCountExceededException if the maximum number ofiterations is exceeded
 */
private double calculateAsymptoticPValue(final double Umin,final int n1,final int n2) throws ConvergenceException, MaxCountExceededException {
  final int n1n2prod=n1 * n2;
  final double EU=(double)n1n2prod / 2.0;
  final double VarU=(double)(n1n2prod * (n1 + n2 + 1)) / 12.0;
  final double z=(Umin - EU) / FastMath.sqrt(VarU);
  final NormalDistribution standardNormal=new NormalDistribution(0,1);
  return 2 * standardNormal.cumulativeProbability(z);
}

Fixed version (ground truth):
/** 
 * @param Umin smallest Mann-Whitney U value
 * @param n1 number of subjects in first sample
 * @param n2 number of subjects in second sample
 * @return two-sided asymptotic p-value
 * @throws ConvergenceException if the p-value can not be computeddue to a convergence error
 * @throws MaxCountExceededException if the maximum number ofiterations is exceeded
 */
private double calculateAsymptoticPValue(final double Umin,final int n1,final int n2) throws ConvergenceException, MaxCountExceededException {
  final double n1n2prod=n1 * n2;
  final double EU=n1n2prod / 2.0;
  final double VarU=n1n2prod * (n1 + n2 + 1) / 12.0;
  final double z=(Umin - EU) / FastMath.sqrt(VarU);
  final NormalDistribution standardNormal=new NormalDistribution(0,1);
  return 2 * standardNormal.cumulativeProbability(z);
}
Program: 57281
Project: 57281
Buggy source:
/** 
 * {@inheritDoc} 
 */
public double cumulativeProbability(int x){
  double ret;
  if (x < 0) {
    ret=0.0;
  }
 else {
    ret=Beta.regularizedBeta(probabilityOfSuccess,numberOfSuccesses,x + 1);
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public double cumulativeProbability(int x){
  double ret;
  if (x < 0) {
    ret=0.0;
  }
 else {
    ret=Beta.regularizedBeta(probabilityOfSuccess,numberOfSuccesses,x + 1.0);
  }
  return ret;
}
Program: 57282
Project: 57282
Buggy source:
/** 
 * Simple constructor. Build a Gragg-Bulirsch-Stoer integrator with the given step bounds. All tuning parameters are set to their default values. The default step handler does nothing.
 * @param minStep minimal step (must be positive even for backwardintegration), the last step can be smaller than this
 * @param maxStep maximal step (must be positive even for backwardintegration)
 * @param vecAbsoluteTolerance allowed absolute error
 * @param vecRelativeTolerance allowed relative error
 */
public GraggBulirschStoerIntegrator(final double minStep,final double maxStep,final double[] vecAbsoluteTolerance,final double[] vecRelativeTolerance){
  super(METHOD_NAME,minStep,maxStep,vecAbsoluteTolerance,vecRelativeTolerance);
  setStabilityCheck(true,-1,-1,-1);
  setStepsizeControl(-1,-1,-1,-1);
  setOrderControl(-1,-1,-1);
  setInterpolationControl(true,-1);
}

Fixed version (ground truth):
/** 
 * Simple constructor. Build a Gragg-Bulirsch-Stoer integrator with the given step bounds. All tuning parameters are set to their default values. The default step handler does nothing.
 * @param minStep minimal step (must be positive even for backwardintegration), the last step can be smaller than this
 * @param maxStep maximal step (must be positive even for backwardintegration)
 * @param vecAbsoluteTolerance allowed absolute error
 * @param vecRelativeTolerance allowed relative error
 */
public GraggBulirschStoerIntegrator(final double minStep,final double maxStep,final double[] vecAbsoluteTolerance,final double[] vecRelativeTolerance){
  super(METHOD_NAME,minStep,maxStep,vecAbsoluteTolerance,vecRelativeTolerance);
  setStabilityCheck(true,-1,-1,-1);
  setControlFactors(-1,-1,-1,-1);
  setOrderControl(-1,-1,-1);
  setInterpolationControl(true,-1);
}
Program: 57283
Project: 57283
Buggy source:
@Test public void testIntegratorControls(){
  TestProblem3 pb=new TestProblem3(0.999);
  GraggBulirschStoerIntegrator integ=new GraggBulirschStoerIntegrator(0,pb.getFinalTime() - pb.getInitialTime(),1.0e-8,1.0e-10);
  double errorWithDefaultSettings=getMaxError(integ,pb);
  integ.setStabilityCheck(true,2,1,0.99);
  Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ,pb));
  integ.setStabilityCheck(true,-1,-1,-1);
  integ.setStepsizeControl(0.5,0.99,0.1,2.5);
  Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ,pb));
  integ.setStepsizeControl(-1,-1,-1,-1);
  integ.setOrderControl(10,0.7,0.95);
  Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ,pb));
  integ.setOrderControl(-1,-1,-1);
  integ.setInterpolationControl(true,3);
  Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ,pb));
  integ.setInterpolationControl(true,-1);
}

Fixed version (ground truth):
@Test public void testIntegratorControls(){
  TestProblem3 pb=new TestProblem3(0.999);
  GraggBulirschStoerIntegrator integ=new GraggBulirschStoerIntegrator(0,pb.getFinalTime() - pb.getInitialTime(),1.0e-8,1.0e-10);
  double errorWithDefaultSettings=getMaxError(integ,pb);
  integ.setStabilityCheck(true,2,1,0.99);
  Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ,pb));
  integ.setStabilityCheck(true,-1,-1,-1);
  integ.setControlFactors(0.5,0.99,0.1,2.5);
  Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ,pb));
  integ.setControlFactors(-1,-1,-1,-1);
  integ.setOrderControl(10,0.7,0.95);
  Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ,pb));
  integ.setOrderControl(-1,-1,-1);
  integ.setInterpolationControl(true,3);
  Assert.assertTrue(errorWithDefaultSettings < getMaxError(integ,pb));
  integ.setInterpolationControl(true,-1);
}
Program: 57284
Project: 57284
Buggy source:
/** 
 * Filter the integration step.
 * @param h signed step
 * @param forward forward integration indicator
 * @param acceptSmall if true, steps smaller than the minimal valueare silently increased up to this value, if false such small steps generate an exception
 * @return a bounded integration step (h if no bound is reach, or a bounded value)
 * @exception NumberIsTooSmallException if the step is too small and acceptSmall is false
 */
protected double filterStep(final double h,final boolean forward,final boolean acceptSmall) throws NumberIsTooSmallException {
  double filteredH=h;
  if (FastMath.abs(h) < minStep) {
    if (acceptSmall) {
      filteredH=forward ? minStep : -minStep;
    }
 else {
      throw new NumberIsTooSmallException(LocalizedFormats.MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION,minStep,FastMath.abs(h),true);
    }
  }
  if (filteredH > maxStep) {
    filteredH=maxStep;
  }
 else   if (filteredH < -maxStep) {
    filteredH=-maxStep;
  }
  return filteredH;
}

Fixed version (ground truth):
/** 
 * Filter the integration step.
 * @param h signed step
 * @param forward forward integration indicator
 * @param acceptSmall if true, steps smaller than the minimal valueare silently increased up to this value, if false such small steps generate an exception
 * @return a bounded integration step (h if no bound is reach, or a bounded value)
 * @exception NumberIsTooSmallException if the step is too small and acceptSmall is false
 */
protected double filterStep(final double h,final boolean forward,final boolean acceptSmall) throws NumberIsTooSmallException {
  double filteredH=h;
  if (FastMath.abs(h) < minStep) {
    if (acceptSmall) {
      filteredH=forward ? minStep : -minStep;
    }
 else {
      throw new NumberIsTooSmallException(LocalizedFormats.MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION,FastMath.abs(h),minStep,true);
    }
  }
  if (filteredH > maxStep) {
    filteredH=maxStep;
  }
 else   if (filteredH < -maxStep) {
    filteredH=-maxStep;
  }
  return filteredH;
}
Program: 57285
Project: 57285
Buggy source:
/** 
 * Generate a random int value uniformly distributed between <code>lower</code> and <code>upper</code>, inclusive. This algorithm uses a secure random number generator.
 * @param lower the lower bound.
 * @param upper the upper bound.
 * @return the random integer.
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public int nextSecureInt(int lower,int upper){
  if (lower >= upper) {
    throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,lower,upper,false);
  }
  SecureRandom sec=getSecRan();
  return lower + (int)(sec.nextDouble() * (upper - lower + 1));
}

Fixed version (ground truth):
/** 
 * Generate a random int value uniformly distributed between <code>lower</code> and <code>upper</code>, inclusive. This algorithm uses a secure random number generator.
 * @param lower the lower bound.
 * @param upper the upper bound.
 * @return the random integer.
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public int nextSecureInt(int lower,int upper){
  if (lower >= upper) {
    throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,lower,upper,false);
  }
  SecureRandom sec=getSecRan();
  double r=sec.nextDouble();
  double scaled=r * upper + (1.0 - r) * lower + r;
  return (int)FastMath.floor(scaled);
}
Program: 57286
Project: 57286
Buggy source:
/** 
 * Generate a random long value uniformly distributed between <code>lower</code> and <code>upper</code>, inclusive. This algorithm uses a secure random number generator.
 * @param lower the lower bound.
 * @param upper the upper bound.
 * @return the random integer.
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public long nextSecureLong(long lower,long upper){
  if (lower >= upper) {
    throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,lower,upper,false);
  }
  SecureRandom sec=getSecRan();
  return lower + (long)(sec.nextDouble() * (upper - lower + 1));
}

Fixed version (ground truth):
/** 
 * Generate a random long value uniformly distributed between <code>lower</code> and <code>upper</code>, inclusive. This algorithm uses a secure random number generator.
 * @param lower the lower bound.
 * @param upper the upper bound.
 * @return the random integer.
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public long nextSecureLong(long lower,long upper){
  if (lower >= upper) {
    throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,lower,upper,false);
  }
  SecureRandom sec=getSecRan();
  double r=sec.nextDouble();
  double scaled=r * upper + (1.0 - r) * lower + r;
  return (long)FastMath.floor(scaled);
}
Program: 57287
Project: 57287
Buggy source:
/** 
 * Generate a random int value uniformly distributed between <code>lower</code> and <code>upper</code>, inclusive.
 * @param lower the lower bound.
 * @param upper the upper bound.
 * @return the random integer.
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public int nextInt(int lower,int upper){
  if (lower >= upper) {
    throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,lower,upper,false);
  }
  double r=getRan().nextDouble();
  return (int)((r * upper) + ((1.0 - r) * lower) + r);
}

Fixed version (ground truth):
/** 
 * Generate a random int value uniformly distributed between <code>lower</code> and <code>upper</code>, inclusive.
 * @param lower the lower bound.
 * @param upper the upper bound.
 * @return the random integer.
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public int nextInt(int lower,int upper){
  if (lower >= upper) {
    throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,lower,upper,false);
  }
  double r=getRan().nextDouble();
  double scaled=r * upper + (1.0 - r) * lower + r;
  return (int)FastMath.floor(scaled);
}
Program: 57288
Project: 57288
Buggy source:
/** 
 * Generate a random long value uniformly distributed between <code>lower</code> and <code>upper</code>, inclusive.
 * @param lower the lower bound.
 * @param upper the upper bound.
 * @return the random integer.
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public long nextLong(long lower,long upper){
  if (lower >= upper) {
    throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,lower,upper,false);
  }
  double r=getRan().nextDouble();
  return (long)((r * upper) + ((1.0 - r) * lower) + r);
}

Fixed version (ground truth):
/** 
 * Generate a random long value uniformly distributed between <code>lower</code> and <code>upper</code>, inclusive.
 * @param lower the lower bound.
 * @param upper the upper bound.
 * @return the random integer.
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public long nextLong(long lower,long upper){
  if (lower >= upper) {
    throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,lower,upper,false);
  }
  double r=getRan().nextDouble();
  double scaled=r * upper + (1.0 - r) * lower + r;
  return (long)FastMath.floor(scaled);
}
Program: 57289
Project: 57289
Buggy source:
/** 
 * {@inheritDoc}<p> <strong>Algorithm Description</strong>: scales the output of Random.nextDouble(), but rejects 0 values (i.e., will generate another random double if Random.nextDouble() returns 0). This is necessary to provide a symmetric output interval (both endpoints excluded). </p>
 * @param lower the lower bound.
 * @param upper the upper bound.
 * @return a uniformly distributed random value from the interval (lower,upper)
 * @throws NumberIsTooLargeException if {@code lower >= upper}.
 */
public double nextUniform(double lower,double upper){
  if (lower >= upper) {
    throw new NumberIsTooLargeException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,lower,upper,false);
  }
  final RandomGenerator generator=getRan();
  double u=generator.nextDouble();
  while (u <= 0.0) {
    u=generator.nextDouble();
  }
  return lower + u * (upper - lower);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}<p> <strong>Algorithm Description</strong>: scales the output of Random.nextDouble(), but rejects 0 values (i.e., will generate another random double if Random.nextDouble() returns 0). This is necessary to provide a symmetric output interval (both endpoints excluded). </p>
 * @param lower the lower bound.
 * @param upper the upper bound.
 * @return a uniformly distributed random value from the interval (lower, upper)
 * @throws MathIllegalArgumentException if {@code lower >= upper}or either bound is infinite or NaN
 */
public double nextUniform(double lower,double upper){
  if (lower >= upper) {
    throw new MathIllegalArgumentException(LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,lower,upper);
  }
  if (Double.isInfinite(lower) || Double.isInfinite(upper)) {
    throw new MathIllegalArgumentException(LocalizedFormats.INFINITE_BOUND);
  }
  if (Double.isNaN(lower) || Double.isNaN(upper)) {
    throw new MathIllegalArgumentException(LocalizedFormats.NAN_NOT_ALLOWED);
  }
  final RandomGenerator generator=getRan();
  double u=generator.nextDouble();
  while (u <= 0.0) {
    u=generator.nextDouble();
  }
  return u * upper + (1.0 - u) * lower;
}
Program: 57290
Project: 57290
Buggy source:
/** 
 * Add a value to the data
 * @param value the value to add
 */
public void addValue(double value){
  sumImpl.increment(value);
  sumsqImpl.increment(value);
  minImpl.increment(value);
  maxImpl.increment(value);
  sumLogImpl.increment(value);
  secondMoment.increment(value);
  if (!(meanImpl instanceof Mean)) {
    meanImpl.increment(value);
  }
  if (!(varianceImpl instanceof Variance)) {
    varianceImpl.increment(value);
  }
  if (!(geoMeanImpl instanceof GeometricMean)) {
    geoMeanImpl.increment(value);
  }
  n++;
}

Fixed version (ground truth):
/** 
 * Add a value to the data
 * @param value the value to add
 */
public void addValue(double value){
  sumImpl.increment(value);
  sumsqImpl.increment(value);
  minImpl.increment(value);
  maxImpl.increment(value);
  sumLogImpl.increment(value);
  secondMoment.increment(value);
  if (meanImpl != mean) {
    meanImpl.increment(value);
  }
  if (varianceImpl != variance) {
    varianceImpl.increment(value);
  }
  if (geoMeanImpl != geoMean) {
    geoMeanImpl.increment(value);
  }
  n++;
}
Program: 57292
Project: 57292
Buggy source:
/** 
 * Returns the transpose of the matrix Q of the decomposition. <p>Q is an orthogonal matrix</p>
 * @return the Q matrix
 */
public RealMatrix getQT(){
  if (cachedQT == null) {
    final int n=qr[0].length;
    final int m=qr.length;
    cachedQT=MatrixUtils.createRealMatrix(m,m);
    for (int minor=m - 1; minor >= rank; minor--) {
      cachedQT.setEntry(minor,minor,1.0);
    }
    for (int minor=rank - 1; minor >= 0; minor--) {
      final int p_minor=permutation[minor];
      cachedQT.setEntry(minor,minor,1.0);
      for (int col=minor; col < m; col++) {
        double alpha=0.0;
        for (int row=minor; row < m; row++) {
          alpha-=cachedQT.getEntry(col,row) * qr[row][p_minor];
        }
        alpha/=rDiag[p_minor] * qr[minor][p_minor];
        for (int row=minor; row < m; row++) {
          cachedQT.addToEntry(col,row,-alpha * qr[row][p_minor]);
        }
      }
    }
  }
  return cachedQT;
}

Fixed version (ground truth):
/** 
 * Returns the transpose of the matrix Q of the decomposition. <p>Q is an orthogonal matrix</p>
 * @return the Q matrix
 */
public RealMatrix getQT(){
  if (cachedQT == null) {
    final int m=qr.length;
    cachedQT=MatrixUtils.createRealMatrix(m,m);
    for (int minor=m - 1; minor >= rank; minor--) {
      cachedQT.setEntry(minor,minor,1.0);
    }
    for (int minor=rank - 1; minor >= 0; minor--) {
      final int p_minor=permutation[minor];
      cachedQT.setEntry(minor,minor,1.0);
      for (int col=minor; col < m; col++) {
        double alpha=0.0;
        for (int row=minor; row < m; row++) {
          alpha-=cachedQT.getEntry(col,row) * qr[row][p_minor];
        }
        alpha/=rDiag[p_minor] * qr[minor][p_minor];
        for (int row=minor; row < m; row++) {
          cachedQT.addToEntry(col,row,-alpha * qr[row][p_minor]);
        }
      }
    }
  }
  return cachedQT;
}
Program: 57293
Project: 57293
Buggy source:
/** 
 * Returns the runtime class of the FieldElement. 
 * @return The {@code Class} object that represents the runtimeclass of this object.
 */
Class<? extends FieldElement<T>> getRuntimeClass();

Fixed version (ground truth):
/** 
 * Returns the runtime class of the FieldElement.
 * @return The {@code Class} object that represents the runtimeclass of this object.
 */
Class<? extends FieldElement<T>> getRuntimeClass();
Program: 57294
Project: 57294
Buggy source:
/** 
 * Prepare for computation. Subclasses must call this method if they override any of the  {@code solve} methods.
 * @param maxEval Maximum number of evaluations.
 * @param f the integrand function
 * @param min the min bound for the interval
 * @param max the upper bound for the interval
 * @throws NullArgumentException if {@code f} is {@code null}.
 * @throws MathIllegalArgumentException if {@code min >= max}.
 */
protected void setup(final int maxEval,final UnivariateRealFunction f,final double min,final double max) throws NullArgumentException, MathIllegalArgumentException {
  MathUtils.checkNotNull(f);
  UnivariateRealSolverUtils.verifyInterval(min,max);
  this.min=min;
  this.max=max;
  function=f;
  evaluations.setMaximalCount(maxEval);
  evaluations.resetCount();
  iterations.resetCount();
}

Fixed version (ground truth):
/** 
 * Prepare for computation. Subclasses must call this method if they override any of the  {@code solve} methods.
 * @param maxEval Maximum number of evaluations.
 * @param f the integrand function
 * @param lower the min bound for the interval
 * @param upper the upper bound for the interval
 * @throws NullArgumentException if {@code f} is {@code null}.
 * @throws MathIllegalArgumentException if {@code min >= max}.
 */
protected void setup(final int maxEval,final UnivariateRealFunction f,final double lower,final double upper) throws NullArgumentException, MathIllegalArgumentException {
  MathUtils.checkNotNull(f);
  UnivariateRealSolverUtils.verifyInterval(lower,upper);
  this.min=lower;
  this.max=upper;
  function=f;
  evaluations.setMaximalCount(maxEval);
  evaluations.resetCount();
  iterations.resetCount();
}
Program: 57295
Project: 57295
Buggy source:
/** 
 * {@inheritDoc} 
 */
public double integrate(final int maxEval,final UnivariateRealFunction f,final double min,final double max) throws TooManyEvaluationsException, MaxCountExceededException, MathIllegalArgumentException, NullArgumentException {
  setup(maxEval,f,min,max);
  return doIntegrate();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public double integrate(final int maxEval,final UnivariateRealFunction f,final double lower,final double upper) throws TooManyEvaluationsException, MaxCountExceededException, MathIllegalArgumentException, NullArgumentException {
  setup(maxEval,f,lower,upper);
  return doIntegrate();
}
Program: 57297
Project: 57297
Buggy source:
/** 
 * Integrate a set of differential equations up to the given time. <p>This method solves an Initial Value Problem (IVP).</p> <p>The set of differential equations is composed of a main set, which can be extended by some sets of secondary equations. The set of equations must be already set up with initial time and partial states. At integration completion, the final time and partial states will be available in the same object.</p> <p>Since this method stores some internal state variables made available in its public interface during integration (  {@link #getCurrentSignedStepsize()}), it is <em>not</em> thread-safe.</p>
 * @param equations complete set of differential equations to integrate
 * @param t target time for the integration(can be set to a value smaller than <code>t0</code> for backward integration)
 * @throws MathIllegalStateException if the integrator cannot perform integration
 * @throws MathIllegalArgumentException if integration parameters are wrong (typicallytoo small integration span)
 */
public abstract void integrate(ExpandableStatefulODE equations,double t) throws MathIllegalStateException, MathIllegalArgumentException ;

Fixed version (ground truth):
/** 
 * Integrate a set of differential expandable up to the given time. <p>This method solves an Initial Value Problem (IVP).</p> <p>The set of differential expandable is composed of a main set, which can be extended by some sets of secondary expandable. The set of expandable must be already set up with initial time and partial states. At integration completion, the final time and partial states will be available in the same object.</p> <p>Since this method stores some internal state variables made available in its public interface during integration (  {@link #getCurrentSignedStepsize()}), it is <em>not</em> thread-safe.</p>
 * @param equations complete set of differential expandable to integrate
 * @param t target time for the integration(can be set to a value smaller than <code>t0</code> for backward integration)
 * @throws MathIllegalStateException if the integrator cannot perform integration
 * @throws MathIllegalArgumentException if integration parameters are wrong (typicallytoo small integration span)
 */
public abstract void integrate(ExpandableStatefulODE equations,double t) throws MathIllegalStateException, MathIllegalArgumentException ;
Program: 57298
Project: 57298
Buggy source:
/** 
 * Compute the derivatives and check the number of evaluations.
 * @param t current value of the independent <I>time</I> variable
 * @param y array containing the current value of the state vector
 * @param yDot placeholder array where to put the time derivative of the state vector
 * @exception MaxCountExceededException if the number of functions evaluations is exceeded
 */
public void computeDerivatives(final double t,final double[] y,final double[] yDot) throws MaxCountExceededException {
  evaluations.incrementCount();
  equations.computeDerivatives(t,y,yDot);
}

Fixed version (ground truth):
/** 
 * Compute the derivatives and check the number of evaluations.
 * @param t current value of the independent <I>time</I> variable
 * @param y array containing the current value of the state vector
 * @param yDot placeholder array where to put the time derivative of the state vector
 * @exception MaxCountExceededException if the number of functions evaluations is exceeded
 */
public void computeDerivatives(final double t,final double[] y,final double[] yDot) throws MaxCountExceededException {
  evaluations.incrementCount();
  expandable.computeDerivatives(t,y,yDot);
}
Program: 57299
Project: 57299
Buggy source:
/** 
 * Check the integration span.
 * @param t target time for the integration
 * @exception NumberIsTooSmallException if integration span is too small
 */
protected void sanityChecks(final ExpandableStatefulODE equations,final double t) throws NumberIsTooSmallException {
  final double threshold=1000 * FastMath.ulp(FastMath.max(FastMath.abs(equations.getTime()),FastMath.abs(t)));
  final double dt=FastMath.abs(equations.getTime() - t);
  if (dt <= threshold) {
    throw new NumberIsTooSmallException(LocalizedFormats.TOO_SMALL_INTEGRATION_INTERVAL,dt,threshold,false);
  }
}

Fixed version (ground truth):
/** 
 * Check the integration span.
 * @param equations set of differential equations
 * @param t target time for the integration
 * @exception NumberIsTooSmallException if integration span is too small
 */
protected void sanityChecks(final ExpandableStatefulODE equations,final double t) throws NumberIsTooSmallException {
  final double threshold=1000 * FastMath.ulp(FastMath.max(FastMath.abs(equations.getTime()),FastMath.abs(t)));
  final double dt=FastMath.abs(equations.getTime() - t);
  if (dt <= threshold) {
    throw new NumberIsTooSmallException(LocalizedFormats.TOO_SMALL_INTEGRATION_INTERVAL,dt,threshold,false);
  }
}
Program: 57300
Project: 57300
Buggy source:
/** 
 * Set the equations.
 * @param equations equations to set
 */
protected void setEquations(final ExpandableStatefulODE equations){
  this.equations=equations;
}

Fixed version (ground truth):
/** 
 * Set the equations.
 * @param equations equations to set
 */
protected void setEquations(final ExpandableStatefulODE equations){
  this.expandable=equations;
}
Program: 57301
Project: 57301
Buggy source:
/** 
 * Simple constructor.
 * @param equation secondary differential equation
 * @param first index index to use for the first element in the complete arrays
 */
public SecondaryComponent(final SecondaryEquations equation,final int firstIndex){
  final int n=equation.getDimension();
  this.equation=equation;
  mapper=new EquationsMapper(firstIndex,n);
  state=new double[n];
  stateDot=new double[n];
}

Fixed version (ground truth):
/** 
 * Simple constructor.
 * @param equation secondary differential equation
 * @param firstIndex index to use for the first element in the complete arrays
 */
public SecondaryComponent(final SecondaryEquations equation,final int firstIndex){
  final int n=equation.getDimension();
  this.equation=equation;
  mapper=new EquationsMapper(firstIndex,n);
  state=new double[n];
  stateDot=new double[n];
}
Program: 57302
Project: 57302
Buggy source:
/** 
 * Add a parameter Jacobian provider.
 * @param pode the parameterized ODE to compute the parameter Jacobian matrix using finite differences 
 */
public void setParameterizedODE(final ParameterizedODE pode){
  this.pode=pode;
  dirtyParameter=true;
}

Fixed version (ground truth):
/** 
 * Add a parameter Jacobian provider.
 * @param parameterizedOde the parameterized ODE to compute the parameter Jacobian matrix using finite differences
 */
public void setParameterizedODE(final ParameterizedODE parameterizedOde){
  this.pode=parameterizedOde;
  dirtyParameter=true;
}
Program: 57303
Project: 57303
Buggy source:
/** 
 * Set the initial value of the Jacobian matrix with respect to state. <p> If this method is not called, the initial value of the Jacobian matrix with respect to state is set to identity. </p>
 * @param dYdY0 initial Jacobian matrix w.r.t. state
 * @exception IllegalArgumentException if matrix dimensions are incorrect
 */
public void setInitialMainStateJacobian(final double[][] dYdY0) throws MathIllegalArgumentException {
  checkDimension(stateDim,dYdY0);
  checkDimension(stateDim,dYdY0[0]);
  int i=0;
  for (  final double[] row : dYdY0) {
    System.arraycopy(row,0,matricesData,i,stateDim);
    i+=stateDim;
  }
  if (efode != null) {
    efode.setSecondaryState(index,matricesData);
  }
}

Fixed version (ground truth):
/** 
 * Set the initial value of the Jacobian matrix with respect to state. <p> If this method is not called, the initial value of the Jacobian matrix with respect to state is set to identity. </p>
 * @param dYdY0 initial Jacobian matrix w.r.t. state
 * @exception DimensionMismatchException if matrix dimensions are incorrect
 */
public void setInitialMainStateJacobian(final double[][] dYdY0) throws DimensionMismatchException {
  checkDimension(stateDim,dYdY0);
  checkDimension(stateDim,dYdY0[0]);
  int i=0;
  for (  final double[] row : dYdY0) {
    System.arraycopy(row,0,matricesData,i,stateDim);
    i+=stateDim;
  }
  if (efode != null) {
    efode.setSecondaryState(index,matricesData);
  }
}
Program: 57304
Project: 57304
Buggy source:
/** 
 * Register the variational equations for the Jacobians matrices to the expandable set.
 * @exception MathIllegalArgumentException if the primary set of the expandable set doesnot match the one used to build the instance
 * @see ExpandableStatefulODE#addSecondaryEquations(SecondaryEquations)
 */
public void registerVariationalEquations(final ExpandableStatefulODE expandable) throws MathIllegalArgumentException {
  final FirstOrderDifferentialEquations ode=(jode instanceof MainStateJacobianWrapper) ? ((MainStateJacobianWrapper)jode).ode : jode;
  if (expandable.getPrimary() != ode) {
    throw new MathIllegalArgumentException(LocalizedFormats.UNMATCHED_ODE_IN_EXPANDED_SET);
  }
  efode=expandable;
  index=efode.addSecondaryEquations(new JacobiansSecondaryEquations());
  efode.setSecondaryState(index,matricesData);
}

Fixed version (ground truth):
/** 
 * Register the variational equations for the Jacobians matrices to the expandable set.
 * @param expandable expandable set into which variational equations should be registered
 * @exception MathIllegalArgumentException if the primary set of the expandable set doesnot match the one used to build the instance
 * @see ExpandableStatefulODE#addSecondaryEquations(SecondaryEquations)
 */
public void registerVariationalEquations(final ExpandableStatefulODE expandable) throws MathIllegalArgumentException {
  final FirstOrderDifferentialEquations ode=(jode instanceof MainStateJacobianWrapper) ? ((MainStateJacobianWrapper)jode).ode : jode;
  if (expandable.getPrimary() != ode) {
    throw new MathIllegalArgumentException(LocalizedFormats.UNMATCHED_ODE_IN_EXPANDED_SET);
  }
  efode=expandable;
  index=efode.addSecondaryEquations(new JacobiansSecondaryEquations());
  efode.setSecondaryState(index,matricesData);
}
Program: 57305
Project: 57305
Buggy source:
/** 
 * Get the current value of the Jacobian matrix with respect to state.
 * @param dYdY0 current Jacobian matrix with respect to state.
 */
public void getCurrentMainSetJacobian(final double[][] dYdY0){
  double[] p=efode.getSecondaryState(index);
  int index=0;
  for (int i=0; i < stateDim; i++) {
    System.arraycopy(p,index,dYdY0[i],0,stateDim);
    index+=stateDim;
  }
}

Fixed version (ground truth):
/** 
 * Get the current value of the Jacobian matrix with respect to state.
 * @param dYdY0 current Jacobian matrix with respect to state.
 */
public void getCurrentMainSetJacobian(final double[][] dYdY0){
  double[] p=efode.getSecondaryState(index);
  int j=0;
  for (int i=0; i < stateDim; i++) {
    System.arraycopy(p,j,dYdY0[i],0,stateDim);
    j+=stateDim;
  }
}
Program: 57306
Project: 57306
Buggy source:
/** 
 * Get the current value of the Jacobian matrix with respect to one parameter.
 * @param pName name of the parameter for the computed Jacobian matrix 
 * @param dYdP current Jacobian matrix with respect to the named parameter
 */
public void getCurrentParameterJacobian(String pName,final double[] dYdP){
  double[] p=efode.getSecondaryState(index);
  int index=stateDim * stateDim;
  for (  ParameterConfiguration param : selectedParameters) {
    if (param.getParameterName().equals(pName)) {
      System.arraycopy(p,index,dYdP,0,stateDim);
      break;
    }
    index+=stateDim;
  }
}

Fixed version (ground truth):
/** 
 * Get the current value of the Jacobian matrix with respect to one parameter.
 * @param pName name of the parameter for the computed Jacobian matrix
 * @param dYdP current Jacobian matrix with respect to the named parameter
 */
public void getCurrentParameterJacobian(String pName,final double[] dYdP){
  double[] p=efode.getSecondaryState(index);
  int i=stateDim * stateDim;
  for (  ParameterConfiguration param : selectedParameters) {
    if (param.getParameterName().equals(pName)) {
      System.arraycopy(p,i,dYdP,0,stateDim);
      return;
    }
    i+=stateDim;
  }
}
Program: 57307
Project: 57307
Buggy source:
/** 
 * Filter the integration step.
 * @param h signed step
 * @param forward forward integration indicator
 * @param acceptSmall if true, steps smaller than the minimal valueare silently increased up to this value, if false such small steps generate an exception
 * @return a bounded integration step (h if no bound is reach, or a bounded value)
 * @exception NumberIsTooSmallException if the step is too small and acceptSmall is false
 */
protected double filterStep(final double h,final boolean forward,final boolean acceptSmall) throws MathIllegalArgumentException {
  double filteredH=h;
  if (FastMath.abs(h) < minStep) {
    if (acceptSmall) {
      filteredH=forward ? minStep : -minStep;
    }
 else {
      throw new NumberIsTooSmallException(LocalizedFormats.MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION,minStep,FastMath.abs(h),true);
    }
  }
  if (filteredH > maxStep) {
    filteredH=maxStep;
  }
 else   if (filteredH < -maxStep) {
    filteredH=-maxStep;
  }
  return filteredH;
}

Fixed version (ground truth):
/** 
 * Filter the integration step.
 * @param h signed step
 * @param forward forward integration indicator
 * @param acceptSmall if true, steps smaller than the minimal valueare silently increased up to this value, if false such small steps generate an exception
 * @return a bounded integration step (h if no bound is reach, or a bounded value)
 * @exception NumberIsTooSmallException if the step is too small and acceptSmall is false
 */
protected double filterStep(final double h,final boolean forward,final boolean acceptSmall) throws NumberIsTooSmallException {
  double filteredH=h;
  if (FastMath.abs(h) < minStep) {
    if (acceptSmall) {
      filteredH=forward ? minStep : -minStep;
    }
 else {
      throw new NumberIsTooSmallException(LocalizedFormats.MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION,minStep,FastMath.abs(h),true);
    }
  }
  if (filteredH > maxStep) {
    filteredH=maxStep;
  }
 else   if (filteredH < -maxStep) {
    filteredH=-maxStep;
  }
  return filteredH;
}
Program: 57308
Project: 57308
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public void writeExternal(final ObjectOutput out) throws IOException {
  try {
    finalizeStep();
  }
 catch (  Exception e) {
    IOException ioe=new IOException(e.getLocalizedMessage());
    ioe.initCause(e);
    throw ioe;
  }
  final int dimension=(currentState == null) ? -1 : currentState.length;
  out.writeInt(dimension);
  for (int i=0; i < dimension; ++i) {
    out.writeDouble(yDotKLast[0][i]);
    out.writeDouble(yDotKLast[1][i]);
    out.writeDouble(yDotKLast[2][i]);
  }
  super.writeExternal(out);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public void writeExternal(final ObjectOutput out) throws IOException {
  finalizeStep();
  final int dimension=(currentState == null) ? -1 : currentState.length;
  out.writeInt(dimension);
  for (int i=0; i < dimension; ++i) {
    out.writeDouble(yDotKLast[0][i]);
    out.writeDouble(yDotKLast[1][i]);
    out.writeDouble(yDotKLast[2][i]);
  }
  super.writeExternal(out);
}
Program: 57309
Project: 57309
Buggy source:
/** 
 * Returns the next pseudorandom, uniformly distributed   {@code long}value from this random number generator's sequence.  All 2<font size="-1"><sup>64</sup></font> possible   {@code long} valuesshould be produced with (approximately) equal probability. <p> The default implementation returns <pre> <code>(long) (nextDouble() * Long.MAX_VALUE)</code> </pre></p>
 * @return  the next pseudorandom, uniformly distributed {@code long}value from this random number generator's sequence
 */
public long nextLong(){
  return (long)(nextDouble() * Long.MAX_VALUE);
}

Fixed version (ground truth):
/** 
 * Returns the next pseudorandom, uniformly distributed   {@code long}value from this random number generator's sequence.  All 2<font size="-1"><sup>64</sup></font> possible   {@code long} valuesshould be produced with (approximately) equal probability. <p> The default implementation returns <pre> <code>(long) (nextDouble() * Long.MAX_VALUE)</code> </pre></p>
 * @return  the next pseudorandom, uniformly distributed {@code long}value from this random number generator's sequence
 */
public long nextLong(){
  return (long)((2d * nextDouble() - 1d) * Long.MAX_VALUE);
}
Program: 57310
Project: 57310
Buggy source:
/** 
 * Returns the <a href="http://www.xycoon.com/standerrorb(1).htm">standard error of the parameter estimate at index</a>, usually denoted s(b<sub>index</sub>).
 * @param index an integer index which must be in the range [0, numberOfParameters-1]
 * @return standard errors associated with parameters estimated at index
 * @throws IndexOutOfBoundsException thrown if the index >= numberOfParameters
 */
public double getStdErrorOfEstimate(int index) throws IndexOutOfBoundsException {
  if (parameters == null) {
    return Double.NaN;
  }
  if (index < 0 || index >= this.parameters.length) {
    throw new IndexOutOfBoundsException("String_Node_Str");
  }
  double var=this.getVcvElement(index,index);
  if (!Double.isNaN(var) && var > Double.MIN_VALUE) {
    return FastMath.sqrt(rank);
  }
  return Double.NaN;
}

Fixed version (ground truth):
/** 
 * Returns the <a href="http://www.xycoon.com/standerrorb(1).htm">standard error of the parameter estimate at index</a>, usually denoted s(b<sub>index</sub>).
 * @param index an integer index which must be in the range [0, numberOfParameters-1]
 * @return standard errors associated with parameters estimated at index
 * @throws IndexOutOfBoundsException thrown if the index >= numberOfParameters
 */
public double getStdErrorOfEstimate(int index) throws IndexOutOfBoundsException {
  if (parameters == null) {
    return Double.NaN;
  }
  if (index < 0 || index >= this.parameters.length) {
    throw new IndexOutOfBoundsException("String_Node_Str");
  }
  double var=this.getVcvElement(index,index);
  if (!Double.isNaN(var) && var > Double.MIN_VALUE) {
    return FastMath.sqrt(var);
  }
  return Double.NaN;
}
Program: 57311
Project: 57311
Buggy source:
/** 
 * <p>Returns the <a href="http://www.xycoon.com/standerrorb(1).htm">standard error of the parameter estimates</a>, usually denoted s(b<sub>i</sub>).</p> <p>If there are problems with an ill conditioned design matrix then the regressor which is redundant will be assigned <code>Double.NaN</code>. </p>
 * @return an array standard errors associated with parameters estimates,null if no estimation occurred
 */
public double[] getStdErrorOfEstimates(){
  if (parameters == null) {
    return null;
  }
  double[] se=new double[this.parameters.length];
  for (int i=0; i < this.parameters.length; i++) {
    double var=this.getVcvElement(i,i);
    if (!Double.isNaN(var) && var > Double.MIN_VALUE) {
      se[i]=FastMath.sqrt(rank);
      continue;
    }
    se[i]=Double.NaN;
  }
  return se;
}

Fixed version (ground truth):
/** 
 * <p>Returns the <a href="http://www.xycoon.com/standerrorb(1).htm">standard error of the parameter estimates</a>, usually denoted s(b<sub>i</sub>).</p> <p>If there are problems with an ill conditioned design matrix then the regressor which is redundant will be assigned <code>Double.NaN</code>. </p>
 * @return an array standard errors associated with parameters estimates,null if no estimation occurred
 */
public double[] getStdErrorOfEstimates(){
  if (parameters == null) {
    return null;
  }
  double[] se=new double[this.parameters.length];
  for (int i=0; i < this.parameters.length; i++) {
    double var=this.getVcvElement(i,i);
    if (!Double.isNaN(var) && var > Double.MIN_VALUE) {
      se[i]=FastMath.sqrt(var);
      continue;
    }
    se[i]=Double.NaN;
  }
  return se;
}