Program: 57230
Project: 57230
Buggy source:
/** 
 * Construct a new Sobol sequence generator for the given space dimension with direction vectors loaded from the given stream. <p> The expected format is identical to the files available from <a href="http://web.maths.unsw.edu.au/~fkuo/sobol/">Stephen Joe and Frances Kuo</a>. The first line will be ignored as it is assumed to contain only the column headers. The columns are: <ul> <li>d: the dimension</li> <li>s: the degree of the primitive polynomial</li> <li>a: the number representing the coefficients</li> <li>m: the list of initial direction numbers</li> </ul> Example: <pre> d       s       a       m_i 2       1       0       1 3       2       1       1 3 </pre>
 * @param dimension the space dimension
 * @param is the stream to read the direction vectors from
 * @throws NotStrictlyPositiveException if the space dimension is &lt; 1
 * @throws OutOfRangeException if the space dimension is outside the range [1, max], wheremax refers to the maximum dimension found in the input stream
 * @throws MathParseException if the content in the stream could not be parsed successfully
 * @throws IOException if an error occurs while reading from the input stream
 */
public SobolSequenceGenerator(final int dimension,final InputStream is) throws NotStrictlyPositiveException, MathParseException, IOException {
  if (dimension < 1) {
    throw new NotStrictlyPositiveException(dimension);
  }
  this.dimension=dimension;
  direction=new long[dimension][BITS + 1];
  x=new long[dimension];
  int lastDimension=initFromStream(is);
  if (lastDimension < dimension) {
    throw new OutOfRangeException(dimension,1,lastDimension);
  }
}

Fixed version (ground truth):
/** 
 * Construct a new Sobol sequence generator for the given space dimension with direction vectors loaded from the given stream. <p> The expected format is identical to the files available from <a href="http://web.maths.unsw.edu.au/~fkuo/sobol/">Stephen Joe and Frances Kuo</a>. The first line will be ignored as it is assumed to contain only the column headers. The columns are: <ul> <li>d: the dimension</li> <li>s: the degree of the primitive polynomial</li> <li>a: the number representing the coefficients</li> <li>m: the list of initial direction numbers</li> </ul> Example: <pre> d       s       a       m_i 2       1       0       1 3       2       1       1 3 </pre> <p> The input stream <i>must</i> be an ASCII text containing one valid direction vector per line.
 * @param dimension the space dimension
 * @param is the stream to read the direction vectors from
 * @throws NotStrictlyPositiveException if the space dimension is &lt; 1
 * @throws OutOfRangeException if the space dimension is outside the range [1, max], wheremax refers to the maximum dimension found in the input stream
 * @throws MathParseException if the content in the stream could not be parsed successfully
 * @throws IOException if an error occurs while reading from the input stream
 */
public SobolSequenceGenerator(final int dimension,final InputStream is) throws NotStrictlyPositiveException, MathParseException, IOException {
  if (dimension < 1) {
    throw new NotStrictlyPositiveException(dimension);
  }
  this.dimension=dimension;
  direction=new long[dimension][BITS + 1];
  x=new long[dimension];
  int lastDimension=initFromStream(is);
  if (lastDimension < dimension) {
    throw new OutOfRangeException(dimension,1,lastDimension);
  }
}