Program: 143997
Project: 143997
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector saxpyPlusConstant(double scalar,Vector vector){
  if (vector.size() + 1 != this.size())   throw new IllegalArgumentException("String_Node_Str");
  SparseVector resultVector;
  if (vector.type() == VectorType.SPARSE) {
    int[] newIndexes=new int[numberOfNonzeroEntries + ((SparseVector)vector).numberOfNonzeroEntries + 1];
    double[] newValues=new double[numberOfNonzeroEntries + ((SparseVector)vector).numberOfNonzeroEntries + 1];
    int currentIndex=0;
    int vector1Index=0;
    int vector2Index=0;
    while (vector1Index < numberOfNonzeroEntries && vector2Index < ((SparseVector)vector).numberOfNonzeroEntries) {
      if (indexes[vector1Index] < ((SparseVector)vector).indexes[vector2Index]) {
        newIndexes[currentIndex]=indexes[vector1Index];
        newValues[currentIndex]=values[vector1Index];
        currentIndex++;
        vector1Index++;
      }
 else       if (indexes[vector1Index] > ((SparseVector)vector).indexes[vector2Index]) {
        newIndexes[currentIndex]=((SparseVector)vector).indexes[vector2Index];
        newValues[currentIndex]=scalar * ((SparseVector)vector).values[vector2Index];
        currentIndex++;
        vector2Index++;
      }
 else {
        newIndexes[currentIndex]=indexes[vector1Index];
        newValues[currentIndex]=values[vector1Index] + scalar * ((SparseVector)vector).values[vector2Index];
        currentIndex++;
        vector1Index++;
        vector2Index++;
      }
    }
    while (vector1Index < numberOfNonzeroEntries) {
      newIndexes[currentIndex]=indexes[vector1Index];
      newValues[currentIndex]=values[vector1Index];
      currentIndex++;
      vector1Index++;
    }
    while (vector2Index < ((SparseVector)vector).numberOfNonzeroEntries) {
      newIndexes[currentIndex]=((SparseVector)vector).indexes[vector2Index];
      newValues[currentIndex]=scalar * ((SparseVector)vector).values[vector2Index];
      currentIndex++;
      vector2Index++;
    }
    if (newIndexes[currentIndex - 1] == size - 1) {
      newValues[currentIndex - 1]+=scalar;
    }
 else {
      newIndexes[currentIndex]=size - 1;
      newValues[currentIndex]=scalar;
      currentIndex++;
    }
    resultVector=new SparseVector(size,currentIndex,newIndexes,newValues);
  }
 else {
    throw new UnsupportedOperationException();
  }
  return resultVector;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public SparseVector saxpyPlusConstant(double scalar,Vector vector){
  if (vector.size() + 1 != this.size())   throw new IllegalArgumentException("String_Node_Str");
  SparseVector resultVector;
  if (vector.type() == VectorType.SPARSE) {
    int[] newIndexes=new int[numberOfNonzeroEntries + ((SparseVector)vector).numberOfNonzeroEntries + 1];
    double[] newValues=new double[numberOfNonzeroEntries + ((SparseVector)vector).numberOfNonzeroEntries + 1];
    int currentIndex=0;
    int vector1Index=0;
    int vector2Index=0;
    while (vector1Index < numberOfNonzeroEntries && vector2Index < ((SparseVector)vector).numberOfNonzeroEntries) {
      if (indexes[vector1Index] < ((SparseVector)vector).indexes[vector2Index]) {
        newIndexes[currentIndex]=indexes[vector1Index];
        newValues[currentIndex]=values[vector1Index];
        currentIndex++;
        vector1Index++;
      }
 else       if (indexes[vector1Index] > ((SparseVector)vector).indexes[vector2Index]) {
        newIndexes[currentIndex]=((SparseVector)vector).indexes[vector2Index];
        newValues[currentIndex]=scalar * ((SparseVector)vector).values[vector2Index];
        currentIndex++;
        vector2Index++;
      }
 else {
        newIndexes[currentIndex]=indexes[vector1Index];
        newValues[currentIndex]=values[vector1Index] + scalar * ((SparseVector)vector).values[vector2Index];
        currentIndex++;
        vector1Index++;
        vector2Index++;
      }
    }
    while (vector1Index < numberOfNonzeroEntries) {
      newIndexes[currentIndex]=indexes[vector1Index];
      newValues[currentIndex]=values[vector1Index];
      currentIndex++;
      vector1Index++;
    }
    while (vector2Index < ((SparseVector)vector).numberOfNonzeroEntries) {
      newIndexes[currentIndex]=((SparseVector)vector).indexes[vector2Index];
      newValues[currentIndex]=scalar * ((SparseVector)vector).values[vector2Index];
      currentIndex++;
      vector2Index++;
    }
    if (currentIndex > 0 && newIndexes[currentIndex - 1] == size - 1) {
      newValues[currentIndex - 1]+=scalar;
    }
 else {
      newIndexes[currentIndex]=size - 1;
      newValues[currentIndex]=scalar;
      currentIndex++;
    }
    resultVector=new SparseVector(size,currentIndex,newIndexes,newValues);
  }
 else {
    throw new UnsupportedOperationException();
  }
  return resultVector;
}