nus-yam/ex-repair huggingface dataset:
Program: 57372
Project: 57372
Buggy source:
/** 
 * Compute and evaluate a new simplex.
 * @param original Original simplex (to be preserved).
 * @param coeff Linear coefficient.
 * @param comparator Comparator to use to sort simplex vertices from bestto poorest.
 * @return the best point in the transformed simplex.
 * @exception FunctionEvaluationException if the function cannot beevaluated at some point.
 * @exception TooManyEvaluationsException if the maximal number ofevaluations is exceeded.
 */
private RealPointValuePair evaluateNewSimplex(final RealPointValuePair[] original,final double coeff,final Comparator<RealPointValuePair> comparator) throws FunctionEvaluationException {
  final double[] xSmallest=original[0].getPointRef();
  final int n=xSmallest.length;
  simplex=new RealPointValuePair[n + 1];
  simplex[0]=original[0];
  for (int i=1; i <= n; ++i) {
    final double[] xOriginal=original[i].getPointRef();
    final double[] xTransformed=new double[n];
    for (int j=0; j < n; ++j) {
      xTransformed[j]=xSmallest[j] + coeff * (xSmallest[j] - xOriginal[j]);
    }
    simplex[i]=new RealPointValuePair(xTransformed,Double.NaN,false);
  }
  evaluateSimplex(comparator);
  return simplex[0];
}

Fixed version (ground truth):
/** 
 * Compute and evaluate a new simplex.
 * @param original Original simplex (to be preserved).
 * @param coeff Linear coefficient.
 * @param comparator Comparator to use to sort simplex vertices from bestto poorest.
 * @return the best point in the transformed simplex.
 * @throws FunctionEvaluationException if the function cannot beevaluated at some point.
 * @throws org.apache.commons.math.exception.TooManyEvaluationsException if the maximal number of evaluations is exceeded.
 */
private RealPointValuePair evaluateNewSimplex(final RealPointValuePair[] original,final double coeff,final Comparator<RealPointValuePair> comparator) throws FunctionEvaluationException {
  final double[] xSmallest=original[0].getPointRef();
  final int n=xSmallest.length;
  simplex=new RealPointValuePair[n + 1];
  simplex[0]=original[0];
  for (int i=1; i <= n; ++i) {
    final double[] xOriginal=original[i].getPointRef();
    final double[] xTransformed=new double[n];
    for (int j=0; j < n; ++j) {
      xTransformed[j]=xSmallest[j] + coeff * (xSmallest[j] - xOriginal[j]);
    }
    simplex[i]=new RealPointValuePair(xTransformed,Double.NaN,false);
  }
  evaluateSimplex(comparator);
  return simplex[0];
}
Program: 57373
Project: 57373
Buggy source:
/** 
 * Fit a curve. <p>This method compute the coefficients of the curve that best fit the sample of observed points previously given through calls to the   {@link #addObservedPoint(WeightedObservedPoint) addObservedPoint} method.</p>
 * @param f parametric function to fit
 * @param initialGuess first guess of the function parameters
 * @return fitted parameters
 * @exception FunctionEvaluationException if the objective function throws one duringthe search
 * @exception ConvergenceException if the algorithm failed to converge
 * @exception IllegalArgumentException if the start point dimension is wrong.
 */
public double[] fit(final ParametricRealFunction f,final double[] initialGuess) throws FunctionEvaluationException {
  double[] target=new double[observations.size()];
  double[] weights=new double[observations.size()];
  int i=0;
  for (  WeightedObservedPoint point : observations) {
    target[i]=point.getY();
    weights[i]=point.getWeight();
    ++i;
  }
  VectorialPointValuePair optimum=optimizer.optimize(new TheoreticalValuesFunction(f),target,weights,initialGuess);
  return optimum.getPointRef();
}

Fixed version (ground truth):
/** 
 * Fit a curve. <p>This method compute the coefficients of the curve that best fit the sample of observed points previously given through calls to the   {@link #addObservedPoint(WeightedObservedPoint) addObservedPoint} method.</p>
 * @param f parametric function to fit
 * @param initialGuess first guess of the function parameters
 * @return fitted parameters
 * @exception FunctionEvaluationException if the objective function throws one duringthe search
 * @exception org.apache.commons.math.exception.ConvergenceException if the algorithm failed to converge.
 * @exception org.apache.commons.math.exception.DimensionMismatchException if the start point dimension is wrong.
 */
public double[] fit(final ParametricRealFunction f,final double[] initialGuess) throws FunctionEvaluationException {
  double[] target=new double[observations.size()];
  double[] weights=new double[observations.size()];
  int i=0;
  for (  WeightedObservedPoint point : observations) {
    target[i]=point.getY();
    weights[i]=point.getWeight();
    ++i;
  }
  VectorialPointValuePair optimum=optimizer.optimize(new TheoreticalValuesFunction(f),target,weights,initialGuess);
  return optimum.getPointRef();
}
Program: 57374
Project: 57374
Buggy source:
/** 
 * Get the polynomial fitting the weighted (x, y) points.
 * @return polynomial function best fitting the observed points
 * @exception ConvergenceException if the algorithm failed to converge
 */
public PolynomialFunction fit(){
  try {
    return new PolynomialFunction(fitter.fit(new ParametricPolynomial(),new double[degree + 1]));
  }
 catch (  FunctionEvaluationException fee) {
    throw MathRuntimeException.createInternalError(fee);
  }
}

Fixed version (ground truth):
/** 
 * Get the polynomial fitting the weighted (x, y) points.
 * @return polynomial function best fitting the observed points
 * @throws org.apache.commons.math.exception.ConvergenceException if the algorithm failed to converge.
 */
public PolynomialFunction fit(){
  try {
    return new PolynomialFunction(fitter.fit(new ParametricPolynomial(),new double[degree + 1]));
  }
 catch (  FunctionEvaluationException fee) {
    throw MathRuntimeException.createInternalError(fee);
  }
}
Program: 57375
Project: 57375
Buggy source:
/** 
 * Compute the gradient vector.
 * @param evaluationPoint Point at which the gradient must be evaluated.
 * @return the gradient at the specified point.
 * @throws FunctionEvaluationException if the function gradient cannot beevaluated.
 * @throws TooManyEvaluationsException if the allowed number of evaluationsis exceeded.
 */
protected double[] computeObjectiveGradient(final double[] evaluationPoint) throws FunctionEvaluationException {
  return gradient.value(evaluationPoint);
}

Fixed version (ground truth):
/** 
 * Compute the gradient vector.
 * @param evaluationPoint Point at which the gradient must be evaluated.
 * @return the gradient at the specified point.
 * @throws FunctionEvaluationException if the function gradient cannot beevaluated.
 * @throws org.apache.commons.math.exception.TooManyEvaluationsException if the allowed number of evaluations is exceeded.
 */
protected double[] computeObjectiveGradient(final double[] evaluationPoint) throws FunctionEvaluationException {
  return gradient.value(evaluationPoint);
}
Program: 57376
Project: 57376
Buggy source:
/** 
 * Compute this minus v.
 * @param v vector to be subtracted
 * @return this + v
 * @throws IllegalArgumentException if v is not the same size as this
 */
RealVector subtract(double[] v) throws IllegalArgumentException ;

Fixed version (ground truth):
/** 
 * Compute this minus v.
 * @param v vector to be subtracted
 * @return this - v
 * @throws IllegalArgumentException if v is not the same size as this
 */
RealVector subtract(double[] v) throws IllegalArgumentException ;
Program: 57377
Project: 57377
Buggy source:
/** 
 * {@inheritDoc} 
 */
public double optimize(final UnivariateRealFunction f,final GoalType goalType,final double min,final double max) throws MaxIterationsExceededException, FunctionEvaluationException {
  clearResult();
  return localMin(f,goalType,min,max,relativeAccuracy,absoluteAccuracy);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public double optimize(final UnivariateRealFunction f,final GoalType goalType,final double min,final double max) throws MaxIterationsExceededException, FunctionEvaluationException {
  return optimize(f,goalType,min,max,min + GOLDEN_SECTION * (max - min));
}
Program: 57380
Project: 57380
Buggy source:
/** 
 * For this distribution, X, this method returns P(X &lt; <code>x</code>).
 * @param x the value at which the CDF is evaluated.
 * @return CDF evaluted at <code>x</code>.
 * @throws MathException if the cumulative probability can not becomputed due to convergence or other numerical errors.
 */
public double cumulativeProbability(double x) throws MathException {
  double ret;
  if (x == 0.0) {
    ret=0.5;
  }
 else {
    double t=Beta.regularizedBeta(degreesOfFreedom / (degreesOfFreedom + (x * x)),0.5 * degreesOfFreedom,0.5);
    if (x < 0.0) {
      ret=0.5 * t;
    }
 else {
      ret=1.0 - 0.5 * t;
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * For this distribution, X, this method returns P(X &lt; <code>x</code>).
 * @param x the value at which the CDF is evaluated.
 * @return CDF evaluated at <code>x</code>.
 * @throws MathException if the cumulative probability can not becomputed due to convergence or other numerical errors.
 */
public double cumulativeProbability(double x) throws MathException {
  double ret;
  if (x == 0.0) {
    ret=0.5;
  }
 else {
    double t=Beta.regularizedBeta(degreesOfFreedom / (degreesOfFreedom + (x * x)),0.5 * degreesOfFreedom,0.5);
    if (x < 0.0) {
      ret=0.5 * t;
    }
 else {
      ret=1.0 - 0.5 * t;
    }
  }
  return ret;
}
Program: 57381
Project: 57381
Buggy source:
/** 
 * Returns a matrix of p-values associated with the (two-sided) null hypothesis that the corresponding correlation coefficient is zero. <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability that a random variable distributed as <code>t<sub>n-2</sub></code> takes a value with absolute value greater than or equal to <br> <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> <p>The values in the matrix are sometimes referred to as the <i>significance</i> of the corresponding correlation coefficients.</p>
 * @return matrix of p-values
 * @throws MathException if an error occurs estimating probabilities
 */
public RealMatrix getCorrelationPValues() throws MathException {
  TDistribution tDistribution=new TDistributionImpl(nObs - 2);
  int nVars=correlationMatrix.getColumnDimension();
  double[][] out=new double[nVars][nVars];
  for (int i=0; i < nVars; i++) {
    for (int j=0; j < nVars; j++) {
      if (i == j) {
        out[i][j]=0d;
      }
 else {
        double r=correlationMatrix.getEntry(i,j);
        double t=Math.abs(r * Math.sqrt((nObs - 2) / (1 - r * r)));
        out[i][j]=2 * (1 - tDistribution.cumulativeProbability(t));
      }
    }
  }
  return new BlockRealMatrix(out);
}

Fixed version (ground truth):
/** 
 * Returns a matrix of p-values associated with the (two-sided) null hypothesis that the corresponding correlation coefficient is zero. <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability that a random variable distributed as <code>t<sub>n-2</sub></code> takes a value with absolute value greater than or equal to <br> <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> <p>The values in the matrix are sometimes referred to as the <i>significance</i> of the corresponding correlation coefficients.</p>
 * @return matrix of p-values
 * @throws MathException if an error occurs estimating probabilities
 */
public RealMatrix getCorrelationPValues() throws MathException {
  TDistribution tDistribution=new TDistributionImpl(nObs - 2);
  int nVars=correlationMatrix.getColumnDimension();
  double[][] out=new double[nVars][nVars];
  for (int i=0; i < nVars; i++) {
    for (int j=0; j < nVars; j++) {
      if (i == j) {
        out[i][j]=0d;
      }
 else {
        double r=correlationMatrix.getEntry(i,j);
        double t=Math.abs(r * Math.sqrt((nObs - 2) / (1 - r * r)));
        out[i][j]=2 * tDistribution.cumulativeProbability(-t);
      }
    }
  }
  return new BlockRealMatrix(out);
}
Program: 57382
Project: 57382
Buggy source:
/** 
 * Advance an entry up to the next non null one.
 * @param e entry to advance
 */
protected void advance(EntryImpl e){
  if (e == null) {
    return;
  }
  do {
    e.setIndex(e.getIndex() + 1);
  }
 while (e.getIndex() < dim && e.getValue() == 0);
  if (e.getIndex() >= dim) {
    e.setIndex(-1);
  }
}

Fixed version (ground truth):
/** 
 * Advance an entry up to the next nonzero one.
 * @param e entry to advance
 */
protected void advance(EntryImpl e){
  if (e == null) {
    return;
  }
  do {
    e.setIndex(e.getIndex() + 1);
  }
 while (e.getIndex() < dim && e.getValue() == 0);
  if (e.getIndex() >= dim) {
    e.setIndex(-1);
  }
}
Program: 57383
Project: 57383
Buggy source:
/** 
 * {@inheritDoc} 
 */
public boolean hasNext(){
  return current != null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public boolean hasNext(){
  return next.getIndex() >= 0;
}
Program: 57384
Project: 57384
Buggy source:
/** 
 * Simple constructor. 
 */
protected SparseEntryIterator(){
  dim=getDimension();
  current=new EntryImpl();
  if (current.getValue() == 0) {
    advance(current);
  }
  if (current.getIndex() >= 0) {
    next=new EntryImpl();
    next.setIndex(current.getIndex());
    advance(next);
  }
 else {
    current=null;
  }
}

Fixed version (ground truth):
/** 
 * Simple constructor. 
 */
protected SparseEntryIterator(){
  dim=getDimension();
  current=new EntryImpl();
  next=new EntryImpl();
  if (next.getValue() == 0) {
    advance(next);
  }
}
Program: 57385
Project: 57385
Buggy source:
/** 
 * {@inheritDoc} 
 */
public Entry next(){
  tmp.setIndex(current.getIndex());
  if (next != null) {
    current.setIndex(next.getIndex());
    advance(next);
    if (next.getIndex() < 0) {
      next=null;
    }
  }
 else {
    current=null;
  }
  return tmp;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public Entry next(){
  int index=next.getIndex();
  if (index < 0) {
    throw new NoSuchElementException();
  }
  current.setIndex(index);
  advance(next);
  return current;
}
Program: 57386
Project: 57386
Buggy source:
/** 
 * Returns true iff <code>object</code> is a <code>SummaryStatistics</code> instance and all statistics have the same values as this.
 * @param object the object to test equality against.
 * @return true if object equals this
 */
@Override public boolean equals(Object object){
  if (object == this) {
    return true;
  }
  if (object instanceof MultivariateSummaryStatistics == false) {
    return false;
  }
  MultivariateSummaryStatistics stat=(MultivariateSummaryStatistics)object;
  return MathUtils.equals(stat.getGeometricMean(),getGeometricMean()) && MathUtils.equals(stat.getMax(),getMax()) && MathUtils.equals(stat.getMean(),getMean())&& MathUtils.equals(stat.getMin(),getMin())&& MathUtils.equals(stat.getN(),getN())&& MathUtils.equals(stat.getSum(),getSum())&& MathUtils.equals(stat.getSumSq(),getSumSq())&& MathUtils.equals(stat.getSumLog(),getSumLog())&& stat.getCovariance().equals(getCovariance());
}

Fixed version (ground truth):
/** 
 * Returns true iff <code>object</code> is a <code>MultivariateSummaryStatistics</code> instance and all statistics have the same values as this.
 * @param object the object to test equality against.
 * @return true if object equals this
 */
@Override public boolean equals(Object object){
  if (object == this) {
    return true;
  }
  if (object instanceof MultivariateSummaryStatistics == false) {
    return false;
  }
  MultivariateSummaryStatistics stat=(MultivariateSummaryStatistics)object;
  return MathUtils.equals(stat.getGeometricMean(),getGeometricMean()) && MathUtils.equals(stat.getMax(),getMax()) && MathUtils.equals(stat.getMean(),getMean())&& MathUtils.equals(stat.getMin(),getMin())&& MathUtils.equals(stat.getN(),getN())&& MathUtils.equals(stat.getSum(),getSum())&& MathUtils.equals(stat.getSumSq(),getSumSq())&& MathUtils.equals(stat.getSumLog(),getSumLog())&& stat.getCovariance().equals(getCovariance());
}
Program: 57387
Project: 57387
Buggy source:
/** 
 * Create a binomial distribution with the given number of trials and probability of success.
 * @param r the number of successes
 * @param p the probability of success
 */
public PascalDistributionImpl(int r,double p){
  super();
  setNumberOfSuccessesInternal(r);
  setProbabilityOfSuccessInternal(p);
}

Fixed version (ground truth):
/** 
 * Create a Pascal distribution with the given number of trials and probability of success.
 * @param r the number of successes
 * @param p the probability of success
 */
public PascalDistributionImpl(int r,double p){
  super();
  setNumberOfSuccessesInternal(r);
  setProbabilityOfSuccessInternal(p);
}
Program: 57392
Project: 57392
Buggy source:
/** 
 * Construct a solver.
 */
public BrentSolver(){
  super(100,1E-6);
}

Fixed version (ground truth):
/** 
 * Contstruct a solver with the given maximum iterations and absolute accuracy.
 * @param maximumIterations maximum number of iterations
 * @param absoluteAccuracy lower bound for absolute accuracy of solutions returned by the solver
 */
public BrentSolver(int maximumIterations,double absoluteAccuracy){
  super(maximumIterations,absoluteAccuracy);
}
Program: 57394
Project: 57394
Buggy source:
public double value(double x) throws FunctionEvaluationException {
  try {
    return cumulativeProbability(x) - p;
  }
 catch (  MathException ex) {
    throw new FunctionEvaluationException(ex,x,ex.getPattern(),ex.getArguments());
  }
}

Fixed version (ground truth):
public double value(double x) throws FunctionEvaluationException {
  double ret=Double.NaN;
  try {
    ret=cumulativeProbability(x) - p;
  }
 catch (  MathException ex) {
    throw new FunctionEvaluationException(ex,x,ex.getPattern(),ex.getArguments());
  }
  if (Double.isNaN(ret)) {
    throw new FunctionEvaluationException(x,"String_Node_Str",x,p);
  }
  return ret;
}
Program: 57395
Project: 57395
Buggy source:
/** 
 * For a random variable X whose values are distributed according to this distribution, this method returns the largest x, such that P(X &le; x) &le; <code>p</code>.
 * @param p the desired probability
 * @return the largest x such that P(X &le; x) <= p
 * @throws MathException if the inverse cumulative probability can not becomputed due to convergence or other numerical errors.
 * @throws IllegalArgumentException if p < 0 or p > 1
 */
public int inverseCumulativeProbability(final double p) throws MathException {
  if (p < 0.0 || p > 1.0) {
    throw MathRuntimeException.createIllegalArgumentException(OUT_OF_RANGE_POINT,p,0.0,1.0);
  }
  int x0=getDomainLowerBound(p);
  int x1=getDomainUpperBound(p);
  double pm;
  while (x0 < x1) {
    int xm=x0 + (x1 - x0) / 2;
    pm=cumulativeProbability(xm);
    if (pm > p) {
      if (xm == x1) {
        --x1;
      }
 else {
        x1=xm;
      }
    }
 else {
      if (xm == x0) {
        ++x0;
      }
 else {
        x0=xm;
      }
    }
  }
  pm=cumulativeProbability(x0);
  while (pm > p) {
    --x0;
    pm=cumulativeProbability(x0);
  }
  return x0;
}

Fixed version (ground truth):
/** 
 * For a random variable X whose values are distributed according to this distribution, this method returns the largest x, such that P(X &le; x) &le; <code>p</code>.
 * @param p the desired probability
 * @return the largest x such that P(X &le; x) <= p
 * @throws MathException if the inverse cumulative probability can not becomputed due to convergence or other numerical errors.
 * @throws IllegalArgumentException if p < 0 or p > 1
 */
public int inverseCumulativeProbability(final double p) throws MathException {
  if (p < 0.0 || p > 1.0) {
    throw MathRuntimeException.createIllegalArgumentException(OUT_OF_RANGE_POINT,p,0.0,1.0);
  }
  int x0=getDomainLowerBound(p);
  int x1=getDomainUpperBound(p);
  double pm;
  while (x0 < x1) {
    int xm=x0 + (x1 - x0) / 2;
    pm=checkedCumulativeProbability(xm);
    if (pm > p) {
      if (xm == x1) {
        --x1;
      }
 else {
        x1=xm;
      }
    }
 else {
      if (xm == x0) {
        ++x0;
      }
 else {
        x0=xm;
      }
    }
  }
  pm=checkedCumulativeProbability(x0);
  while (pm > p) {
    --x0;
    pm=checkedCumulativeProbability(x0);
  }
  return x0;
}
Program: 57396
Project: 57396
Buggy source:
/** 
 * The probability distribution function P(X <= x) for a Poisson distribution.
 * @param x the value at which the PDF is evaluated.
 * @return Poisson distribution function evaluated at x
 * @throws MathException if the cumulative probability can not be computeddue to convergence or other numerical errors.
 */
@Override public double cumulativeProbability(int x) throws MathException {
  if (x < 0) {
    return 0;
  }
  if (x == Integer.MAX_VALUE) {
    return 1;
  }
  return Gamma.regularizedGammaQ((double)x + 1,mean,1E-12,Integer.MAX_VALUE);
}

Fixed version (ground truth):
/** 
 * The probability distribution function P(X <= x) for a Poisson distribution.
 * @param x the value at which the PDF is evaluated.
 * @return Poisson distribution function evaluated at x
 * @throws MathException if the cumulative probability can not be computeddue to convergence or other numerical errors.
 */
@Override public double cumulativeProbability(int x) throws MathException {
  if (x < 0) {
    return 0;
  }
  if (x == Integer.MAX_VALUE) {
    return 1;
  }
  return Gamma.regularizedGammaQ((double)x + 1,mean,epsilon,maxIterations);
}
Program: 57397
Project: 57397
Buggy source:
/** 
 * Build an enhanced integrator using ODE builtin jacobian computation features.
 * @param integrator underlying integrator to solve the compound problem
 * @param ode original problem, which can compute the jacobians by itself
 * @see #EnhancedFirstOrderIntegrator(FirstOrderIntegrator,ParameterizedODE,double[],double[],double[])
 */
public FirstOrderIntegratorWithJacobians(final FirstOrderIntegrator integrator,final ParameterizedODEWithJacobians ode){
  this.integrator=integrator;
  this.ode=ode;
  setMaxEvaluations(-1);
}

Fixed version (ground truth):
/** 
 * Build an enhanced integrator using ODE builtin jacobian computation features.
 * @param integrator underlying integrator to solve the compound problem
 * @param ode original problem, which can compute the jacobians by itself
 * @see #FirstOrderIntegratorWithJacobians(FirstOrderIntegrator,ParameterizedODE,double[],double[],double[])
 */
public FirstOrderIntegratorWithJacobians(final FirstOrderIntegrator integrator,final ParameterizedODEWithJacobians ode){
  this.integrator=integrator;
  this.ode=ode;
  setMaxEvaluations(-1);
}
Program: 57399
Project: 57399
Buggy source:
/** 
 * Determines whether this handler needs dense output. <p>This method allows the integrator to avoid performing extra computation if the handler does not need dense output. If this method returns false, the integrator will call the   {@link #handleStep} method with a {@link DummyStepInterpolator} ratherthan a custom interpolator.</p>
 * @return true if the handler needs dense output
 */
boolean requiresDenseOutput();

Fixed version (ground truth):
/** 
 * Determines whether this handler needs dense output. <p>This method allows the integrator to avoid performing extra computation if the handler does not need dense output.</p>
 * @return true if the handler needs dense output
 */
boolean requiresDenseOutput();
Program: 57403
Project: 57403
Buggy source:
/** 
 * Write the instance to an output channel.
 * @param out output channel
 * @exception IOException if the instance cannot be written
 */
@Override public void writeExternal(final ObjectOutput out) throws IOException {
  writeBaseExternal(out);
}

Fixed version (ground truth):
/** 
 * Write the instance to an output channel.
 * @param out output channel
 * @exception IOException if the instance cannot be written
 */
@Override public void writeExternal(final ObjectOutput out) throws IOException {
  writeBaseExternal(out);
  if (currentDerivative != null) {
    for (int i=0; i < currentDerivative.length; ++i) {
      out.writeDouble(currentDerivative[i]);
    }
  }
}
Program: 57404
Project: 57404
Buggy source:
/** 
 * Copy constructor.
 * @param interpolator interpolator to copy from. The copy is a deepcopy: its arrays are separated from the original arrays of the instance
 */
public DummyStepInterpolator(final DummyStepInterpolator interpolator){
  super(interpolator);
}

Fixed version (ground truth):
/** 
 * Copy constructor.
 * @param interpolator interpolator to copy from. The copy is a deepcopy: its arrays are separated from the original arrays of the instance
 */
public DummyStepInterpolator(final DummyStepInterpolator interpolator){
  super(interpolator);
  currentDerivative=interpolator.currentDerivative.clone();
}
Program: 57405
Project: 57405
Buggy source:
/** 
 * Read the instance from an input channel.
 * @param in input channel
 * @exception IOException if the instance cannot be read
 */
@Override public void readExternal(final ObjectInput in) throws IOException {
  final double t=readBaseExternal(in);
  setInterpolatedTime(t);
}

Fixed version (ground truth):
/** 
 * Read the instance from an input channel.
 * @param in input channel
 * @exception IOException if the instance cannot be read
 */
@Override public void readExternal(final ObjectInput in) throws IOException {
  final double t=readBaseExternal(in);
  if (currentState == null) {
    currentDerivative=null;
  }
 else {
    currentDerivative=new double[currentState.length];
    for (int i=0; i < currentDerivative.length; ++i) {
      currentDerivative[i]=in.readDouble();
    }
  }
  setInterpolatedTime(t);
}
Program: 57406
Project: 57406
Buggy source:
/** 
 * Compute the state at the interpolated time. In this class, this method does nothing: the interpolated state is always the state at the end of the current step.
 * @param theta normalized interpolation abscissa within the step(theta is zero at the previous time step and one at the current time step)
 * @param oneMinusThetaH time gap between the interpolated time andthe current time
 * @throws DerivativeException this exception is propagated to the caller if theunderlying user function triggers one
 */
@Override protected void computeInterpolatedStateAndDerivatives(final double theta,final double oneMinusThetaH) throws DerivativeException {
  System.arraycopy(currentState,0,interpolatedState,0,currentState.length);
}

Fixed version (ground truth):
/** 
 * Compute the state at the interpolated time. In this class, this method does nothing: the interpolated state is always the state at the end of the current step.
 * @param theta normalized interpolation abscissa within the step(theta is zero at the previous time step and one at the current time step)
 * @param oneMinusThetaH time gap between the interpolated time andthe current time
 * @throws DerivativeException this exception is propagated to the caller if theunderlying user function triggers one
 */
@Override protected void computeInterpolatedStateAndDerivatives(final double theta,final double oneMinusThetaH) throws DerivativeException {
  System.arraycopy(currentState,0,interpolatedState,0,currentState.length);
  System.arraycopy(currentDerivative,0,interpolatedDerivatives,0,currentDerivative.length);
}
Program: 57407
Project: 57407
Buggy source:
/** 
 * {@inheritDoc} 
 */
public StepInterpolatorWithJacobians copy() throws DerivativeException {
  return new StepInterpolatorWrapper(interpolator.copy(),y.length,dydy0[0].length);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public StepInterpolatorWithJacobians copy() throws DerivativeException {
  final int n=y.length;
  final int k=dydp[0].length;
  StepInterpolatorWrapper copied=new StepInterpolatorWrapper(interpolator.copy(),n,k);
  System.arraycopy(y,0,copied.y,0,n);
  System.arraycopy(yDot,0,copied.yDot,0,n);
  for (int i=0; i < n; ++i) {
    System.arraycopy(dydy0[i],0,copied.dydy0[i],0,n);
  }
  for (int i=0; i < n; ++i) {
    System.arraycopy(dydp[i],0,copied.dydp[i],0,k);
  }
  return copied;
}
Program: 57409
Project: 57409
Buggy source:
public double dYdP0(){
  return -1087.8787631970476 + (1050.4387741821572 + (-338.90621620263096 + 36.51793006801084 * b) * b) * b;
}

Fixed version (ground truth):
public double dYdP0(){
  return -1088.232716447743 + (1050.775747149553 + (-339.012934631828 + 36.52917025056327 * b) * b) * b;
}
Program: 57410
Project: 57410
Buggy source:
@Test public void testInternalDifferentiation() throws IntegratorException, DerivativeException {
  FirstOrderIntegrator integ=new DormandPrince54Integrator(1.0e-8,100.0,1.0e-4,1.0e-4);
  double hP=1.0e-12;
  SummaryStatistics residuals0=new SummaryStatistics();
  SummaryStatistics residuals1=new SummaryStatistics();
  for (double b=2.88; b < 3.08; b+=0.001) {
    Brusselator brusselator=new Brusselator(b);
    brusselator.setParameter(0,b);
    double[] z={1.3,b};
    double[][] dZdZ0=new double[2][2];
    double[][] dZdP=new double[2][1];
    double hY=1.0e-12;
    FirstOrderIntegratorWithJacobians extInt=new FirstOrderIntegratorWithJacobians(integ,brusselator,new double[]{b},new double[]{hY,hY},new double[]{hP});
    extInt.integrate(0,z,new double[][]{{0.0},{1.0}},20.0,z,dZdZ0,dZdP);
    residuals0.addValue(dZdP[0][0] - brusselator.dYdP0());
    residuals1.addValue(dZdP[1][0] - brusselator.dYdP1());
  }
  Assert.assertTrue((residuals0.getMax() - residuals0.getMin()) < 0.006);
  Assert.assertTrue(residuals0.getStandardDeviation() < 0.0009);
  Assert.assertTrue((residuals1.getMax() - residuals1.getMin()) < 0.006);
  Assert.assertTrue(residuals1.getStandardDeviation() < 0.0012);
}

Fixed version (ground truth):
@Test public void testInternalDifferentiation() throws IntegratorException, DerivativeException {
  FirstOrderIntegrator integ=new DormandPrince54Integrator(1.0e-8,100.0,1.0e-4,1.0e-4);
  double hP=1.0e-12;
  SummaryStatistics residualsP0=new SummaryStatistics();
  SummaryStatistics residualsP1=new SummaryStatistics();
  for (double b=2.88; b < 3.08; b+=0.001) {
    Brusselator brusselator=new Brusselator(b);
    brusselator.setParameter(0,b);
    double[] z={1.3,b};
    double[][] dZdZ0=new double[2][2];
    double[][] dZdP=new double[2][1];
    double hY=1.0e-12;
    FirstOrderIntegratorWithJacobians extInt=new FirstOrderIntegratorWithJacobians(integ,brusselator,new double[]{b},new double[]{hY,hY},new double[]{hP});
    extInt.integrate(0,z,new double[][]{{0.0},{1.0}},20.0,z,dZdZ0,dZdP);
    residualsP0.addValue(dZdP[0][0] - brusselator.dYdP0());
    residualsP1.addValue(dZdP[1][0] - brusselator.dYdP1());
  }
  Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) < 0.006);
  Assert.assertTrue(residualsP0.getStandardDeviation() < 0.0009);
  Assert.assertTrue((residualsP1.getMax() - residualsP1.getMin()) < 0.009);
  Assert.assertTrue(residualsP1.getStandardDeviation() < 0.0014);
}
Program: 57411
Project: 57411
Buggy source:
@Test public void testLowAccuracyExternalDifferentiation() throws IntegratorException, DerivativeException {
  FirstOrderIntegrator integ=new DormandPrince54Integrator(1.0e-8,100.0,1.0e-4,1.0e-4);
  double hP=1.0e-12;
  SummaryStatistics residuals0=new SummaryStatistics();
  SummaryStatistics residuals1=new SummaryStatistics();
  for (double b=2.88; b < 3.08; b+=0.001) {
    Brusselator brusselator=new Brusselator(b);
    double[] y={1.3,b};
    integ.integrate(brusselator,0,y,20.0,y);
    double[] yP={1.3,b + hP};
    brusselator.setParameter(0,b + hP);
    integ.integrate(brusselator,0,yP,20.0,yP);
    residuals0.addValue((yP[0] - y[0]) / hP - brusselator.dYdP0());
    residuals1.addValue((yP[1] - y[1]) / hP - brusselator.dYdP1());
  }
  Assert.assertTrue((residuals0.getMax() - residuals0.getMin()) > 600);
  Assert.assertTrue(residuals0.getStandardDeviation() > 30);
  Assert.assertTrue((residuals1.getMax() - residuals1.getMin()) > 800);
  Assert.assertTrue(residuals1.getStandardDeviation() > 50);
}

Fixed version (ground truth):
@Test public void testLowAccuracyExternalDifferentiation() throws IntegratorException, DerivativeException {
  FirstOrderIntegrator integ=new DormandPrince54Integrator(1.0e-8,100.0,1.0e-4,1.0e-4);
  double hP=1.0e-12;
  SummaryStatistics residualsP0=new SummaryStatistics();
  SummaryStatistics residualsP1=new SummaryStatistics();
  for (double b=2.88; b < 3.08; b+=0.001) {
    Brusselator brusselator=new Brusselator(b);
    double[] y={1.3,b};
    integ.integrate(brusselator,0,y,20.0,y);
    double[] yP={1.3,b + hP};
    brusselator.setParameter(0,b + hP);
    integ.integrate(brusselator,0,yP,20.0,yP);
    residualsP0.addValue((yP[0] - y[0]) / hP - brusselator.dYdP0());
    residualsP1.addValue((yP[1] - y[1]) / hP - brusselator.dYdP1());
  }
  Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) > 600);
  Assert.assertTrue(residualsP0.getStandardDeviation() > 30);
  Assert.assertTrue((residualsP1.getMax() - residualsP1.getMin()) > 800);
  Assert.assertTrue(residualsP1.getStandardDeviation() > 50);
}
Program: 57412
Project: 57412
Buggy source:
@Test public void testHighAccuracyExternalDifferentiation() throws IntegratorException, DerivativeException {
  FirstOrderIntegrator integ=new DormandPrince54Integrator(1.0e-8,100.0,1.0e-10,1.0e-10);
  double hP=1.0e-12;
  SummaryStatistics residuals0=new SummaryStatistics();
  SummaryStatistics residuals1=new SummaryStatistics();
  for (double b=2.88; b < 3.08; b+=0.001) {
    Brusselator brusselator=new Brusselator(b);
    double[] y={1.3,b};
    integ.integrate(brusselator,0,y,20.0,y);
    double[] yP={1.3,b + hP};
    brusselator.setParameter(0,b + hP);
    integ.integrate(brusselator,0,yP,20.0,yP);
    residuals0.addValue((yP[0] - y[0]) / hP - brusselator.dYdP0());
    residuals1.addValue((yP[1] - y[1]) / hP - brusselator.dYdP1());
  }
  Assert.assertTrue((residuals0.getMax() - residuals0.getMin()) > 0.02);
  Assert.assertTrue((residuals0.getMax() - residuals0.getMin()) < 0.03);
  Assert.assertTrue(residuals0.getStandardDeviation() > 0.003);
  Assert.assertTrue(residuals0.getStandardDeviation() < 0.004);
  Assert.assertTrue((residuals1.getMax() - residuals1.getMin()) > 0.04);
  Assert.assertTrue((residuals1.getMax() - residuals1.getMin()) < 0.05);
  Assert.assertTrue(residuals1.getStandardDeviation() > 0.006);
  Assert.assertTrue(residuals1.getStandardDeviation() < 0.007);
}

Fixed version (ground truth):
@Test public void testHighAccuracyExternalDifferentiation() throws IntegratorException, DerivativeException {
  FirstOrderIntegrator integ=new DormandPrince54Integrator(1.0e-8,100.0,1.0e-10,1.0e-10);
  double hP=1.0e-12;
  SummaryStatistics residualsP0=new SummaryStatistics();
  SummaryStatistics residualsP1=new SummaryStatistics();
  for (double b=2.88; b < 3.08; b+=0.001) {
    Brusselator brusselator=new Brusselator(b);
    double[] y={1.3,b};
    integ.integrate(brusselator,0,y,20.0,y);
    double[] yP={1.3,b + hP};
    brusselator.setParameter(0,b + hP);
    integ.integrate(brusselator,0,yP,20.0,yP);
    residualsP0.addValue((yP[0] - y[0]) / hP - brusselator.dYdP0());
    residualsP1.addValue((yP[1] - y[1]) / hP - brusselator.dYdP1());
  }
  Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) > 0.02);
  Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) < 0.03);
  Assert.assertTrue(residualsP0.getStandardDeviation() > 0.003);
  Assert.assertTrue(residualsP0.getStandardDeviation() < 0.004);
  Assert.assertTrue((residualsP1.getMax() - residualsP1.getMin()) > 0.04);
  Assert.assertTrue((residualsP1.getMax() - residualsP1.getMin()) < 0.05);
  Assert.assertTrue(residualsP1.getStandardDeviation() > 0.006);
  Assert.assertTrue(residualsP1.getStandardDeviation() < 0.007);
}
Program: 57413
Project: 57413
Buggy source:
@Test public void testAnalyticalDifferentiation() throws IntegratorException, DerivativeException {
  FirstOrderIntegrator integ=new DormandPrince54Integrator(1.0e-8,100.0,1.0e-4,1.0e-4);
  SummaryStatistics residuals0=new SummaryStatistics();
  SummaryStatistics residuals1=new SummaryStatistics();
  for (double b=2.88; b < 3.08; b+=0.001) {
    Brusselator brusselator=new Brusselator(b);
    brusselator.setParameter(0,b);
    double[] z={1.3,b};
    double[][] dZdZ0=new double[2][2];
    double[][] dZdP=new double[2][1];
    FirstOrderIntegratorWithJacobians extInt=new FirstOrderIntegratorWithJacobians(integ,brusselator);
    extInt.integrate(0,z,new double[][]{{0.0},{1.0}},20.0,z,dZdZ0,dZdP);
    residuals0.addValue(dZdP[0][0] - brusselator.dYdP0());
    residuals1.addValue(dZdP[1][0] - brusselator.dYdP1());
  }
  Assert.assertTrue((residuals0.getMax() - residuals0.getMin()) < 0.004);
  Assert.assertTrue(residuals0.getStandardDeviation() < 0.001);
  Assert.assertTrue((residuals1.getMax() - residuals1.getMin()) < 0.005);
  Assert.assertTrue(residuals1.getStandardDeviation() < 0.001);
}

Fixed version (ground truth):
@Test public void testAnalyticalDifferentiation() throws IntegratorException, DerivativeException, OptimizationException {
  FirstOrderIntegrator integ=new DormandPrince54Integrator(1.0e-8,100.0,1.0e-10,1.0e-10);
  SummaryStatistics residualsP0=new SummaryStatistics();
  SummaryStatistics residualsP1=new SummaryStatistics();
  for (double b=2.88; b < 3.08; b+=0.001) {
    Brusselator brusselator=new Brusselator(b);
    brusselator.setParameter(0,b);
    double[] z={1.3,b};
    double[][] dZdZ0=new double[2][2];
    double[][] dZdP=new double[2][1];
    FirstOrderIntegratorWithJacobians extInt=new FirstOrderIntegratorWithJacobians(integ,brusselator);
    extInt.integrate(0,z,new double[][]{{0.0},{1.0}},20.0,z,dZdZ0,dZdP);
    residualsP0.addValue(dZdP[0][0] - brusselator.dYdP0());
    residualsP1.addValue(dZdP[1][0] - brusselator.dYdP1());
  }
  Assert.assertTrue((residualsP0.getMax() - residualsP0.getMin()) < 0.004);
  Assert.assertTrue(residualsP0.getStandardDeviation() < 0.0008);
  Assert.assertTrue((residualsP1.getMax() - residualsP1.getMin()) < 0.005);
  Assert.assertTrue(residualsP1.getStandardDeviation() < 0.0010);
}
Program: 57414
Project: 57414
Buggy source:
public double dYdP1(){
  return 1499.0904666097015 + (-1434.9574631810726 + (459.71079478756945 - 49.29949940968588 * b) * b) * b;
}

Fixed version (ground truth):
public double dYdP1(){
  return 1502.824469929139 + (-1438.6974831849952 + (460.959476642384 - 49.43847385647082 * b) * b) * b;
}
Program: 57415
Project: 57415
Buggy source:
/** 
 * <p> Multiplies the value of this fraction by another, returning the result in reduced form. </p>
 * @param fraction the fraction to multiply by, must not be <code>null</code>.
 * @return a {@link BigFraction} instance with the resulting values.
 * @throws NullPointerException if the fraction is <code>null</code>.
 */
public BigFraction multiply(final BigFraction fraction){
  BigFraction ret=ZERO;
  if (getNumeratorAsInt() != 0 && fraction.getNumeratorAsInt() != 0) {
    ret=new BigFraction(numerator.multiply(fraction.numerator),denominator.multiply(fraction.denominator));
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * <p> Multiplies the value of this fraction by another, returning the result in reduced form. </p>
 * @param fraction the fraction to multiply by, must not be <code>null</code>.
 * @return a {@link BigFraction} instance with the resulting values.
 * @throws NullPointerException if the fraction is <code>null</code>.
 */
public BigFraction multiply(final BigFraction fraction){
  if (numerator.equals(BigInteger.ZERO) || fraction.numerator.equals(BigInteger.ZERO)) {
    return ZERO;
  }
  return new BigFraction(numerator.multiply(fraction.numerator),denominator.multiply(fraction.denominator));
}
Program: 57416
Project: 57416
Buggy source:
protected OpenMapSparseIterator(){
  iter=entries.iterator();
  current=new OpenMapEntry(iter);
}

Fixed version (ground truth):
/** 
 * Simple constructor. 
 */
protected OpenMapSparseIterator(){
  iter=entries.iterator();
  current=new OpenMapEntry(iter);
}
Program: 57417
Project: 57417
Buggy source:
/** 
 * {@InheritDoc} 
 */
public boolean hasNext(){
  return iter.hasNext();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public boolean hasNext(){
  return iter.hasNext();
}
Program: 57418
Project: 57418
Buggy source:
protected OpenMapEntry(Iterator iter){
  this.iter=iter;
}

Fixed version (ground truth):
/** 
 * Build an entry from an iterator point to an element.
 * @param iter iterator pointing to the entry
 */
protected OpenMapEntry(Iterator iter){
  this.iter=iter;
}
Program: 57419
Project: 57419
Buggy source:
/** 
 * {@InheritDoc} 
 */
@Override public int getIndex(){
  return iter.key();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public int getIndex(){
  return iter.key();
}
Program: 57420
Project: 57420
Buggy source:
/** 
 * {@InheritDoc} 
 */
public Entry next(){
  iter.advance();
  return current;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public Entry next(){
  iter.advance();
  return current;
}
Program: 57421
Project: 57421
Buggy source:
/** 
 * @{InheritDoc } 
 */
public java.util.Iterator<Entry> sparseIterator(){
  return new OpenMapSparseIterator();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public java.util.Iterator<Entry> sparseIterator(){
  return new OpenMapSparseIterator();
}
Program: 57422
Project: 57422
Buggy source:
public void remove(){
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void remove(){
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 57423
Project: 57423
Buggy source:
/** 
 * {@InheritDoc} 
 */
@Override public double getValue(){
  return iter.value();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public double getValue(){
  return iter.value();
}
Program: 57424
Project: 57424
Buggy source:
/** 
 * {@InheritDoc} 
 */
@Override public void setValue(double value){
  entries.put(iter.key(),value);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public void setValue(double value){
  entries.put(iter.key(),value);
}
Program: 57426
Project: 57426
Buggy source:
/** 
 * Calculates the L<sub>2</sub> (Euclidean) distance between two points.
 * @param p1 the first point
 * @param p2 the second point
 * @return the L<sub>2</sub> distance between the two points
 */
public static double distance(int[] p1,int[] p2){
  int sum=0;
  for (int i=0; i < p1.length; i++) {
    final int dp=p1[i] - p2[i];
    sum+=dp * dp;
  }
  return Math.sqrt(sum);
}

Fixed version (ground truth):
/** 
 * Calculates the L<sub>2</sub> (Euclidean) distance between two points.
 * @param p1 the first point
 * @param p2 the second point
 * @return the L<sub>2</sub> distance between the two points
 */
public static double distance(int[] p1,int[] p2){
  double sum=0;
  for (int i=0; i < p1.length; i++) {
    final double dp=p1[i] - p2[i];
    sum+=dp * dp;
  }
  return Math.sqrt(sum);
}
Program: 57429
Project: 57429
Buggy source:
/** 
 * Flip qd array if warranted.
 * @param n number of rows in the block
 * @param step within the array (1 for flipping all elements, 2 for flippingonly every other element)
 * @return true if qd array was flipped
 */
private boolean flipIfWarranted(final int n,final int step){
  if (1.5 * work[pingPong] < work[4 * (n - 1) + pingPong]) {
    int j=4 * n - 1;
    for (int i=0; i < j; i+=4) {
      for (int k=0; k < 4; k+=step) {
        final double tmp=work[i + k];
        work[i + k]=work[j - k];
        work[j - k]=tmp;
      }
      j-=4;
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Flip qd array if warranted.
 * @param n number of rows in the block
 * @param step within the array (1 for flipping all elements, 2 for flippingonly every other element)
 * @return true if qd array was flipped
 */
private boolean flipIfWarranted(final int n,final int step){
  if (1.5 * work[pingPong] < work[4 * (n - 1) + pingPong]) {
    int j=4 * (n - 1);
    for (int i=0; i < j; i+=4) {
      for (int k=0; k < 4; k+=step) {
        final double tmp=work[i + k];
        work[i + k]=work[j - k];
        work[j - k]=tmp;
      }
      j-=4;
    }
    return true;
  }
  return false;
}
Program: 57430
Project: 57430
Buggy source:
/** 
 * Constructor
 * @param dfbg degrees of freedom in numerator (between groups)
 * @param dfwg degrees of freedom in denominator (within groups)
 * @param F statistic
 */
AnovaStats(int dfbg,int dfwg,double F){
  this.dfbg=dfbg;
  this.dfwg=dfwg;
  this.F=F;
}

Fixed version (ground truth):
/** 
 * Constructor
 * @param dfbg degrees of freedom in numerator (between groups)
 * @param dfwg degrees of freedom in denominator (within groups)
 * @param F statistic
 */
public AnovaStats(int dfbg,int dfwg,double F){
  this.dfbg=dfbg;
  this.dfwg=dfwg;
  this.F=F;
}
Program: 57431
Project: 57431
Buggy source:
/** 
 * Returns the row with the minimum ratio as given by the minimum ratio test (MRT).
 * @param tableau simple tableau for the problem
 * @param col the column to test the ratio of.  See {@link #getPivotColumn(SimplexTableau)}
 * @return row with the minimum ratio
 */
private Integer getPivotRow(final int col,final SimplexTableau tableau){
  double minRatio=Double.MAX_VALUE;
  Integer minRatioPos=null;
  for (int i=tableau.getNumObjectiveFunctions(); i < tableau.getHeight(); i++) {
    double rhs=tableau.getEntry(i,tableau.getWidth() - 1);
    if (MathUtils.compareTo(tableau.getEntry(i,col),0,epsilon) >= 0) {
      double ratio=rhs / tableau.getEntry(i,col);
      if (ratio < minRatio) {
        minRatio=ratio;
        minRatioPos=i;
      }
    }
  }
  return minRatioPos;
}

Fixed version (ground truth):
/** 
 * Returns the row with the minimum ratio as given by the minimum ratio test (MRT).
 * @param tableau simple tableau for the problem
 * @param col the column to test the ratio of.  See {@link #getPivotColumn(SimplexTableau)}
 * @return row with the minimum ratio
 */
private Integer getPivotRow(final int col,final SimplexTableau tableau){
  double minRatio=Double.MAX_VALUE;
  Integer minRatioPos=null;
  for (int i=tableau.getNumObjectiveFunctions(); i < tableau.getHeight(); i++) {
    final double rhs=tableau.getEntry(i,tableau.getWidth() - 1);
    final double entry=tableau.getEntry(i,col);
    if (MathUtils.compareTo(entry,0,epsilon) > 0) {
      final double ratio=rhs / entry;
      if (ratio < minRatio) {
        minRatio=ratio;
        minRatioPos=i;
      }
    }
  }
  return minRatioPos;
}
Program: 57433
Project: 57433
Buggy source:
/** 
 * Build a tableau for a linear problem.
 * @param f linear objective function
 * @param constraints linear constraints
 * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE}or   {@link GoalType#MINIMIZE}
 * @param restrictToNonNegative whether to restrict the variables to non-negative values
 * @param epsilon amount of error to accept in floating point comparisons
 */
SimplexTableau(final LinearObjectiveFunction f,final Collection<LinearConstraint> constraints,final GoalType goalType,final boolean restrictToNonNegative,final double epsilon){
  this.f=f;
  this.constraints=constraints;
  this.restrictToNonNegative=restrictToNonNegative;
  this.epsilon=epsilon;
  this.numDecisionVariables=getNumVariables() + (restrictToNonNegative ? 0 : 1);
  this.numSlackVariables=getConstraintTypeCounts(Relationship.LEQ) + getConstraintTypeCounts(Relationship.GEQ);
  this.numArtificialVariables=getConstraintTypeCounts(Relationship.EQ) + getConstraintTypeCounts(Relationship.GEQ);
  this.tableau=new Array2DRowRealMatrix(createTableau(goalType == GoalType.MAXIMIZE));
  initialize();
}

Fixed version (ground truth):
/** 
 * Build a tableau for a linear problem.
 * @param f linear objective function
 * @param constraints linear constraints
 * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE}or   {@link GoalType#MINIMIZE}
 * @param restrictToNonNegative whether to restrict the variables to non-negative values
 * @param epsilon amount of error to accept in floating point comparisons
 */
SimplexTableau(final LinearObjectiveFunction f,final Collection<LinearConstraint> constraints,final GoalType goalType,final boolean restrictToNonNegative,final double epsilon){
  this.f=f;
  this.constraints=normalizeConstraints(constraints);
  this.restrictToNonNegative=restrictToNonNegative;
  this.epsilon=epsilon;
  this.numDecisionVariables=getNumVariables() + (restrictToNonNegative ? 0 : 1);
  this.numSlackVariables=getConstraintTypeCounts(Relationship.LEQ) + getConstraintTypeCounts(Relationship.GEQ);
  this.numArtificialVariables=getConstraintTypeCounts(Relationship.EQ) + getConstraintTypeCounts(Relationship.GEQ);
  this.tableau=new Array2DRowRealMatrix(createTableau(goalType == GoalType.MAXIMIZE));
  initialize();
}