/** * Constructs a digital net in base 2 after reading its parameters from file `filename`. See the * documentation in * * @ref umontreal.ssj.hups.DigitalNetFromFile. Parameter `w` gives the number of bits of * resolution, `r1` is the number of rows, and `s1` is the dimension. Restrictions: `s1` must * be less than the maximal dimension, and `r1` less than the maximal number of rows in the * data file. Also `w` @f$\ge@f$ `r1`. * @param filename Name of the file to be read * @param r1 Number of rows for the generating matrices * @param w Number of bits of resolution * @param s1 Number of dimensions */ public DigitalNetBase2FromFile(String filename, int r1, int w, int s1) throws IOException, MalformedURLException { super(); if (w < r1 || w > MAXBITS) throw new IllegalArgumentException(" Must have numRows <= w <= 31"); BufferedReader input; if (filename.startsWith("http:") || filename.startsWith("ftp:")) input = DigitalNetFromFile.openURL(filename); else input = DigitalNetFromFile.openFile(filename); try { readData(input, r1, s1); } catch (NumberFormatException e) { System.err.println(" DigitalNetBase2FromFile: cannot read from " + filename); throw e; } catch (IOException e) { System.err.println(" DigitalNetBase2FromFile: cannot read from " + filename); throw e; } input.close(); maskRows(numRows, w); outDigits = w; if (numCols >= MAXBITS) throw new IllegalArgumentException(" Must have numCols < 31"); this.filename = filename; int x = (1 << numCols); if (x != numPoints) { System.out.println("numPoints != 2^k"); throw new IllegalArgumentException("numPoints != 2^k"); } // Compute the normalization factors. normFactor = 1.0 / ((double) (1L << (outDigits))); }