26package umontreal.ssj.hups;
29import java.net.MalformedURLException;
30import umontreal.ssj.util.PrintfFormat;
111 private String filename;
114 private void readData(Reader re,
int r1,
int s1)
throws IOException, NumberFormatException {
116 StreamTokenizer st =
new StreamTokenizer(re);
119 st.eolIsSignificant(
false);
120 st.slashSlashComments(
true);
122 int i = st.nextToken();
123 if (i != StreamTokenizer.TT_NUMBER)
124 throw new NumberFormatException();
127 numCols = (int) st.nval;
129 numRows = (int) st.nval;
136 throw new IllegalArgumentException(
"dimension dim <= 0");
139 throw new IllegalArgumentException(
"DigitalNetBase2FromFile: One must have r1 <= Max num rows");
141 throw new IllegalArgumentException(
"s1 is too large");
149 System.err.println(
"***** DigitalNetBase2FromFile: only base 2 allowed");
150 throw new IllegalArgumentException(
"only base 2 allowed");
152 genMat =
new int[
dim * numCols];
153 for (i = 0; i <
dim; i++)
154 for (
int c = 0; c < numCols; c++) {
156 genMat[i * numCols + c] = (int) st.nval;
159 }
catch (NumberFormatException e) {
160 System.err.println(
" DigitalNetBase2FromFile: not a number " + e);
165 private void maskRows(
int r,
int w) {
167 int mask = (int) ((1L << r) - 1);
169 for (
int i = 0; i <
dim; i++)
170 for (
int c = 0; c < numCols; c++) {
171 genMat[i * numCols + c] &= mask;
172 genMat[i * numCols + c] >>=
MAXBITS - w;
193 throw new IllegalArgumentException(
" Must have numRows <= w <= 31");
195 BufferedReader input;
196 if (filename.startsWith(
"http:") || filename.startsWith(
"ftp:"))
202 readData(input, r1, s1);
203 }
catch (NumberFormatException e) {
204 System.err.println(
" DigitalNetBase2FromFile: cannot read from " + filename);
207 }
catch (IOException e) {
208 System.err.println(
" DigitalNetBase2FromFile: cannot read from " + filename);
212 maskRows(numRows, w);
215 throw new IllegalArgumentException(
" Must have numCols < 31");
217 this.filename = filename;
218 int x = (1 << numCols);
220 System.out.println(
"numPoints != 2^k");
221 throw new IllegalArgumentException(
"numPoints != 2^k");
224 normFactor = 1.0 / ((double) (1L << (outDigits)));
237 this(filename, -1, 31, s1);
242 sb.append(super.toString());
243 return sb.toString();
254 for (
int i = 0; i <
dim; i++) {
256 for (
int c = 0; c < numCols; c++)
260 return sb.toString();
270 public static String
listDir(String dirname)
throws IOException {
String toStringDetailed()
Writes the parameters and the generating matrices of this digital net to a string.
DigitalNetBase2FromFile(String filename, int r1, int w, int s1)
Constructs a digital net in base 2 after reading its parameters from file filename.
String toString()
Formats a string that contains information on this digital net.
static String listDir(String dirname)
Lists all files (or directories) in directory dirname.
DigitalNetBase2FromFile(String filename, int s1)
Same as DigitalNetBase2FromFile(filename,r, 31, s1) where s1 is the dimension and r is given in data ...
A special case of DigitalNet for the base .
This class allows us to read the parameters defining a digital net either from a file,...
static String listDir(String dirname)
Lists all files (or directories) in directory dirname.
static final int MAXBITS
Since Java has no unsigned type, the 32nd bit cannot be used efficiently, so we have only 31 bits.
int numPoints
Number of points.
int dim
Dimension of the points.