nus-yam/ex-repair huggingface dataset:
Program: 144143
Project: 144143
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public void write(OutputStream outputStream,boolean includeType) throws IOException {
  if (includeType)   UnsafeSerializationUtilities.writeInt(outputStream,type().ordinal());
  UnsafeSerializationUtilities.writeInt(outputStream,size);
  UnsafeSerializationUtilities.writeInt(outputStream,numberOfNonzeroEntries);
  UnsafeSerializationUtilities.writeIntArray(outputStream,indexes);
  UnsafeSerializationUtilities.writeDoubleArray(outputStream,values);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public void write(OutputStream outputStream,boolean includeType) throws IOException {
  if (includeType)   UnsafeSerializationUtilities.writeInt(outputStream,type().ordinal());
  UnsafeSerializationUtilities.writeInt(outputStream,size);
  UnsafeSerializationUtilities.writeInt(outputStream,numberOfNonzeroEntries);
  UnsafeSerializationUtilities.writeIntArray(outputStream,indexes,numberOfNonzeroEntries);
  UnsafeSerializationUtilities.writeDoubleArray(outputStream,values,numberOfNonzeroEntries);
}
Program: 144144
Project: 144144
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public double sum(){
  double sum=values[0];
  for (int i=1; i < numberOfNonzeroEntries; i++) {
    sum+=values[i];
  }
  return sum;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public double sum(){
  double sum=values[0];
  for (int i=1; i < numberOfNonzeroEntries; i++)   sum+=values[i];
  return sum;
}
Program: 144145
Project: 144145
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public double min(){
  double minValue=values[0];
  for (int i=1; i < numberOfNonzeroEntries; i++) {
    minValue=Math.min(minValue,values[i]);
  }
  return minValue;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public double min(){
  double minValue=values[0];
  for (int i=1; i < numberOfNonzeroEntries; i++)   minValue=Math.min(minValue,values[i]);
  return minValue;
}
Program: 144146
Project: 144146
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector multInPlace(double scalar){
  for (int i=0; i < numberOfNonzeroEntries; i++) {
    values[i]*=scalar;
  }
  return this;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector multInPlace(double scalar){
  for (int i=0; i < numberOfNonzeroEntries; i++)   values[i]*=scalar;
  return this;
}
Program: 144147
Project: 144147
Buggy source:
/** 
 * Writes the provided double array to the provided output stream byte by byte. Note that the size of the array is not stored and so the user of this method must make sure to store that as well somewhere, so that the array can be serialized later on.
 * @param outputStream    The output stream to write the provided double array to.
 * @param array           The double array to write to the provided output stream.
 * @throws IOException
 */
public static void writeDoubleArray(OutputStream outputStream,double[] array) throws IOException {
  byte[] buffer=new byte[array.length << 3];
  UNSAFE.copyMemory(array,DOUBLE_ARRAY_OFFSET,buffer,BYTE_ARRAY_OFFSET,array.length << 3);
  outputStream.write(buffer);
}

Fixed version (ground truth):
/** 
 * Writes a subarray of the provided double array to the provided output stream byte by byte. The subarray starts from the beginning of the provided double array and has   {@code length} elements. Note that the size of the arrayis not stored and so the user of this method must make sure to store that as well somewhere, so that the array can be serialized later on.
 * @param outputStream    The output stream to write the provided double array to.
 * @param array           The double array whose subarray to write to the provided output stream.
 * @param length          The length of the double array to write to the provided output stream.
 * @throws IOException
 */
public static void writeDoubleArray(OutputStream outputStream,double[] array,int length) throws IOException {
  byte[] buffer=new byte[length << 3];
  UNSAFE.copyMemory(array,DOUBLE_ARRAY_OFFSET,buffer,BYTE_ARRAY_OFFSET,length << 3);
  outputStream.write(buffer);
}
Program: 144148
Project: 144148
Buggy source:
/** 
 * Writes the provided integer array to the provided output stream byte by byte. Note that the size of the array is not stored and so the user of this method must make sure to store that as well somewhere, so that the array can be serialized later on.
 * @param outputStream    The output stream to write the provided integer array to.
 * @param array           The integer array to write to the provided output stream.
 * @throws IOException
 */
public static void writeIntArray(OutputStream outputStream,int[] array) throws IOException {
  byte[] buffer=new byte[array.length << 2];
  UNSAFE.copyMemory(array,INT_ARRAY_OFFSET,buffer,BYTE_ARRAY_OFFSET,array.length << 2);
  outputStream.write(buffer);
}

Fixed version (ground truth):
/** 
 * Writes a subarray of the provided integer array to the provided output stream byte by byte. The subarray starts from the beginning of the provided integer array and has   {@code length} elements. Note that the size of the arrayis not stored and so the user of this method must make sure to store that as well somewhere, so that the array can be serialized later on.
 * @param outputStream    The output stream to write the provided integer array to.
 * @param array           The integer array whose subarray to write to the provided output stream.
 * @param length          The length of the integer array to write to the provided output stream.
 * @throws IOException
 */
public static void writeIntArray(OutputStream outputStream,int[] array,int length) throws IOException {
  byte[] buffer=new byte[length << 2];
  UNSAFE.copyMemory(array,INT_ARRAY_OFFSET,buffer,BYTE_ARRAY_OFFSET,length << 2);
  outputStream.write(buffer);
}
Program: 144149
Project: 144149
Buggy source:
public double[] predict(DataInstance<Vector,Integer>[] dataInstances) throws UntrainedModelException ;

Fixed version (ground truth):
public double[] predict(DataInstance<Vector,Integer>[] dataInstances);
Program: 144150
Project: 144150
Buggy source:
@Override public void updateDirection(){
  if (currentIteration == 0) {
    sumOfGradientSquares=currentGradient.map(gradient -> Math.pow(gradient,2)).copy();
    if (useL1Regularization) {
      sumOfGradients=currentGradient.copy();
    }
  }
 else {
    sumOfGradientSquares.addInPlace(currentGradient.map(gradient -> Math.pow(gradient,2)));
    if (useL1Regularization) {
      sumOfGradients.addInPlace(currentGradient);
    }
  }
  if (useL1Regularization) {
    currentDirection=sumOfGradients.map(x -> Math.abs(x) / currentIteration <= l1RegularizationWeight ? 0.0 : Math.signum(x) * (Math.abs(x) / currentIteration - l1RegularizationWeight)).mult(-1).divElementwise(sumOfGradientSquares.map(Math::sqrt).add(epsilon)).mult(currentIteration);
  }
 else {
    currentDirection=currentGradient.mult(-1).divElementwise(sumOfGradientSquares.map(Math::sqrt).add(epsilon));
  }
}

Fixed version (ground truth):
@Override public void updateDirection(){
  if (currentIteration == 0) {
    sumOfGradientSquares=currentGradient.map(gradient -> Math.pow(gradient,2)).copy();
    if (useL1Regularization) {
      sumOfGradients=currentGradient.copy();
    }
  }
 else {
    sumOfGradientSquares.addInPlace(currentGradient.map(gradient -> Math.pow(gradient,2)));
    if (useL1Regularization) {
      sumOfGradients.addInPlace(currentGradient);
    }
  }
  if (useL1Regularization) {
    currentDirection=sumOfGradients.map(x -> Math.abs(x) / currentIteration <= l1RegularizationWeight ? 0.0 : Math.signum(x) * (Math.abs(x) / (currentIteration + 1) - l1RegularizationWeight)).mult(-1).divElementwise(sumOfGradientSquares.map(Math::sqrt).add(epsilon)).mult(currentIteration);
  }
 else {
    currentDirection=currentGradient.mult(-1).divElementwise(sumOfGradientSquares.map(Math::sqrt).add(epsilon));
  }
}
Program: 144151
Project: 144151
Buggy source:
private AdaptiveGradientSolver(AbstractBuilder<?> builder){
  super(builder);
  sumOfGradients=Vectors.build(currentGradient.size(),currentGradient.type());
  squareRootOfSumOfGradientSquares=Vectors.build(currentGradient.size(),currentGradient.type()).add(epsilon);
}

Fixed version (ground truth):
private AdaptiveGradientSolver(AbstractBuilder<?> builder){
  super(builder);
  sumOfGradients=Vectors.build(currentGradient.size(),currentGradient.type());
  squareRootOfSumOfGradientSquares=Vectors.build(currentGradient.size(),currentGradient.type());
}
Program: 144152
Project: 144152
Buggy source:
@Override public void updateDirection(){
  squareRootOfSumOfGradientSquares.hypotenuseFastInPlace(currentGradient);
  if (useL1Regularization) {
    currentDirection=sumOfGradients.addInPlace(currentGradient).mapDivElementwise(x -> Math.abs(x) / (currentIteration + 1) <= l1RegularizationWeight ? 0.0 : -currentIteration * Math.signum(x) * (Math.abs(x) / (currentIteration + 1) - l1RegularizationWeight),squareRootOfSumOfGradientSquares);
  }
 else {
    currentDirection=currentGradient.divElementwise(squareRootOfSumOfGradientSquares).mult(-1);
  }
}

Fixed version (ground truth):
@Override public void updateDirection(){
  squareRootOfSumOfGradientSquares.hypotenuseFastInPlace(currentGradient);
  if (useL1Regularization) {
    currentDirection=sumOfGradients.addInPlace(currentGradient).mapDivElementwise(x -> Math.abs(x) / (currentIteration + 1) <= l1RegularizationWeight ? 0.0 : -currentIteration * Math.signum(x) * (Math.abs(x) / (currentIteration + 1) - l1RegularizationWeight),squareRootOfSumOfGradientSquares.add(epsilon));
  }
 else {
    currentDirection=currentGradient.divElementwise(squareRootOfSumOfGradientSquares.add(epsilon)).mult(-1);
  }
}
Program: 144153
Project: 144153
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector multElementwise(Vector vector){
  checkVectorSize(vector);
  SparseVector resultVector=new SparseVector(size,hashMap);
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      resultVector.set(key,hashMap.get(key) * vector.get(key));
    }
  }
 else {
    if (this.numberOfNonzeroElements() <= vector.numberOfNonzeroElements()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          resultVector.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          resultVector.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
  }
  return resultVector;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector multElementwise(Vector vector){
  checkVectorSize(vector);
  SparseVector resultVector=new SparseVector(size);
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      resultVector.set(key,hashMap.get(key) * vector.get(key));
    }
  }
 else {
    if (hashMap.keys().size() <= ((SparseVector)vector).hashMap.keys().size()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          resultVector.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          resultVector.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
  }
  return resultVector;
}
Program: 144154
Project: 144154
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public double inner(Vector vector){
  checkVectorSize(vector);
  double result=0;
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      result+=hashMap.get(key) * vector.get(key);
    }
  }
 else {
    if (this.numberOfNonzeroElements() <= vector.numberOfNonzeroElements()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          result+=hashMap.get(key) * vector.get(key);
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          result+=hashMap.get(key) * vector.get(key);
        }
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public double inner(Vector vector){
  checkVectorSize(vector);
  double result=0;
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      result+=hashMap.get(key) * vector.get(key);
    }
  }
 else {
    if (this.cardinality() <= vector.cardinality()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          result+=hashMap.get(key) * vector.get(key);
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          result+=hashMap.get(key) * vector.get(key);
        }
      }
    }
  }
  return result;
}
Program: 144155
Project: 144155
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector multElementwiseInPlace(Vector vector){
  checkVectorSize(vector);
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      this.set(key,hashMap.get(key) * vector.get(key));
    }
  }
 else {
    if (this.numberOfNonzeroElements() <= vector.numberOfNonzeroElements()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          this.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          this.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
  }
  return this;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector multElementwiseInPlace(Vector vector){
  checkVectorSize(vector);
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      this.set(key,hashMap.get(key) * vector.get(key));
    }
  }
 else {
    if (this.cardinality() <= vector.cardinality()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          this.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          this.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
  }
  return this;
}
Program: 144156
Project: 144156
Buggy source:
@Override public void updateDirection(){
  if (currentIteration == 0) {
    sumOfGradientSquares=currentGradient.map(gradient -> Math.pow(gradient,2)).copy();
  }
 else {
    sumOfGradientSquares.addInPlace(currentGradient.map(gradient -> Math.pow(gradient,2)));
  }
  currentDirection=currentGradient.mult(-1).divElementwise(sumOfGradientSquares.map(x -> {
    if (x == 0)     return epsilon;
 else     return x;
  }
).map(Math::sqrt));
}

Fixed version (ground truth):
@Override public void updateDirection(){
  if (currentIteration == 0) {
    sumOfGradientSquares=currentGradient.map(gradient -> Math.pow(gradient,2)).copy();
  }
 else {
    sumOfGradientSquares.addInPlace(currentGradient.map(gradient -> Math.pow(gradient,2)));
  }
  currentDirection=currentGradient.mult(-1).divElementwise(sumOfGradientSquares.map(Math::sqrt).add(epsilon));
}
Program: 144157
Project: 144157
Buggy source:
@Override public void updateDirection(){
  if (currentIteration == 0) {
    sumOfGradientSquares=currentGradient.map(gradient -> Math.pow(gradient,2)).copy();
  }
 else {
    sumOfGradientSquares.addInPlace(currentGradient.map(gradient -> Math.pow(gradient,2)));
  }
  currentDirection=currentGradient.mult(-1).divElementwise(sumOfGradientSquares.map(Math::sqrt));
}

Fixed version (ground truth):
@Override public void updateDirection(){
  if (currentIteration == 0) {
    sumOfGradientSquares=currentGradient.map(gradient -> Math.pow(gradient,2)).copy();
  }
 else {
    sumOfGradientSquares.addInPlace(currentGradient.map(gradient -> Math.pow(gradient,2)));
  }
  currentDirection=currentGradient.mult(-1).divElementwise(sumOfGradientSquares.map(x -> {
    if (x == 0)     return epsilon;
 else     return x;
  }
).map(Math::sqrt));
}
Program: 144158
Project: 144158
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector multElementwise(Vector vector){
  checkVectorSize(vector);
  SparseVector resultVector=new SparseVector(size,hashMap);
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      resultVector.set(key,hashMap.get(key) * vector.get(key));
    }
  }
 else {
    if (size <= vector.size()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          resultVector.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          resultVector.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
  }
  return resultVector;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector multElementwise(Vector vector){
  checkVectorSize(vector);
  SparseVector resultVector=new SparseVector(size,hashMap);
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      resultVector.set(key,hashMap.get(key) * vector.get(key));
    }
  }
 else {
    if (this.numberOfNonzeroElements() <= vector.numberOfNonzeroElements()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          resultVector.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          resultVector.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
  }
  return resultVector;
}
Program: 144159
Project: 144159
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public double inner(Vector vector){
  checkVectorSize(vector);
  double result=0;
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      result+=hashMap.get(key) * vector.get(key);
    }
  }
 else {
    if (size <= vector.size()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          result+=hashMap.get(key) * vector.get(key);
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          result+=hashMap.get(key) * vector.get(key);
        }
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public double inner(Vector vector){
  checkVectorSize(vector);
  double result=0;
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      result+=hashMap.get(key) * vector.get(key);
    }
  }
 else {
    if (this.numberOfNonzeroElements() <= vector.numberOfNonzeroElements()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          result+=hashMap.get(key) * vector.get(key);
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          result+=hashMap.get(key) * vector.get(key);
        }
      }
    }
  }
  return result;
}
Program: 144160
Project: 144160
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector multElementwiseInPlace(Vector vector){
  checkVectorSize(vector);
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      this.set(key,hashMap.get(key) * vector.get(key));
    }
  }
 else {
    if (size <= vector.size()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          this.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          this.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
  }
  return this;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector multElementwiseInPlace(Vector vector){
  checkVectorSize(vector);
  if (vector.type() != VectorType.SPARSE) {
    for (    int key : hashMap.keys().elements()) {
      this.set(key,hashMap.get(key) * vector.get(key));
    }
  }
 else {
    if (this.numberOfNonzeroElements() <= vector.numberOfNonzeroElements()) {
      for (      int key : hashMap.keys().elements()) {
        if (((SparseVector)vector).hashMap.containsKey(key)) {
          this.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
 else {
      for (      int key : ((SparseVector)vector).hashMap.keys().elements()) {
        if (hashMap.containsKey(key)) {
          this.set(key,hashMap.get(key) * vector.get(key));
        }
      }
    }
  }
  return this;
}
Program: 144161
Project: 144161
Buggy source:
/** 
 * Gets a column of this matrix.
 * @param columnIndex The index of the column to get.
 * @return              The column corresponding to the provided index as a vector.
 * @exception ArrayIndexOutOfBoundsException  The provided column index is out of bounds.
 */
public Vector getColumn(int columnIndex){
  DenseVector resultVector=new DenseVector(rowDimension);
  double[] resultVectorArray=resultVector.getArray();
  try {
    for (int i=0; i < rowDimension; i++) {
      resultVectorArray[i]=array[i][columnIndex];
    }
  }
 catch (  ArrayIndexOutOfBoundsException e) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str");
  }
  return resultVector;
}

Fixed version (ground truth):
/** 
 * Gets a column of this matrix.
 * @param columnIndex The index of the column to get.
 * @return              The column corresponding to the provided index as a vector.
 * @exception ArrayIndexOutOfBoundsException  The provided column index is out of bounds.
 */
public Vector getColumn(int columnIndex){
  Vector resultVector=new DenseVector(rowDimension);
  try {
    for (int i=0; i < rowDimension; i++) {
      resultVector.set(i,array[i][columnIndex]);
    }
  }
 catch (  ArrayIndexOutOfBoundsException e) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str");
  }
  return resultVector;
}
Program: 144162
Project: 144162
Buggy source:
/** 
 * Gets a row of this matrix.
 * @param rowIndex    The index of the row to get.
 * @return              The row corresponding to the provided index as a vector.
 * @exception ArrayIndexOutOfBoundsException  The provided row index is out of bounds.
 */
public Vector getRow(int rowIndex){
  DenseVector resultVector=new DenseVector(columnDimension);
  double[] resultVectorArray=resultVector.getArray();
  try {
    for (int i=0; i < columnDimension; i++) {
      resultVectorArray[i]=array[rowIndex][i];
    }
  }
 catch (  ArrayIndexOutOfBoundsException e) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str");
  }
  return resultVector;
}

Fixed version (ground truth):
/** 
 * Gets a row of this matrix.
 * @param rowIndex    The index of the row to get.
 * @return              The row corresponding to the provided index as a vector.
 * @exception ArrayIndexOutOfBoundsException  The provided row index is out of bounds.
 */
public Vector getRow(int rowIndex){
  Vector resultVector=new DenseVector(columnDimension);
  try {
    for (int i=0; i < columnDimension; i++) {
      resultVector.set(i,array[rowIndex][i]);
    }
  }
 catch (  ArrayIndexOutOfBoundsException e) {
    throw new ArrayIndexOutOfBoundsException("String_Node_Str");
  }
  return resultVector;
}
Program: 144163
Project: 144163
Buggy source:
@Test public void testCycleMethodSolver(){
  System.out.println("String_Node_Str");
  CoordinateDescentSolver coordinateDescentSolver=new CoordinateDescentSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(CoordinateDescentSolver.Method.CYCLE).build();
  double[] actualResult=coordinateDescentSolver.solve().getArray();
  double[] expectedResult=new double[]{1,1};
  Assert.assertArrayEquals(expectedResult,actualResult,0.2);
  System.out.println("String_Node_Str");
  Matrix A=new Matrix(new double[][]{{1,0.5},{0.5,1}});
  Vector b=new Vector(new double[]{1,2});
  coordinateDescentSolver=new CoordinateDescentSolver.Builder(new QuadraticFunction(A,b),new double[]{0,0}).method(CoordinateDescentSolver.Method.CYCLE).build();
  actualResult=coordinateDescentSolver.solve().getArray();
  expectedResult=new double[]{0,2};
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}

Fixed version (ground truth):
@Test public void testCycleMethodSolver(){
  System.out.println("String_Node_Str");
  CoordinateDescentSolver coordinateDescentSolver=new CoordinateDescentSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(CoordinateDescentSolver.Method.CYCLE).build();
  double[] actualResult=coordinateDescentSolver.solve().getArray();
  double[] expectedResult=new double[]{1,1};
  Assert.assertArrayEquals(expectedResult,actualResult,0.3);
  System.out.println("String_Node_Str");
  Matrix A=new Matrix(new double[][]{{1,0.5},{0.5,1}});
  Vector b=new Vector(new double[]{1,2});
  coordinateDescentSolver=new CoordinateDescentSolver.Builder(new QuadraticFunction(A,b),new double[]{0,0}).method(CoordinateDescentSolver.Method.CYCLE).build();
  actualResult=coordinateDescentSolver.solve().getArray();
  expectedResult=new double[]{0,2};
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}
Program: 144164
Project: 144164
Buggy source:
@Test public void testBackAndForthMethodSolver(){
  System.out.println("String_Node_Str");
  CoordinateDescentSolver coordinateDescentSolver=new CoordinateDescentSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(CoordinateDescentSolver.Method.BACK_AND_FORTH).build();
  double[] actualResult=coordinateDescentSolver.solve().getArray();
  double[] expectedResult=new double[]{1,1};
  Assert.assertArrayEquals(expectedResult,actualResult,0.2);
  System.out.println("String_Node_Str");
  Matrix A=new Matrix(new double[][]{{1,0.5},{0.5,1}});
  Vector b=new Vector(new double[]{1,2});
  coordinateDescentSolver=new CoordinateDescentSolver.Builder(new QuadraticFunction(A,b),new double[]{0,0}).method(CoordinateDescentSolver.Method.BACK_AND_FORTH).build();
  actualResult=coordinateDescentSolver.solve().getArray();
  expectedResult=new double[]{0,2};
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}

Fixed version (ground truth):
@Test public void testBackAndForthMethodSolver(){
  System.out.println("String_Node_Str");
  CoordinateDescentSolver coordinateDescentSolver=new CoordinateDescentSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(CoordinateDescentSolver.Method.BACK_AND_FORTH).build();
  double[] actualResult=coordinateDescentSolver.solve().getArray();
  double[] expectedResult=new double[]{1,1};
  Assert.assertArrayEquals(expectedResult,actualResult,0.3);
  System.out.println("String_Node_Str");
  Matrix A=new Matrix(new double[][]{{1,0.5},{0.5,1}});
  Vector b=new Vector(new double[]{1,2});
  coordinateDescentSolver=new CoordinateDescentSolver.Builder(new QuadraticFunction(A,b),new double[]{0,0}).method(CoordinateDescentSolver.Method.BACK_AND_FORTH).build();
  actualResult=coordinateDescentSolver.solve().getArray();
  expectedResult=new double[]{0,2};
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}
Program: 144165
Project: 144165
Buggy source:
public double[][] predict(double[][] points){
  double[][] probabilities=new double[points.length][];
  for (int i=0; i < points.length; i++) {
    Vector predictions=weights.transpose().multiply(new Vector(points[i])).computeFunctionResult(Math::exp);
    probabilities[i]=predictions.divide(predictions.computeSum()).getArrayCopy();
  }
  return probabilities;
}

Fixed version (ground truth):
public double[][] predict(double[][] points){
  double[][] probabilities=new double[points.length][];
  for (int i=0; i < points.length; i++) {
    Vector predictions=weights.transpose().multiply(new Vector(points[i]));
    predictions=predictions.subtract(Utilities.computeLogSumExp(predictions));
    predictions=predictions.computeFunctionResult(Math::exp);
    probabilities[i]=predictions.getArrayCopy();
  }
  return probabilities;
}
Program: 144166
Project: 144166
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public DenseVector copy(){
  return new DenseVector(Arrays.copyOf(array,size));
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public DenseVector copy(){
  return new DenseVector(array);
}
Program: 144167
Project: 144167
Buggy source:
/** 
 * Constructs a dense vector from a one-dimensional array.
 * @param elements    One-dimensional array of values with which to fill the vector.
 */
protected DenseVector(double[] elements){
  size=elements.length;
  this.array=elements;
}

Fixed version (ground truth):
/** 
 * Constructs a dense vector from a one-dimensional array.
 * @param elements    One-dimensional array of values with which to fill the vector.
 */
protected DenseVector(double[] elements){
  size=elements.length;
  array=Arrays.copyOf(elements,size);
}
Program: 144168
Project: 144168
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector sub(Vector vector){
  checkVectorSize(vector);
  SparseVector resultVector=new SparseVector(size,hashMap);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      resultVector.set(i,this.get(i) - vector.get(i));
    }
  }
 else {
    if (size <= vector.size()) {
      hashMap.keySet().stream().filter(((SparseVector)vector).hashMap::containsKey).forEach(key -> resultVector.set(key,hashMap.get(key) - vector.get(key)));
    }
 else {
      ((SparseVector)vector).hashMap.keySet().stream().filter(hashMap::containsKey).forEach(key -> resultVector.set(key,hashMap.get(key) - vector.get(key)));
    }
  }
  return resultVector;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector sub(Vector vector){
  checkVectorSize(vector);
  SparseVector resultVector=new SparseVector(size,hashMap);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      resultVector.set(i,this.get(i) - vector.get(i));
    }
  }
 else {
    List<Integer> keysUnion=new ArrayList<>(hashMap.keySet());
    keysUnion.addAll(((SparseVector)vector).hashMap.keySet());
    for (    int key : keysUnion) {
      resultVector.set(key,this.get(key) - vector.get(key));
    }
  }
  return resultVector;
}
Program: 144169
Project: 144169
Buggy source:
/** 
 * Constructs a sparse vector of the given size from a hash map.
 * @param size        The size of the vector.
 * @param elements    Hash map containing the indexes of elements as keys and the values of the correspondingelements as values.
 */
protected SparseVector(int size,HashMap<Integer,Double> elements){
  this.size=size;
  hashMap=new HashMap<>(128);
  hashMap.putAll(elements);
}

Fixed version (ground truth):
/** 
 * Constructs a sparse vector of the given size from a hash map.
 * @param size        The size of the vector.
 * @param elements    Hash map containing the indexes of elements as keys and the values of the correspondingelements as values.
 */
protected SparseVector(int size,HashMap<Integer,Double> elements){
  this.size=size;
  hashMap=new HashMap<>(initialSize);
  hashMap.putAll(elements);
}
Program: 144170
Project: 144170
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector saxpyInPlace(double scalar,Vector vector){
  checkVectorSize(vector);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      this.set(i,this.get(i) + scalar * vector.get(i));
    }
  }
 else {
    Collection<Integer> keysUnion=hashMap.keySet();
    keysUnion.addAll(((SparseVector)vector).hashMap.keySet());
    for (    int key : keysUnion) {
      this.set(key,this.get(key) + scalar * vector.get(key));
    }
  }
  return this;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector saxpyInPlace(double scalar,Vector vector){
  checkVectorSize(vector);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      this.set(i,this.get(i) + scalar * vector.get(i));
    }
  }
 else {
    List<Integer> keysUnion=new ArrayList<>(hashMap.keySet());
    keysUnion.addAll(((SparseVector)vector).hashMap.keySet());
    for (    int key : keysUnion) {
      this.set(key,this.get(key) + scalar * vector.get(key));
    }
  }
  return this;
}
Program: 144171
Project: 144171
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public void setAll(double value){
  if (value >= epsilon) {
    for (int i=0; i < size; i++) {
      hashMap.put(i,value);
    }
  }
 else {
    hashMap=new HashMap<>(128);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public void setAll(double value){
  if (Math.abs(value) >= epsilon) {
    for (int i=0; i < size; i++) {
      hashMap.put(i,value);
    }
  }
 else {
    hashMap=new HashMap<>(initialSize);
  }
}
Program: 144172
Project: 144172
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector add(Vector vector){
  checkVectorSize(vector);
  SparseVector resultVector=new SparseVector(size,hashMap);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      resultVector.set(i,this.get(i) + vector.get(i));
    }
  }
 else {
    if (size <= vector.size()) {
      hashMap.keySet().stream().filter(((SparseVector)vector).hashMap::containsKey).forEach(key -> resultVector.set(key,hashMap.get(key) + vector.get(key)));
    }
 else {
      ((SparseVector)vector).hashMap.keySet().stream().filter(hashMap::containsKey).forEach(key -> resultVector.set(key,hashMap.get(key) + vector.get(key)));
    }
  }
  return resultVector;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector add(Vector vector){
  checkVectorSize(vector);
  SparseVector resultVector=new SparseVector(size,hashMap);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      resultVector.set(i,this.get(i) + vector.get(i));
    }
  }
 else {
    List<Integer> keysUnion=new ArrayList<>(hashMap.keySet());
    keysUnion.addAll(((SparseVector)vector).hashMap.keySet());
    for (    int key : keysUnion) {
      resultVector.set(key,this.get(key) + vector.get(key));
    }
  }
  return resultVector;
}
Program: 144173
Project: 144173
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public void set(int[] indexes,Vector vector){
  for (int i=0; i < indexes.length; i++) {
    if (indexes[i] < 0 || indexes[i] >= size) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    double value=vector.get(i);
    if (value >= epsilon) {
      hashMap.put(indexes[i],value);
    }
 else {
      hashMap.remove(indexes[i]);
    }
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public void set(int[] indexes,Vector vector){
  for (int i=0; i < indexes.length; i++) {
    if (indexes[i] < 0 || indexes[i] >= size) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    double value=vector.get(i);
    if (Math.abs(value) >= epsilon) {
      hashMap.put(indexes[i],value);
    }
 else {
      hashMap.remove(indexes[i]);
    }
  }
}
Program: 144174
Project: 144174
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector subInPlace(Vector vector){
  checkVectorSize(vector);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      this.set(i,this.get(i) - vector.get(i));
    }
  }
 else {
    if (size <= vector.size()) {
      hashMap.keySet().stream().filter(((SparseVector)vector).hashMap::containsKey).forEach(key -> this.set(key,hashMap.get(key) - vector.get(key)));
    }
 else {
      ((SparseVector)vector).hashMap.keySet().stream().filter(hashMap::containsKey).forEach(key -> this.set(key,hashMap.get(key) - vector.get(key)));
    }
  }
  return this;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector subInPlace(Vector vector){
  checkVectorSize(vector);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      this.set(i,this.get(i) - vector.get(i));
    }
  }
 else {
    List<Integer> keysUnion=new ArrayList<>(hashMap.keySet());
    keysUnion.addAll(((SparseVector)vector).hashMap.keySet());
    for (    int key : keysUnion) {
      this.set(key,this.get(key) - vector.get(key));
    }
  }
  return this;
}
Program: 144175
Project: 144175
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector saxpy(double scalar,Vector vector){
  checkVectorSize(vector);
  SparseVector resultVector=new SparseVector(size,hashMap);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      resultVector.set(i,this.get(i) + scalar * vector.get(i));
    }
  }
 else {
    Collection<Integer> keysUnion=hashMap.keySet();
    keysUnion.addAll(((SparseVector)vector).hashMap.keySet());
    for (    int key : keysUnion) {
      resultVector.set(key,this.get(key) + scalar * vector.get(key));
    }
  }
  return resultVector;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector saxpy(double scalar,Vector vector){
  checkVectorSize(vector);
  SparseVector resultVector=new SparseVector(size,hashMap);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      resultVector.set(i,this.get(i) + scalar * vector.get(i));
    }
  }
 else {
    List<Integer> keysUnion=new ArrayList<>(hashMap.keySet());
    keysUnion.addAll(((SparseVector)vector).hashMap.keySet());
    for (    int key : keysUnion) {
      resultVector.set(key,this.get(key) + scalar * vector.get(key));
    }
  }
  return resultVector;
}
Program: 144176
Project: 144176
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector addInPlace(Vector vector){
  checkVectorSize(vector);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      this.set(i,this.get(i) + vector.get(i));
    }
  }
 else {
    if (size <= vector.size()) {
      hashMap.keySet().stream().filter(((SparseVector)vector).hashMap::containsKey).forEach(key -> this.set(key,hashMap.get(key) + vector.get(key)));
    }
 else {
      ((SparseVector)vector).hashMap.keySet().stream().filter(hashMap::containsKey).forEach(key -> this.set(key,hashMap.get(key) + vector.get(key)));
    }
  }
  return this;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector addInPlace(Vector vector){
  checkVectorSize(vector);
  if (vector.type() != VectorType.SPARSE) {
    for (int i=0; i < size; i++) {
      this.set(i,this.get(i) + vector.get(i));
    }
  }
 else {
    List<Integer> keysUnion=new ArrayList<>(hashMap.keySet());
    keysUnion.addAll(((SparseVector)vector).hashMap.keySet());
    for (    int key : keysUnion) {
      this.set(key,this.get(key) + vector.get(key));
    }
  }
  return this;
}
Program: 144177
Project: 144177
Buggy source:
/** 
 * Computes the natural logarithm of the sum of the exponential of the values in a given vector in a way that aims to avoid numerical underflow or overflow. For a vector \(\boldsymbol{x}\) with elements \(x_i\), the quantity computed by this method is the following: \[\log{\sum_{i}{e^{x_i}}}.\]
 * @param vector  The vector to use for this operation.
 * @return          The natural logarithm of the sum of the exponential of the values in the given vector.
 */
public static double computeLogSumExp(Vector vector){
  double maximumValue=vector.max();
  return maximumValue + Math.log(vector.sub(maximumValue).map(Math::exp).sum());
}

Fixed version (ground truth):
/** 
 * Computes the natural logarithm of the sum of the exponential of the values in a given array in a way that aims to avoid numerical underflow or overflow. For an array \(\boldsymbol{x}\) with elements \(x_i\), the quantity computed by this method is the following: \[\log{\sum_{i}{e^{x_i}}}.\]
 * @param array   The array to use for this operation.
 * @return          The natural logarithm of the sum of the exponential of the values in the given array.
 */
public static double computeLogSumExp(double... array){
  Vector vector=VectorFactory.buildDense(array);
  return computeLogSumExp(vector);
}
Program: 144179
Project: 144179
Buggy source:
@Test public void testFletcherRievesPolakRibiereSolver(){
  System.out.println("String_Node_Str");
  NonlinearConjugateGradientSolver fletcherRievesPolakRibiereSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.FLETCHER_RIEVES_POLAK_RIBIERE).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.NO_RESTART).build();
  double[] actualResult=fletcherRievesPolakRibiereSolver.solve().getArray();
  double[] expectedResult=new double[]{1,1};
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
  System.out.println("String_Node_Str");
  fletcherRievesPolakRibiereSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.FLETCHER_RIEVES_POLAK_RIBIERE).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.N_STEP).build();
  actualResult=fletcherRievesPolakRibiereSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}

Fixed version (ground truth):
@Test public void testFletcherRievesPolakRibiereSolver(){
  System.out.println("String_Node_Str");
  NonlinearConjugateGradientSolver fletcherRievesPolakRibiereSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.FLETCHER_RIEVES_POLAK_RIBIERE).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.NO_RESTART).build();
  double[] actualResult=fletcherRievesPolakRibiereSolver.solve().getArray();
  double[] expectedResult=new double[]{1,1};
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
  System.out.println("String_Node_Str");
  fletcherRievesPolakRibiereSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.FLETCHER_RIEVES_POLAK_RIBIERE).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.N_STEP).build();
  actualResult=fletcherRievesPolakRibiereSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
  System.out.println("String_Node_Str");
  fletcherRievesPolakRibiereSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.FLETCHER_RIEVES_POLAK_RIBIERE).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.GRADIENTS_ORTHOGONALITY_CHECK).build();
  actualResult=fletcherRievesPolakRibiereSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}
Program: 144180
Project: 144180
Buggy source:
@Test public void testHagerZhangSolver(){
  double[] expectedResult=new double[]{1,1};
  System.out.println("String_Node_Str");
  NonlinearConjugateGradientSolver hagerZhangSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.HAGER_ZHANG).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.GRADIENTS_ORTHOGONALITY_CHECK).build();
  double[] actualResult=hagerZhangSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}

Fixed version (ground truth):
@Test public void testHagerZhangSolver(){
  System.out.println("String_Node_Str");
  NonlinearConjugateGradientSolver hagerZhangSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.HAGER_ZHANG).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.NO_RESTART).build();
  double[] actualResult=hagerZhangSolver.solve().getArray();
  double[] expectedResult=new double[]{1,1};
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
  System.out.println("String_Node_Str");
  hagerZhangSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.HAGER_ZHANG).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.N_STEP).build();
  actualResult=hagerZhangSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
  System.out.println("String_Node_Str");
  hagerZhangSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.HAGER_ZHANG).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.GRADIENTS_ORTHOGONALITY_CHECK).build();
  actualResult=hagerZhangSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}
Program: 144181
Project: 144181
Buggy source:
@Test public void testDaiYuanSolver(){
  double[] expectedResult=new double[]{1,1};
  System.out.println("String_Node_Str");
  NonlinearConjugateGradientSolver daiYuanSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.DAI_YUAN).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.GRADIENTS_ORTHOGONALITY_CHECK).build();
  double[] actualResult=daiYuanSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}

Fixed version (ground truth):
@Test public void testDaiYuanSolver(){
  System.out.println("String_Node_Str");
  NonlinearConjugateGradientSolver daiYuanSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.DAI_YUAN).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.NO_RESTART).build();
  double[] actualResult=daiYuanSolver.solve().getArray();
  double[] expectedResult=new double[]{1,1};
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
  System.out.println("String_Node_Str");
  daiYuanSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.DAI_YUAN).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.N_STEP).build();
  actualResult=daiYuanSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
  System.out.println("String_Node_Str");
  daiYuanSolver=new NonlinearConjugateGradientSolver.Builder(new RosenbrockFunction(),new double[]{-1.2,1}).method(NonlinearConjugateGradientSolver.Method.DAI_YUAN).restartMethod(NonlinearConjugateGradientSolver.RestartMethod.GRADIENTS_ORTHOGONALITY_CHECK).build();
  actualResult=daiYuanSolver.solve().getArray();
  Assert.assertArrayEquals(expectedResult,actualResult,1e-2);
}