nus-yam/ex-repair huggingface dataset:
Program: 57476
Project: 57476
Buggy source:
/** 
 * Returns the natural <code>log</code> of the <a href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial Coefficient</a>, "<code>n choose k</code>", the number of <code>k</code>-element subsets that can be selected from an <code>n</code>-element set. <p> <Strong>Preconditions</strong>: <ul> <li> <code>0 <= k <= n </code> (otherwise <code>IllegalArgumentException</code> is thrown)</li> </ul></p>
 * @param n the size of the set
 * @param k the size of the subsets to be counted
 * @return <code>n choose k</code>
 * @throws IllegalArgumentException if preconditions are not met.
 */
public static double binomialCoefficientLog(final int n,final int k){
  if (n < k) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (n < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if ((n == k) || (k == 0)) {
    return 0;
  }
  if ((k == 1) || (k == n - 1)) {
    return Math.log((double)n);
  }
  double logSum=0;
  for (int i=k + 1; i <= n; i++) {
    logSum+=Math.log((double)i);
  }
  for (int i=2; i <= n - k; i++) {
    logSum-=Math.log((double)i);
  }
  return logSum;
}

Fixed version (ground truth):
/** 
 * Returns the natural <code>log</code> of the <a href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial Coefficient</a>, "<code>n choose k</code>", the number of <code>k</code>-element subsets that can be selected from an <code>n</code>-element set. <p> <Strong>Preconditions</strong>: <ul> <li> <code>0 <= k <= n </code> (otherwise <code>IllegalArgumentException</code> is thrown)</li> </ul></p>
 * @param n the size of the set
 * @param k the size of the subsets to be counted
 * @return <code>n choose k</code>
 * @throws IllegalArgumentException if preconditions are not met.
 */
public static double binomialCoefficientLog(final int n,final int k){
  if (n < k) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (n < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if ((n == k) || (k == 0)) {
    return 0;
  }
  if ((k == 1) || (k == n - 1)) {
    return Math.log((double)n);
  }
  if (n < 67) {
    return Math.log(binomialCoefficient(n,k));
  }
  if (n < 1030) {
    return Math.log(binomialCoefficientDouble(n,k));
  }
  double logSum=0;
  for (int i=k + 1; i <= n; i++) {
    logSum+=Math.log((double)i);
  }
  for (int i=2; i <= n - k; i++) {
    logSum-=Math.log((double)i);
  }
  return logSum;
}
Program: 57477
Project: 57477
Buggy source:
/** 
 * Returns a <code>double</code> representation of the <a href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial Coefficient</a>, "<code>n choose k</code>", the number of <code>k</code>-element subsets that can be selected from an <code>n</code>-element set. <p> <Strong>Preconditions</strong>: <ul> <li> <code>0 <= k <= n </code> (otherwise <code>IllegalArgumentException</code> is thrown)</li> <li> The result is small enough to fit into a <code>double</code>. The largest value of <code>n</code> for which all coefficients are < Double.MAX_VALUE is 1029. If the computed value exceeds Double.MAX_VALUE, Double.POSITIVE_INFINITY is returned</li> </ul></p>
 * @param n the size of the set
 * @param k the size of the subsets to be counted
 * @return <code>n choose k</code>
 * @throws IllegalArgumentException if preconditions are not met.
 */
public static double binomialCoefficientDouble(final int n,final int k){
  return Math.floor(Math.exp(binomialCoefficientLog(n,k)) + 0.5);
}

Fixed version (ground truth):
/** 
 * Returns a <code>double</code> representation of the <a href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial Coefficient</a>, "<code>n choose k</code>", the number of <code>k</code>-element subsets that can be selected from an <code>n</code>-element set. <p> <Strong>Preconditions</strong>: <ul> <li> <code>0 <= k <= n </code> (otherwise <code>IllegalArgumentException</code> is thrown)</li> <li> The result is small enough to fit into a <code>double</code>. The largest value of <code>n</code> for which all coefficients are < Double.MAX_VALUE is 1029. If the computed value exceeds Double.MAX_VALUE, Double.POSITIVE_INFINITY is returned</li> </ul></p>
 * @param n the size of the set
 * @param k the size of the subsets to be counted
 * @return <code>n choose k</code>
 * @throws IllegalArgumentException if preconditions are not met.
 */
public static double binomialCoefficientDouble(final int n,final int k){
  if (n < k) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (n < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if ((n == k) || (k == 0)) {
    return 1d;
  }
  if ((k == 1) || (k == n - 1)) {
    return n;
  }
  if (k > n / 2) {
    return binomialCoefficientDouble(n,n - k);
  }
  if (n < 67) {
    return binomialCoefficient(n,k);
  }
  double result=1d;
  for (int i=1; i <= k; i++) {
    result*=(double)(n - k + i) / (double)i;
  }
  return Math.floor(result + 0.5);
}
Program: 57479
Project: 57479
Buggy source:
/** 
 * Returns n!. Shorthand for <code>n</code> <a href="http://mathworld.wolfram.com/Factorial.html"> Factorial</a>, the product of the numbers <code>1,...,n</code>. <p> <Strong>Preconditions</strong>: <ul> <li> <code>n >= 0</code> (otherwise <code>IllegalArgumentException</code> is thrown)</li> <li> The result is small enough to fit into a <code>long</code>. The largest value of <code>n</code> for which <code>n!</code> < Long.MAX_VALUE</code> is 20. If the computed value exceeds <code>Long.MAX_VALUE</code> an <code>ArithMeticException </code> is thrown.</li> </ul> </p>
 * @param n argument
 * @return <code>n!</code>
 * @throws ArithmeticException if the result is too large to be representedby a long integer.
 * @throws IllegalArgumentException if n < 0
 */
public static long factorial(final int n){
  long result=Math.round(factorialDouble(n));
  if (result == Long.MAX_VALUE) {
    throw new ArithmeticException("String_Node_Str");
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Returns n!. Shorthand for <code>n</code> <a href="http://mathworld.wolfram.com/Factorial.html"> Factorial</a>, the product of the numbers <code>1,...,n</code>. <p> <Strong>Preconditions</strong>: <ul> <li> <code>n >= 0</code> (otherwise <code>IllegalArgumentException</code> is thrown)</li> <li> The result is small enough to fit into a <code>long</code>. The largest value of <code>n</code> for which <code>n!</code> < Long.MAX_VALUE</code> is 20. If the computed value exceeds <code>Long.MAX_VALUE</code> an <code>ArithMeticException </code> is thrown.</li> </ul> </p>
 * @param n argument
 * @return <code>n!</code>
 * @throws ArithmeticException if the result is too large to be representedby a long integer.
 * @throws IllegalArgumentException if n < 0
 */
public static long factorial(final int n){
  if (n < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (n > 20) {
    throw new ArithmeticException("String_Node_Str");
  }
  return factorials[n];
}
Program: 57480
Project: 57480
Buggy source:
/** 
 * Returns n!. Shorthand for <code>n</code> <a href="http://mathworld.wolfram.com/Factorial.html"> Factorial</a>, the product of the numbers <code>1,...,n</code> as a <code>double</code>. <p> <Strong>Preconditions</strong>: <ul> <li> <code>n >= 0</code> (otherwise <code>IllegalArgumentException</code> is thrown)</li> <li> The result is small enough to fit into a <code>double</code>. The largest value of <code>n</code> for which <code>n!</code> < Double.MAX_VALUE</code> is 170. If the computed value exceeds Double.MAX_VALUE, Double.POSITIVE_INFINITY is returned</li> </ul> </p>
 * @param n argument
 * @return <code>n!</code>
 * @throws IllegalArgumentException if n < 0
 */
public static double factorialDouble(final int n){
  if (n < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return Math.floor(Math.exp(factorialLog(n)) + 0.5);
}

Fixed version (ground truth):
/** 
 * Returns n!. Shorthand for <code>n</code> <a href="http://mathworld.wolfram.com/Factorial.html"> Factorial</a>, the product of the numbers <code>1,...,n</code> as a <code>double</code>. <p> <Strong>Preconditions</strong>: <ul> <li> <code>n >= 0</code> (otherwise <code>IllegalArgumentException</code> is thrown)</li> <li> The result is small enough to fit into a <code>double</code>. The largest value of <code>n</code> for which <code>n!</code> < Double.MAX_VALUE</code> is 170. If the computed value exceeds Double.MAX_VALUE, Double.POSITIVE_INFINITY is returned</li> </ul> </p>
 * @param n argument
 * @return <code>n!</code>
 * @throws IllegalArgumentException if n < 0
 */
public static double factorialDouble(final int n){
  if (n < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (n < 21) {
    return factorial(n);
  }
  return Math.floor(Math.exp(factorialLog(n)) + 0.5);
}
Program: 57481
Project: 57481
Buggy source:
/** 
 * Returns the natural logarithm of n!. <p> <Strong>Preconditions</strong>: <ul> <li> <code>n >= 0</code> (otherwise <code>IllegalArgumentException</code> is thrown)</li> </ul></p>
 * @param n argument
 * @return <code>n!</code>
 * @throws IllegalArgumentException if preconditions are not met.
 */
public static double factorialLog(final int n){
  if (n < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  double logSum=0;
  for (int i=2; i <= n; i++) {
    logSum+=Math.log((double)i);
  }
  return logSum;
}

Fixed version (ground truth):
/** 
 * Returns the natural logarithm of n!. <p> <Strong>Preconditions</strong>: <ul> <li> <code>n >= 0</code> (otherwise <code>IllegalArgumentException</code> is thrown)</li> </ul></p>
 * @param n argument
 * @return <code>n!</code>
 * @throws IllegalArgumentException if preconditions are not met.
 */
public static double factorialLog(final int n){
  if (n < 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (n < 21) {
    return Math.log(factorial(n));
  }
  double logSum=0;
  for (int i=2; i <= n; i++) {
    logSum+=Math.log((double)i);
  }
  return logSum;
}
Program: 57482
Project: 57482
Buggy source:
/** 
 * <p> Gets the greatest common divisor of the absolute value of two numbers, using the "binary gcd" method which avoids division and modulo operations. See Knuth 4.5.2 algorithm B. This algorithm is due to Josef Stein (1961). </p>
 * @param u a non-zero number
 * @param v a non-zero number
 * @return the greatest common divisor, never zero
 * @since 1.1
 */
public static int gcd(int u,int v){
  if (u * v == 0) {
    return (Math.abs(u) + Math.abs(v));
  }
  if (u > 0) {
    u=-u;
  }
  if (v > 0) {
    v=-v;
  }
  int k=0;
  while ((u & 1) == 0 && (v & 1) == 0 && k < 31) {
    u/=2;
    v/=2;
    k++;
  }
  if (k == 31) {
    throw new ArithmeticException("String_Node_Str");
  }
  int t=((u & 1) == 1) ? v : -(u / 2);
  do {
    while ((t & 1) == 0) {
      t/=2;
    }
    if (t > 0) {
      u=-t;
    }
 else {
      v=t;
    }
    t=(v - u) / 2;
  }
 while (t != 0);
  return -u * (1 << k);
}

Fixed version (ground truth):
/** 
 * <p> Gets the greatest common divisor of the absolute value of two numbers, using the "binary gcd" method which avoids division and modulo operations. See Knuth 4.5.2 algorithm B. This algorithm is due to Josef Stein (1961). </p>
 * @param u a non-zero number
 * @param v a non-zero number
 * @return the greatest common divisor, never zero
 * @since 1.1
 */
public static int gcd(int u,int v){
  if ((u == 0) || (v == 0)) {
    return (Math.abs(u) + Math.abs(v));
  }
  if (u > 0) {
    u=-u;
  }
  if (v > 0) {
    v=-v;
  }
  int k=0;
  while ((u & 1) == 0 && (v & 1) == 0 && k < 31) {
    u/=2;
    v/=2;
    k++;
  }
  if (k == 31) {
    throw new ArithmeticException("String_Node_Str");
  }
  int t=((u & 1) == 1) ? v : -(u / 2);
  do {
    while ((t & 1) == 0) {
      t/=2;
    }
    if (t > 0) {
      u=-t;
    }
 else {
      v=t;
    }
    t=(v - u) / 2;
  }
 while (t != 0);
  return -u * (1 << k);
}
Program: 57483
Project: 57483
Buggy source:
/** 
 * {@inheritDoc} 
 */
public RealMatrix getQT() throws IllegalStateException {
  if (cachedQT == null) {
    final int n=qrt.length;
    final int m=qrt[0].length;
    cachedQT=MatrixUtils.createRealMatrix(m,m);
    for (int minor=m - 1; minor >= Math.min(m,n); minor--) {
      cachedQT.setEntry(minor,minor,1.0);
    }
    for (int minor=Math.min(m,n) - 1; minor >= 0; minor--) {
      final double[] qrtMinor=qrt[minor];
      cachedQT.setEntry(minor,minor,1.0);
      if (qrtMinor[minor] != 0.0) {
        for (int col=minor; col < m; col++) {
          double alpha=0;
          for (int row=minor; row < m; row++) {
            alpha-=cachedQT.getEntry(col,row) * qrtMinor[row];
          }
          alpha/=rDiag[minor] * qrtMinor[minor];
          for (int row=minor; row < m; row++) {
            cachedQT.addToEntry(col,row,-alpha * qrtMinor[row]);
          }
        }
      }
    }
  }
  return cachedQT;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public RealMatrix getQT(){
  if (cachedQT == null) {
    final int n=qrt.length;
    final int m=qrt[0].length;
    cachedQT=MatrixUtils.createRealMatrix(m,m);
    for (int minor=m - 1; minor >= Math.min(m,n); minor--) {
      cachedQT.setEntry(minor,minor,1.0);
    }
    for (int minor=Math.min(m,n) - 1; minor >= 0; minor--) {
      final double[] qrtMinor=qrt[minor];
      cachedQT.setEntry(minor,minor,1.0);
      if (qrtMinor[minor] != 0.0) {
        for (int col=minor; col < m; col++) {
          double alpha=0;
          for (int row=minor; row < m; row++) {
            alpha-=cachedQT.getEntry(col,row) * qrtMinor[row];
          }
          alpha/=rDiag[minor] * qrtMinor[minor];
          for (int row=minor; row < m; row++) {
            cachedQT.addToEntry(col,row,-alpha * qrtMinor[row]);
          }
        }
      }
    }
  }
  return cachedQT;
}
Program: 57484
Project: 57484
Buggy source:
/** 
 * {@inheritDoc} 
 */
public RealMatrix getH() throws IllegalStateException {
  if (cachedH == null) {
    final int n=qrt.length;
    final int m=qrt[0].length;
    cachedH=MatrixUtils.createRealMatrix(m,n);
    for (int i=0; i < m; ++i) {
      for (int j=0; j < Math.min(i + 1,n); ++j) {
        cachedH.setEntry(i,j,qrt[j][i] / -rDiag[j]);
      }
    }
  }
  return cachedH;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public RealMatrix getH(){
  if (cachedH == null) {
    final int n=qrt.length;
    final int m=qrt[0].length;
    cachedH=MatrixUtils.createRealMatrix(m,n);
    for (int i=0; i < m; ++i) {
      for (int j=0; j < Math.min(i + 1,n); ++j) {
        cachedH.setEntry(i,j,qrt[j][i] / -rDiag[j]);
      }
    }
  }
  return cachedH;
}
Program: 57485
Project: 57485
Buggy source:
/** 
 * {@inheritDoc} 
 */
public RealMatrix getInverse() throws IllegalStateException, InvalidMatrixException {
  return solve(MatrixUtils.createRealIdentityMatrix(rDiag.length));
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public RealMatrix getInverse() throws InvalidMatrixException {
  return solve(MatrixUtils.createRealIdentityMatrix(rDiag.length));
}
Program: 57486
Project: 57486
Buggy source:
/** 
 * Calculates the QR-decomposition of the given matrix.  <p>Calling this constructor is equivalent to first call the no-arguments constructor and then call   {@link #decompose(RealMatrix)}.</p>
 * @param matrix The matrix to decompose.
 */
public QRDecompositionImpl(RealMatrix matrix){
  final int m=matrix.getRowDimension();
  final int n=matrix.getColumnDimension();
  qrt=matrix.transpose().getData();
  rDiag=new double[n];
  cachedQ=null;
  cachedQT=null;
  cachedR=null;
  cachedH=null;
  for (int minor=0; minor < Math.min(m,n); minor++) {
    final double[] qrtMinor=qrt[minor];
    double xNormSqr=0;
    for (int row=minor; row < m; row++) {
      final double c=qrtMinor[row];
      xNormSqr+=c * c;
    }
    final double a=(qrtMinor[minor] > 0) ? -Math.sqrt(xNormSqr) : Math.sqrt(xNormSqr);
    rDiag[minor]=a;
    if (a != 0.0) {
      qrtMinor[minor]-=a;
      for (int col=minor + 1; col < n; col++) {
        final double[] qrtCol=qrt[col];
        double alpha=0;
        for (int row=minor; row < m; row++) {
          alpha-=qrtCol[row] * qrtMinor[row];
        }
        alpha/=a * qrtMinor[minor];
        for (int row=minor; row < m; row++) {
          qrtCol[row]-=alpha * qrtMinor[row];
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Calculates the QR-decomposition of the given matrix.  <p>Calling this constructor is equivalent to first call the no-arguments constructor and then call   {@link #decompose(RealMatrix)}.</p>
 * @param matrix The matrix to decompose.
 */
public QRDecompositionImpl(RealMatrix matrix){
  final int m=matrix.getRowDimension();
  final int n=matrix.getColumnDimension();
  qrt=matrix.transpose().getData();
  rDiag=new double[Math.min(m,n)];
  cachedQ=null;
  cachedQT=null;
  cachedR=null;
  cachedH=null;
  for (int minor=0; minor < Math.min(m,n); minor++) {
    final double[] qrtMinor=qrt[minor];
    double xNormSqr=0;
    for (int row=minor; row < m; row++) {
      final double c=qrtMinor[row];
      xNormSqr+=c * c;
    }
    final double a=(qrtMinor[minor] > 0) ? -Math.sqrt(xNormSqr) : Math.sqrt(xNormSqr);
    rDiag[minor]=a;
    if (a != 0.0) {
      qrtMinor[minor]-=a;
      for (int col=minor + 1; col < n; col++) {
        final double[] qrtCol=qrt[col];
        double alpha=0;
        for (int row=minor; row < m; row++) {
          alpha-=qrtCol[row] * qrtMinor[row];
        }
        alpha/=a * qrtMinor[minor];
        for (int row=minor; row < m; row++) {
          qrtCol[row]-=alpha * qrtMinor[row];
        }
      }
    }
  }
}
Program: 57488
Project: 57488
Buggy source:
/** 
 * {@inheritDoc} 
 */
public boolean isNonSingular() throws IllegalStateException {
  for (  double diag : rDiag) {
    if (diag == 0) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public boolean isNonSingular(){
  for (  double diag : rDiag) {
    if (diag == 0) {
      return false;
    }
  }
  return true;
}
Program: 57489
Project: 57489
Buggy source:
/** 
 * {@inheritDoc} 
 */
public RealMatrix getQ() throws IllegalStateException {
  if (cachedQ == null) {
    cachedQ=getQT().transpose();
  }
  return cachedQ;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public RealMatrix getQ(){
  if (cachedQ == null) {
    cachedQ=getQT().transpose();
  }
  return cachedQ;
}
Program: 57491
Project: 57491
Buggy source:
public static RealMatrix createOrthogonalMatrix(final Random r,final int size){
  final double[][] data=new double[size][size];
  for (int i=0; i < size; ++i) {
    final double[] dataI=data[i];
    double norm2=0;
    do {
      for (int j=0; j < size; ++j) {
        dataI[j]=2 * r.nextDouble() - 1;
      }
      for (int k=0; k < i; ++k) {
        final double[] dataK=data[k];
        double dotProduct=0;
        for (int j=0; j < size; ++j) {
          dotProduct+=dataI[j] * dataK[j];
        }
        for (int j=0; j < size; ++j) {
          dataI[j]-=dotProduct * dataK[j];
        }
      }
      norm2=0;
      for (      final double dataIJ : dataI) {
        norm2+=dataIJ * dataIJ;
      }
      final double inv=1.0 / Math.sqrt(norm2);
      for (int j=0; j < size; ++j) {
        dataI[j]*=inv;
      }
    }
 while (norm2 * size < 0.01);
  }
  return new RealMatrixImpl(data,false);
}

Fixed version (ground truth):
public static RealMatrix createOrthogonalMatrix(final Random r,final int size){
  final double[][] data=new double[size][size];
  for (int i=0; i < size; ++i) {
    final double[] dataI=data[i];
    double norm2=0;
    do {
      for (int j=0; j < size; ++j) {
        dataI[j]=2 * r.nextDouble() - 1;
      }
      for (int k=0; k < i; ++k) {
        final double[] dataK=data[k];
        double dotProduct=0;
        for (int j=0; j < size; ++j) {
          dotProduct+=dataI[j] * dataK[j];
        }
        for (int j=0; j < size; ++j) {
          dataI[j]-=dotProduct * dataK[j];
        }
      }
      norm2=0;
      for (      final double dataIJ : dataI) {
        norm2+=dataIJ * dataIJ;
      }
      final double inv=1.0 / Math.sqrt(norm2);
      for (int j=0; j < size; ++j) {
        dataI[j]*=inv;
      }
    }
 while (norm2 * size < 0.01);
  }
  return MatrixUtils.createRealMatrix(data);
}
Program: 57492
Project: 57492
Buggy source:
/** 
 * test eigenvectors 
 */
public void testEigenvectors(){
  EigenDecomposition ed=new EigenDecompositionImpl(matrix,MathUtils.SAFE_MIN);
  for (int i=0; i < matrix.getRowDimension(); ++i) {
    double lambda=ed.getEigenvalue(i);
    RealVector v=ed.getEigenvector(i);
    RealVector mV=matrix.operate(v);
    assertEquals(0,mV.subtract(v.mapMultiplyToSelf(lambda)).getNorm(),1.0e-13);
  }
}

Fixed version (ground truth):
/** 
 * test eigenvectors 
 */
public void testEigenvectors(){
  EigenDecomposition ed=new EigenDecompositionImpl(matrix,MathUtils.SAFE_MIN);
  for (int i=0; i < matrix.getRowDimension(); ++i) {
    double lambda=ed.getEigenvalue(i);
    RealVector v=ed.getEigenvector(i);
    RealVector mV=matrix.operate(v);
    System.out.println(lambda + "String_Node_Str" + v+ "String_Node_Str"+ mV);
    assertEquals(0,mV.subtract(v.mapMultiplyToSelf(lambda)).getNorm(),1.0e-13);
  }
}
Program: 57493
Project: 57493
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void setSubMatrix(final double[][] subMatrix,final int row,final int column) throws MatrixIndexException {
  if (data == null) {
    if (row > 0) {
      throw MathRuntimeException.createIllegalStateException("String_Node_Str",new Object[]{row});
    }
    if (column > 0) {
      throw MathRuntimeException.createIllegalStateException("String_Node_Str",new Object[]{column});
    }
    data=new double[subMatrix.length][subMatrix[0].length];
    for (int i=0; i < data.length; ++i) {
      System.arraycopy(subMatrix[i],0,data[i],0,subMatrix[i].length);
    }
  }
 else {
    super.setSubMatrix(subMatrix,row,column);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void setSubMatrix(final double[][] subMatrix,final int row,final int column) throws MatrixIndexException {
  if (data == null) {
    if (row > 0) {
      throw MathRuntimeException.createIllegalStateException("String_Node_Str",new Object[]{row});
    }
    if (column > 0) {
      throw MathRuntimeException.createIllegalStateException("String_Node_Str",new Object[]{column});
    }
    final int nRows=subMatrix.length;
    if (nRows == 0) {
      throw MathRuntimeException.createIllegalArgumentException("String_Node_Str",null);
    }
    final int nCols=subMatrix[0].length;
    if (nCols == 0) {
      throw MathRuntimeException.createIllegalArgumentException("String_Node_Str",null);
    }
    data=new double[subMatrix.length][nCols];
    for (int i=0; i < data.length; ++i) {
      if (subMatrix[i].length != nCols) {
        throw MathRuntimeException.createIllegalArgumentException("String_Node_Str",new Object[]{nCols,subMatrix[i].length});
      }
      System.arraycopy(subMatrix[i],0,data[i + row],column,nCols);
    }
  }
 else {
    super.setSubMatrix(subMatrix,row,column);
  }
}
Program: 57494
Project: 57494
Buggy source:
/** 
 * {@inheritDoc} 
 */
public RealMatrix getQT() throws IllegalStateException {
  if (cachedQ == null) {
    checkDecomposed();
    final int n=qrt.length;
    final int m=qrt[0].length;
    double[][] qT=new double[m][m];
    for (int minor=m - 1; minor >= Math.min(m,n); minor--) {
      qT[minor][minor]=1;
    }
    for (int minor=Math.min(m,n) - 1; minor >= 0; minor--) {
      final double[] qrtMinor=qrt[minor];
      qT[minor][minor]=1;
      if (qrtMinor[minor] != 0.0) {
        for (int col=minor; col < m; col++) {
          final double[] qTCol=qT[col];
          double alpha=0;
          for (int row=minor; row < m; row++) {
            alpha-=qTCol[row] * qrtMinor[row];
          }
          alpha/=rDiag[minor] * qrtMinor[minor];
          for (int row=minor; row < m; row++) {
            qTCol[row]-=alpha * qrtMinor[row];
          }
        }
      }
    }
    cachedQT=new RealMatrixImpl(qT,false);
  }
  return cachedQT;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public RealMatrix getQT() throws IllegalStateException {
  if (cachedQT == null) {
    checkDecomposed();
    final int n=qrt.length;
    final int m=qrt[0].length;
    double[][] qT=new double[m][m];
    for (int minor=m - 1; minor >= Math.min(m,n); minor--) {
      qT[minor][minor]=1;
    }
    for (int minor=Math.min(m,n) - 1; minor >= 0; minor--) {
      final double[] qrtMinor=qrt[minor];
      qT[minor][minor]=1;
      if (qrtMinor[minor] != 0.0) {
        for (int col=minor; col < m; col++) {
          final double[] qTCol=qT[col];
          double alpha=0;
          for (int row=minor; row < m; row++) {
            alpha-=qTCol[row] * qrtMinor[row];
          }
          alpha/=rDiag[minor] * qrtMinor[minor];
          for (int row=minor; row < m; row++) {
            qTCol[row]-=alpha * qrtMinor[row];
          }
        }
      }
    }
    cachedQT=new RealMatrixImpl(qT,false);
  }
  return cachedQT;
}
Program: 57495
Project: 57495
Buggy source:
/** 
 * Constructs a VectorialMean.
 * @param dimension vectors dimension
 * @param isBiasCorrected if true, computed the unbiased sample covariance,otherwise computes the biased population covariance
 */
public VectorialCovariance(int dimension,boolean isBiasCorrected){
  sums=new double[dimension];
  productsSums=new double[dimension * (dimension + 1) / 2];
  n=0;
  this.isBiasCorrected=isBiasCorrected;
}

Fixed version (ground truth):
/** 
 * Constructs a VectorialCovariance.
 * @param dimension vectors dimension
 * @param isBiasCorrected if true, computed the unbiased sample covariance,otherwise computes the biased population covariance
 */
public VectorialCovariance(int dimension,boolean isBiasCorrected){
  sums=new double[dimension];
  productsSums=new double[dimension * (dimension + 1) / 2];
  n=0;
  this.isBiasCorrected=isBiasCorrected;
}
Program: 57498
Project: 57498
Buggy source:
/** 
 * {@inheritDoc} 
 */
public void setInterpolatedTime(final double time) throws DerivativeException {
  interpolatedTime=time;
  final double oneMinusThetaH=currentTime - interpolatedTime;
  computeInterpolatedState((h - oneMinusThetaH) / h,oneMinusThetaH);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public void setInterpolatedTime(final double time) throws DerivativeException {
  interpolatedTime=time;
  final double oneMinusThetaH=currentTime - interpolatedTime;
  final double theta=(h == 0) ? 0 : (h - oneMinusThetaH) / h;
  computeInterpolatedState(theta,oneMinusThetaH);
}
Program: 57499
Project: 57499
Buggy source:
/** 
 * Add an event handler for end time checking. <p>This method can be used to simplify handling of integration end time. It leverages the nominal stop condition with the exceptional stop conditions.</p>
 * @param endTime desired end time
 * @param manager manager containing the user-defined handlers
 * @return a new manager containing all the user-defined handlers plus adedicated manager triggering a stop event at entTime
 */
protected CombinedEventsManager addEndTimeChecker(final double endTime,final CombinedEventsManager manager){
  CombinedEventsManager newManager=new CombinedEventsManager();
  for (  final EventState state : manager.getEventsStates()) {
    newManager.addEventHandler(state.getEventHandler(),state.getMaxCheckInterval(),state.getConvergence(),state.getMaxIterationCount());
  }
  newManager.addEventHandler(new EndTimeChecker(endTime),Double.POSITIVE_INFINITY,Math.ulp(endTime),10);
  return newManager;
}

Fixed version (ground truth):
/** 
 * Add an event handler for end time checking. <p>This method can be used to simplify handling of integration end time. It leverages the nominal stop condition with the exceptional stop conditions.</p>
 * @param startTime integration start time
 * @param endTime desired end time
 * @param manager manager containing the user-defined handlers
 * @return a new manager containing all the user-defined handlers plus adedicated manager triggering a stop event at entTime
 */
protected CombinedEventsManager addEndTimeChecker(final double startTime,final double endTime,final CombinedEventsManager manager){
  CombinedEventsManager newManager=new CombinedEventsManager();
  for (  final EventState state : manager.getEventsStates()) {
    newManager.addEventHandler(state.getEventHandler(),state.getMaxCheckInterval(),state.getConvergence(),state.getMaxIterationCount());
  }
  newManager.addEventHandler(new EndTimeChecker(endTime),Double.POSITIVE_INFINITY,Math.ulp(Math.max(Math.abs(startTime),Math.abs(endTime))),100);
  return newManager;
}
Program: 57502
Project: 57502
Buggy source:
/** 
 * Compute the backward differences coefficients array. <p>This is quite similar to the Pascal triangle, except for a (-1)<sup>i</sup> sign. We use a straightforward approach here, since we don't expect this to be run too many times with too high k. It is based on the recurrence relations:</p> <pre> &nabla;<sup>0</sup> f<sub>n</sub> = f<sub>n</sub> &nabla;<sup>i+1</sup> f<sub>n</sub> = &nabla;<sup>i</sup>f<sub>n</sub> - &nabla;<sup>i</sup>f<sub>n-1</sub> </pre>
 * @param order order of the integration method
 */
static int[][] computeBackwardDifferencesArray(final int order){
  int[][] bdArray=new int[order][];
  bdArray[0]=new int[]{1};
  for (int i=1; i < order; ++i) {
    bdArray[i]=new int[i + 1];
    bdArray[i][0]=1;
    for (int j=0; j < i - 1; ++j) {
      bdArray[i][j + 1]=bdArray[i - 1][j + 1] - bdArray[i - 1][j];
    }
    bdArray[i][i]=-bdArray[i - 1][i - 1];
  }
  return bdArray;
}

Fixed version (ground truth):
/** 
 * Compute the backward differences coefficients array. <p>This is quite similar to the Pascal triangle containing the binomial coefficiens, except for an additional (-1)<sup>i</sup> sign. We use a straightforward approach here, since we don't expect this to be run too many times with too high k. It is based on the recurrence relations:</p> <pre> &nabla;<sup>0</sup> f<sub>n</sub> = f<sub>n</sub> &nabla;<sup>i+1</sup> f<sub>n</sub> = &nabla;<sup>i</sup>f<sub>n</sub> - &nabla;<sup>i</sup>f<sub>n-1</sub> </pre>
 * @param order order of the integration method
 * @return the coefficients array for backward differences
 */
static int[][] computeBackwardDifferencesArray(final int order){
  int[][] bdArray=new int[order][];
  bdArray[0]=new int[]{1};
  for (int i=1; i < order; ++i) {
    bdArray[i]=new int[i + 1];
    bdArray[i][0]=1;
    for (int j=0; j < i - 1; ++j) {
      bdArray[i][j + 1]=bdArray[i - 1][j + 1] - bdArray[i - 1][j];
    }
    bdArray[i][i]=-bdArray[i - 1][i - 1];
  }
  return bdArray;
}
Program: 57503
Project: 57503
Buggy source:
/** 
 * Truncate a step. <p>Truncating a step is necessary when an event is triggered before the nominal end of the step.</p>
 */
void truncateStep(final double truncatedEndTime){
  currentTime=truncatedEndTime;
  h=currentTime - previousTime;
}

Fixed version (ground truth):
/** 
 * Truncate a step. <p>Truncating a step is necessary when an event is triggered before the nominal end of the step.</p>
 * @param truncatedEndTime end time of truncated step
 */
void truncateStep(final double truncatedEndTime){
  currentTime=truncatedEndTime;
  h=currentTime - previousTime;
}
Program: 57504
Project: 57504
Buggy source:
/** 
 * Truncate a step. <p>Truncating a step is necessary when an event is triggered before the nominal end of the step.</p>
 */
void truncateStep(final double truncatedEndTime){
  currentTime=truncatedEndTime;
  h=currentTime - previousTime;
}

Fixed version (ground truth):
/** 
 * Truncate a step. <p>Truncating a step is necessary when an event is triggered before the nominal end of the step.</p>
 * @param truncatedEndTime end time of truncated step
 */
void truncateStep(final double truncatedEndTime){
  currentTime=truncatedEndTime;
  h=currentTime - previousTime;
}
Program: 57505
Project: 57505
Buggy source:
/** 
 * Build a new instance.
 * @param number of steps to store
 */
public StoringStepHandler(final int n){
  this.n=n;
  restart();
}

Fixed version (ground truth):
/** 
 * Build a new instance.
 * @param n number of steps to store
 */
public StoringStepHandler(final int n){
  this.n=n;
  restart();
}
Program: 57506
Project: 57506
Buggy source:
/** 
 * @param v vector to operate on
 * @throws IllegalArgumentException if columnDimension != v.length
 * @return resulting vector
 */
public double[] operate(double[] v) throws IllegalArgumentException {
  final int nRows=this.getRowDimension();
  final int nCols=this.getColumnDimension();
  if (v.length != nCols) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final double[] out=new double[v.length];
  for (int row=0; row < nRows; row++) {
    final double[] dataRow=data[row];
    double sum=0;
    for (int i=0; i < nCols; i++) {
      sum+=dataRow[i] * v[i];
    }
    out[row]=sum;
  }
  return out;
}

Fixed version (ground truth):
/** 
 * @param v vector to operate on
 * @throws IllegalArgumentException if columnDimension != v.length
 * @return resulting vector
 */
public double[] operate(double[] v) throws IllegalArgumentException {
  final int nRows=this.getRowDimension();
  final int nCols=this.getColumnDimension();
  if (v.length != nCols) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final double[] out=new double[nRows];
  for (int row=0; row < nRows; row++) {
    final double[] dataRow=data[row];
    double sum=0;
    for (int i=0; i < nCols; i++) {
      sum+=dataRow[i] * v[i];
    }
    out[row]=sum;
  }
  return out;
}
Program: 57507
Project: 57507
Buggy source:
/** 
 * @see org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic#getResult()
 */
public abstract double getResult();

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public abstract double getResult();
Program: 57508
Project: 57508
Buggy source:
/** 
 * @see org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic#clear()
 */
public abstract void clear();

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public abstract void clear();
Program: 57509
Project: 57509
Buggy source:
/** 
 * @see org.apache.commons.math.stat.descriptive.StorelessUnivariateStatistic#increment(double)
 */
public abstract void increment(final double d);

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public abstract void increment(final double d);
Program: 57510
Project: 57510
Buggy source:
/** 
 * This default implementation calls   {@link #clear}, then invokes   {@link #increment} in a loop over the specified portion of the input array, and then uses  {@link #getResult} to compute the return value.  <p> Note that this implementation changes the internal state of the statistic.  Its side effects are the same as invoking  {@link #clear} andthen  {@link #incrementAll(double[],int,int)}.</p> <p> Implementations may override this method with a more efficient and possibly more accurate implementation that works directly with the input array.</p> <p> If the array is null or the index parameters are not valid, an  IllegalArgumentException is thrown.</p>
 * @see org.apache.commons.math.stat.descriptive.UnivariateStatistic#evaluate(double[],int,int)
 */
public double evaluate(final double[] values,final int begin,final int length){
  if (test(values,begin,length)) {
    clear();
    incrementAll(values,begin,length);
  }
  return getResult();
}

Fixed version (ground truth):
/** 
 * This default implementation calls   {@link #clear}, then invokes   {@link #increment} in a loop over the specified portion of the input array, and then uses  {@link #getResult} to compute the return value.  <p> Note that this implementation changes the internal state of the statistic.  Its side effects are the same as invoking  {@link #clear} andthen  {@link #incrementAll(double[],int,int)}.</p> <p> Implementations may override this method with a more efficient and possibly more accurate implementation that works directly with the input array.</p> <p> If the array is null or the index parameters are not valid, an  IllegalArgumentException is thrown.</p>
 * @param values the input array
 * @param begin the index of the first element to include
 * @param length the number of elements to include
 * @return the value of the statistic applied to the included array entries
 * @see org.apache.commons.math.stat.descriptive.UnivariateStatistic#evaluate(double[],int,int)
 */
public double evaluate(final double[] values,final int begin,final int length){
  if (test(values,begin,length)) {
    clear();
    incrementAll(values,begin,length);
  }
  return getResult();
}
Program: 57511
Project: 57511
Buggy source:
/** 
 * @see org.apache.commons.math.stat.descriptive.UnivariateStatistic#evaluate(double[],int,int)
 */
public abstract double evaluate(final double[] values,final int begin,final int length);

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public abstract double evaluate(final double[] values,final int begin,final int length);
Program: 57512
Project: 57512
Buggy source:
/** 
 * @see org.apache.commons.math.stat.descriptive.DescriptiveStatistics#getValues()
 */
public synchronized double[] getValues(){
  return super.getValues();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public synchronized double[] getValues(){
  return super.getValues();
}
Program: 57513
Project: 57513
Buggy source:
/** 
 * @see org.apache.commons.math.stat.descriptive.DescriptiveStatistics#getElement(int)
 */
public synchronized double getElement(int index){
  return super.getElement(index);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public synchronized double getElement(int index){
  return super.getElement(index);
}
Program: 57514
Project: 57514
Buggy source:
/** 
 * @see org.apache.commons.math.stat.descriptive.DescriptiveStatistics#clear()
 */
public synchronized void clear(){
  super.clear();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public synchronized void clear(){
  super.clear();
}
Program: 57515
Project: 57515
Buggy source:
/** 
 * @see org.apache.commons.math.stat.descriptive.DescriptiveStatistics#getN()
 */
public synchronized long getN(){
  return super.getN();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public synchronized long getN(){
  return super.getN();
}
Program: 57516
Project: 57516
Buggy source:
/** 
 * @see org.apache.commons.math.stat.descriptive.DescriptiveStatistics#setWindowSize(int)
 */
public synchronized void setWindowSize(int windowSize){
  super.setWindowSize(windowSize);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public synchronized void setWindowSize(int windowSize){
  super.setWindowSize(windowSize);
}
Program: 57517
Project: 57517
Buggy source:
/** 
 * @see org.apache.commons.math.stat.descriptive.DescriptiveStatistics#addValue(double)
 */
public synchronized void addValue(double v){
  super.addValue(v);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public synchronized void addValue(double v){
  super.addValue(v);
}
Program: 57518
Project: 57518
Buggy source:
/** 
 * Computes p-value for 2-sided, 2-sample t-test, under the assumption of equal subpopulation variances. <p> The sum of the sample sizes minus 2 is used as degrees of freedom.</p>
 * @param m1 first sample mean
 * @param m2 second sample mean
 * @param v1 first sample variance
 * @param v2 second sample variance
 * @param n1 first sample n
 * @param n2 second sample n
 * @return p-value
 * @throws MathException if an error occurs computing the p-value
 */
protected double homoscedasticTTest(double m1,double m2,double v1,double v2,double n1,double n2) throws MathException {
  double t=Math.abs(homoscedasticT(m1,m2,v1,v2,n1,n2));
  double degreesOfFreedom=(double)(n1 + n2 - 2);
  distribution.setDegreesOfFreedom(degreesOfFreedom);
  return 1.0 - distribution.cumulativeProbability(-t,t);
}

Fixed version (ground truth):
/** 
 * Computes p-value for 2-sided, 2-sample t-test, under the assumption of equal subpopulation variances. <p> The sum of the sample sizes minus 2 is used as degrees of freedom.</p>
 * @param m1 first sample mean
 * @param m2 second sample mean
 * @param v1 first sample variance
 * @param v2 second sample variance
 * @param n1 first sample n
 * @param n2 second sample n
 * @return p-value
 * @throws MathException if an error occurs computing the p-value
 */
protected double homoscedasticTTest(double m1,double m2,double v1,double v2,double n1,double n2) throws MathException {
  double t=Math.abs(homoscedasticT(m1,m2,v1,v2,n1,n2));
  double degreesOfFreedom=(double)(n1 + n2 - 2);
  distribution.setDegreesOfFreedom(degreesOfFreedom);
  return 2.0 * distribution.cumulativeProbability(-t);
}
Program: 57519
Project: 57519
Buggy source:
/** 
 * Computes p-value for 2-sided, 2-sample t-test. <p> Does not assume subpopulation variances are equal. Degrees of freedom are estimated from the data.</p>
 * @param m1 first sample mean
 * @param m2 second sample mean
 * @param v1 first sample variance
 * @param v2 second sample variance
 * @param n1 first sample n
 * @param n2 second sample n
 * @return p-value
 * @throws MathException if an error occurs computing the p-value
 */
protected double tTest(double m1,double m2,double v1,double v2,double n1,double n2) throws MathException {
  double t=Math.abs(t(m1,m2,v1,v2,n1,n2));
  double degreesOfFreedom=0;
  degreesOfFreedom=df(v1,v2,n1,n2);
  distribution.setDegreesOfFreedom(degreesOfFreedom);
  return 1.0 - distribution.cumulativeProbability(-t,t);
}

Fixed version (ground truth):
/** 
 * Computes p-value for 2-sided, 2-sample t-test. <p> Does not assume subpopulation variances are equal. Degrees of freedom are estimated from the data.</p>
 * @param m1 first sample mean
 * @param m2 second sample mean
 * @param v1 first sample variance
 * @param v2 second sample variance
 * @param n1 first sample n
 * @param n2 second sample n
 * @return p-value
 * @throws MathException if an error occurs computing the p-value
 */
protected double tTest(double m1,double m2,double v1,double v2,double n1,double n2) throws MathException {
  double t=Math.abs(t(m1,m2,v1,v2,n1,n2));
  double degreesOfFreedom=0;
  degreesOfFreedom=df(v1,v2,n1,n2);
  distribution.setDegreesOfFreedom(degreesOfFreedom);
  return 2.0 * distribution.cumulativeProbability(-t);
}
Program: 57520
Project: 57520
Buggy source:
public void testEqualsAndHashCode(){
  SummaryStatistics u=createSummaryStatistics();
  SummaryStatistics t=null;
  int emptyHash=u.hashCode();
  assertTrue("String_Node_Str",u.equals(u));
  assertFalse("String_Node_Str",u.equals(t));
  assertFalse("String_Node_Str",u.equals(new Double(0)));
  t=createSummaryStatistics();
  assertTrue("String_Node_Str",t.equals(u));
  assertTrue("String_Node_Str",u.equals(t));
  assertEquals("String_Node_Str",emptyHash,t.hashCode());
  u.addValue(2d);
  u.addValue(1d);
  u.addValue(3d);
  u.addValue(4d);
  assertFalse("String_Node_Str",t.equals(u));
  assertFalse("String_Node_Str",u.equals(t));
  assertTrue("String_Node_Str",u.hashCode() != t.hashCode());
  t.addValue(2d);
  t.addValue(3d);
  t.addValue(1d);
  t.addValue(4d);
  assertTrue("String_Node_Str",t.equals(u));
  assertTrue("String_Node_Str",u.equals(t));
  assertEquals("String_Node_Str",u.hashCode(),t.hashCode());
  u.clear();
  t.clear();
  assertTrue("String_Node_Str",t.equals(u));
  assertTrue("String_Node_Str",u.equals(t));
  assertEquals("String_Node_Str",emptyHash,t.hashCode());
  assertEquals("String_Node_Str",emptyHash,u.hashCode());
}

Fixed version (ground truth):
public void testEqualsAndHashCode(){
  SummaryStatistics u=createSummaryStatistics();
  SummaryStatistics t=null;
  int emptyHash=u.hashCode();
  assertTrue("String_Node_Str",u.equals(u));
  assertFalse("String_Node_Str",u.equals(t));
  assertFalse("String_Node_Str",u.equals(new Double(0)));
  t=createSummaryStatistics();
  assertTrue("String_Node_Str",t.equals(u));
  assertTrue("String_Node_Str",u.equals(t));
  assertEquals("String_Node_Str",emptyHash,t.hashCode());
  u.addValue(2d);
  u.addValue(1d);
  u.addValue(3d);
  u.addValue(4d);
  assertFalse("String_Node_Str",t.equals(u));
  assertFalse("String_Node_Str",u.equals(t));
  assertTrue("String_Node_Str",u.hashCode() != t.hashCode());
  t.addValue(2d);
  t.addValue(1d);
  t.addValue(3d);
  t.addValue(4d);
  assertTrue("String_Node_Str",t.equals(u));
  assertTrue("String_Node_Str",u.equals(t));
  assertEquals("String_Node_Str",u.hashCode(),t.hashCode());
  u.clear();
  t.clear();
  assertTrue("String_Node_Str",t.equals(u));
  assertTrue("String_Node_Str",u.equals(t));
  assertEquals("String_Node_Str",emptyHash,t.hashCode());
  assertEquals("String_Node_Str",emptyHash,u.hashCode());
}
Program: 57521
Project: 57521
Buggy source:
/** 
 * Update the residuals array and cost function value.
 * @exception EstimationException if the number of cost evaluationsexceeds the maximum allowed
 */
protected void updateResidualsAndCost() throws EstimationException {
  if (++costEvaluations > maxCostEval) {
    throw new EstimationException("String_Node_Str",new String[]{Integer.toString(maxCostEval)});
  }
  cost=0;
  for (int i=0, index=0; i < rows; i++, index+=cols) {
    WeightedMeasurement wm=measurements[i];
    double residual=wm.getResidual();
    residuals[i]=Math.sqrt(wm.getWeight()) * residual;
    cost+=wm.getWeight() * residual * residual;
  }
  cost=Math.sqrt(cost);
}

Fixed version (ground truth):
/** 
 * Update the residuals array and cost function value.
 * @exception EstimationException if the number of cost evaluationsexceeds the maximum allowed
 */
protected void updateResidualsAndCost() throws EstimationException {
  if (++costEvaluations > maxCostEval) {
    throw new EstimationException("String_Node_Str",new Object[]{new Integer(maxCostEval)});
  }
  cost=0;
  for (int i=0, index=0; i < rows; i++, index+=cols) {
    WeightedMeasurement wm=measurements[i];
    double residual=wm.getResidual();
    residuals[i]=Math.sqrt(wm.getWeight()) * residual;
    cost+=wm.getWeight() * residual * residual;
  }
  cost=Math.sqrt(cost);
}
Program: 57522
Project: 57522
Buggy source:
/** 
 * Copy constructor. <p>The copied interpolator should have been finalized before the copy, otherwise the copy will not be able to perform correctly any interpolation and will throw a   {@link NullPointerException}later. Since we don't want this constructor to throw the exceptions finalization may involve and since we don't want this method to modify the state of the copied interpolator, finalization is <strong>not</strong> done automatically, it remains under user control.</p> <p>The copy is a deep copy: its arrays are separated from the original arrays of the instance.</p>
 * @param interpolator interpolator to copy from.
 */
protected DummyStepInterpolator(DummyStepInterpolator interpolator){
  super(interpolator);
}

Fixed version (ground truth):
/** 
 * Simple constructor.
 * @param y reference to the integrator array holding the state atthe end of the step
 * @param forward integration direction indicator
 */
protected DummyStepInterpolator(double[] y,boolean forward){
  super(y,forward);
}
Program: 57523
Project: 57523
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
 */
protected void computeInterpolatedState(double theta,double oneMinusThetaH) throws DerivativeException {
}

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
 */
protected void computeInterpolatedState(double theta,double oneMinusThetaH) throws DerivativeException {
  System.arraycopy(currentState,0,interpolatedState,0,currentState.length);
}