Program: 76416
Project: 76416
Buggy source:
/** 
 * Return a new array that is filled with samples of a window of a specified length and type. Throw an IllegalArgumentException if the length is less than 1 or the window type is unknown.
 * @param length The length of the window to be generated.
 * @param windowType The type of window to generate.
 * @return A new array of doubles.
 */
public static final double[] generateWindow(int length,int windowType){
  if (length < 1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  int M=length - 1;
  int n;
  double[] window=new double[length];
switch (windowType) {
case WINDOW_TYPE_RECTANGULAR:
{
      for (n=0; n < length; n++) {
        window[n]=1.0;
      }
    }
  break;
case WINDOW_TYPE_BARTLETT:
{
  int halfM=length / 2;
  double twoOverM=2.0 / (double)M;
  for (n=0; n <= halfM; n++) {
    window[n]=twoOverM;
  }
  for (n=halfM + 1; n < length; n++) {
    window[n]=2.0 - twoOverM;
  }
}
break;
case WINDOW_TYPE_HANNING:
{
double twoPiOverM=2.0 * Math.PI / (double)M;
for (n=0; n < length; n++) {
window[n]=0.5 - 0.5 * Math.cos(twoPiOverM * n);
}
}
break;
case WINDOW_TYPE_HAMMING:
{
double twoPiOverM=2.0 * Math.PI / (double)M;
for (n=0; n < length; n++) {
window[n]=0.54 - 0.46 * Math.cos(twoPiOverM * n);
}
}
break;
case WINDOW_TYPE_BLACKMAN:
{
double twoPiOverM=2.0 * Math.PI / (double)M;
double fourPiOverM=2.0 * twoPiOverM;
for (n=0; n < length; n++) {
window[n]=0.42 - 0.5 * Math.cos(twoPiOverM * n) + 0.08 * Math.cos(fourPiOverM * n);
}
}
break;
case WINDOW_TYPE_BLACKMAN_HARRIS:
{
double twoPiOverM=2.0 * Math.PI / (double)M;
double fourPiOverM=2.0 * twoPiOverM;
double sixPiOverM=3.0 * twoPiOverM;
for (n=0; n < length; n++) {
window[n]=0.35875 - 0.48829 * Math.cos(twoPiOverM * n) + 0.14128 * Math.cos(fourPiOverM * n) - 0.01168 * Math.cos(sixPiOverM * n);
}
}
break;
default :
throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + windowType + "String_Node_Str");
}
return window;
}

Fixed version (ground truth):
/** 
 * Return a new array that is filled with samples of a window of a specified length and type. Throw an IllegalArgumentException if the length is less than 1 or the window type is unknown.
 * @param length The length of the window to be generated.
 * @param windowType The type of window to generate.
 * @return A new array of doubles.
 */
public static final double[] generateWindow(int length,int windowType){
  if (length < 1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  int M=length - 1;
  int n;
  double[] window=new double[length];
switch (windowType) {
case WINDOW_TYPE_RECTANGULAR:
{
      for (n=0; n < length; n++) {
        window[n]=1.0;
      }
    }
  break;
case WINDOW_TYPE_BARTLETT:
{
  int halfM=M / 2;
  double twoOverM=2.0 / (double)M;
  for (n=0; n <= halfM; n++) {
    window[n]=n * twoOverM;
  }
  for (n=halfM + 1; n < length; n++) {
    window[n]=2.0 - n * twoOverM;
  }
}
break;
case WINDOW_TYPE_HANNING:
{
double twoPiOverM=2.0 * Math.PI / (double)M;
for (n=0; n < length; n++) {
window[n]=0.5 - 0.5 * Math.cos(twoPiOverM * n);
}
}
break;
case WINDOW_TYPE_HAMMING:
{
double twoPiOverM=2.0 * Math.PI / (double)M;
for (n=0; n < length; n++) {
window[n]=0.54 - 0.46 * Math.cos(twoPiOverM * n);
}
}
break;
case WINDOW_TYPE_BLACKMAN:
{
double twoPiOverM=2.0 * Math.PI / (double)M;
double fourPiOverM=2.0 * twoPiOverM;
for (n=0; n < length; n++) {
window[n]=0.42 - 0.5 * Math.cos(twoPiOverM * n) + 0.08 * Math.cos(fourPiOverM * n);
}
}
break;
case WINDOW_TYPE_BLACKMAN_HARRIS:
{
double twoPiOverM=2.0 * Math.PI / (double)M;
double fourPiOverM=2.0 * twoPiOverM;
double sixPiOverM=3.0 * twoPiOverM;
for (n=0; n < length; n++) {
window[n]=0.35875 - 0.48829 * Math.cos(twoPiOverM * n) + 0.14128 * Math.cos(fourPiOverM * n) - 0.01168 * Math.cos(sixPiOverM * n);
}
}
break;
default :
throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + windowType + "String_Node_Str");
}
return window;
}