Program: 31894
Project: 31894
Buggy source:
private void genLinearGridPoints(double[][] gridPointsArray,double startValue,double endValue,double gridDensity,int scale_mode){
  if (startValue == endValue) {
    Log.e(AnalyzeActivity.TAG,"String_Node_Str");
    return;
  }
  if (startValue > endValue) {
    double t=endValue;
    endValue=startValue;
    startValue=t;
  }
  double intervalValue=endValue - startValue;
  double gridIntervalGuess=intervalValue / gridDensity;
  double gridIntervalBig;
  double gridIntervalSmall;
  if (scale_mode == 0 || intervalValue <= 1) {
    double exponent=Math.pow(10,Math.floor(Math.log10(gridIntervalGuess)));
    double fraction=gridIntervalGuess / exponent;
    if (fraction < Math.sqrt(1 * 2)) {
      gridIntervalBig=1;
      gridIntervalSmall=0.2;
    }
 else     if (fraction < Math.sqrt(2 * 5)) {
      gridIntervalBig=2;
      gridIntervalSmall=1.0;
    }
 else     if (fraction < Math.sqrt(5 * 10)) {
      gridIntervalBig=5;
      gridIntervalSmall=1;
    }
 else {
      gridIntervalBig=10;
      gridIntervalSmall=2;
    }
    gridIntervalBig*=exponent;
    gridIntervalSmall*=exponent;
  }
 else {
    if (intervalValue > 36) {
      gridIntervalBig=36;
      gridIntervalSmall=12;
    }
 else     if (intervalValue > 12) {
      gridIntervalBig=12;
      gridIntervalSmall=2;
    }
 else     if (intervalValue > 6) {
      gridIntervalBig=6;
      gridIntervalSmall=1;
    }
 else     if (intervalValue > 3) {
      gridIntervalBig=3;
      gridIntervalSmall=1;
    }
 else {
      gridIntervalBig=1;
      gridIntervalSmall=1.0 / 6;
    }
  }
  if (gridPointsArray == null || gridPointsArray.length != 2) {
    Log.e(AnalyzeActivity.TAG,"String_Node_Str");
  }
  int nGrid=(int)Math.floor(intervalValue / gridIntervalBig) + 1;
  if (nGrid != gridPointsArray[0].length) {
    gridPointsArray[0]=new double[nGrid];
  }
  double[] bigGridPoints=gridPointsArray[0];
  double gridStartValueBig=Math.ceil(startValue / gridIntervalBig) * gridIntervalBig;
  for (int i=0; i < nGrid; i++) {
    bigGridPoints[i]=gridStartValueBig + i * gridIntervalBig;
  }
  nGrid=(int)Math.floor(intervalValue / gridIntervalSmall) + 1;
  if (nGrid != gridPointsArray[1].length) {
    gridPointsArray[1]=new double[nGrid];
  }
  double[] smallGridPoints=gridPointsArray[1];
  double gridStartValueSmall=Math.ceil(startValue / gridIntervalSmall) * gridIntervalSmall;
  for (int i=0; i < nGrid; i++) {
    smallGridPoints[i]=gridStartValueSmall + i * gridIntervalSmall;
  }
}

Fixed version (ground truth):
private void genLinearGridPoints(double[][] gridPointsArray,double startValue,double endValue,double gridDensity,int scale_mode){
  if (startValue == endValue) {
    Log.e(AnalyzeActivity.TAG,"String_Node_Str");
    return;
  }
  if (startValue > endValue) {
    double t=endValue;
    endValue=startValue;
    startValue=t;
  }
  double intervalValue=endValue - startValue;
  double gridIntervalGuess=intervalValue / gridDensity;
  double gridIntervalBig;
  double gridIntervalSmall;
  if (scale_mode == 0 || intervalValue <= 1) {
    double exponent=Math.pow(10,Math.floor(Math.log10(gridIntervalGuess)));
    double fraction=gridIntervalGuess / exponent;
    if (fraction < Math.sqrt(1 * 2)) {
      gridIntervalBig=1;
      gridIntervalSmall=0.2;
    }
 else     if (fraction < Math.sqrt(2 * 5)) {
      gridIntervalBig=2;
      gridIntervalSmall=1.0;
    }
 else     if (fraction < Math.sqrt(5 * 10)) {
      gridIntervalBig=5;
      gridIntervalSmall=1;
    }
 else {
      gridIntervalBig=10;
      gridIntervalSmall=2;
    }
    gridIntervalBig*=exponent;
    gridIntervalSmall*=exponent;
  }
 else {
    if (gridIntervalGuess > Math.sqrt(36 * 12)) {
      gridIntervalBig=36;
      gridIntervalSmall=12;
    }
 else     if (gridIntervalGuess > Math.sqrt(12 * 6)) {
      gridIntervalBig=12;
      gridIntervalSmall=2;
    }
 else     if (gridIntervalGuess > Math.sqrt(6 * 3)) {
      gridIntervalBig=6;
      gridIntervalSmall=1;
    }
 else     if (gridIntervalGuess > Math.sqrt(3 * 1)) {
      gridIntervalBig=3;
      gridIntervalSmall=1;
    }
 else {
      gridIntervalBig=1;
      gridIntervalSmall=1.0 / 6;
    }
  }
  if (gridPointsArray == null || gridPointsArray.length != 2) {
    Log.e(AnalyzeActivity.TAG,"String_Node_Str");
    return;
  }
  int nGrid=(int)Math.floor(intervalValue / gridIntervalBig) + 1;
  if (nGrid != gridPointsArray[0].length) {
    gridPointsArray[0]=new double[nGrid];
  }
  double[] bigGridPoints=gridPointsArray[0];
  double gridStartValueBig=Math.ceil(startValue / gridIntervalBig) * gridIntervalBig;
  for (int i=0; i < nGrid; i++) {
    bigGridPoints[i]=gridStartValueBig + i * gridIntervalBig;
  }
  nGrid=(int)Math.floor(intervalValue / gridIntervalSmall) + 1;
  if (nGrid != gridPointsArray[1].length) {
    gridPointsArray[1]=new double[nGrid];
  }
  double[] smallGridPoints=gridPointsArray[1];
  double gridStartValueSmall=Math.ceil(startValue / gridIntervalSmall) * gridIntervalSmall;
  for (int i=0; i < nGrid; i++) {
    smallGridPoints[i]=gridStartValueSmall + i * gridIntervalSmall;
  }
}