93 private static final int MAXDIM = 500;
116 init(b, k, r, w,
dim);
119 private void init(
int b,
int k,
int r,
int w,
int dim) {
121 throw new IllegalArgumentException(
"Dimension for FaureSequence must be > 1");
122 if ((
double) k * Math.log((
double) b) > (31.0 * Math.log(2.0)))
123 throw new IllegalArgumentException(
"Trying to construct a FaureSequence with too many points");
125 throw new IllegalArgumentException(
"One must have k <= r <= w for FaureSequence");
134 for (i = 1; i < k; i++)
138 normFactor = 1.0 / Math.pow((
double) b, (
double) outDigits);
140 double invb = 1.0 / b;
141 factor =
new double[outDigits];
143 for (j = 1; j < outDigits; j++)
144 factor[j] = factor[j - 1] * invb;
146 genMat =
new int[
dim * numCols][numRows];
161 if ((
dim < 1) || (
dim > MAXDIM))
162 throw new IllegalArgumentException(
"Dimension for Faure net must be > 1 and < " + MAXDIM);
163 b = getSmallestPrime(
dim);
164 numCols = (int) Math.ceil(Math.log((
double) n) / Math.log((
double) b));
165 outDigits = (int) Math.floor(Math.log((
double) (1 << (
MAXBITS - 1))) / Math.log((
double) b));
166 outDigits = Math.max(outDigits, numCols);
168 init(b, numCols, numRows, outDigits,
dim);
173 sb.append(super.toString());
174 return sb.toString();
178 init(b, k, numRows, outDigits,
dim);
183 private void initGenMat() {
186 for (c = 0; c < numCols; c++) {
187 for (l = 0; l < numRows; l++)
192 for (j = 1; j <
dim; j++) {
193 genMat[j * numCols][0] = 1;
194 for (c = 1; c < numCols; c++) {
195 genMat[j * numCols + c][c] = 1;
196 genMat[j * numCols + c][0] = (j * genMat[j * numCols + c - 1][0]) % b;
198 for (c = 2; c < numCols; c++) {
199 for (l = 1; l < c; l++)
200 genMat[j * numCols + c][l] = (genMat[j * numCols + c - 1][l - 1] + j * genMat[j * numCols + c - 1][l])
203 for (c = 0; c < numCols; c++)
204 for (l = c + 1; l < numRows; l++)
205 genMat[j * numCols + c][l] = 0;
231 private int getSmallestPrime(
int d) {
232 return primes[d - 1];
238 static final int primes[] = { 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11, 13, 13, 17, 17, 17, 17, 19, 19, 23, 23, 23, 23,
239 29, 29, 29, 29, 29, 29, 31, 31, 37, 37, 37, 37, 37, 37, 41, 41, 41, 41, 43, 43, 47, 47, 47, 47, 53, 53, 53, 53,
240 53, 53, 59, 59, 59, 59, 59, 59, 61, 61, 67, 67, 67, 67, 67, 67, 71, 71, 71, 71, 73, 73, 79, 79, 79, 79, 79, 79,
241 83, 83, 83, 83, 89, 89, 89, 89, 89, 89, 97, 97, 97, 97, 97, 97, 97, 97, 101, 101, 101, 101, 103, 103, 107, 107,
242 107, 107, 109, 109, 113, 113, 113, 113, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
243 131, 131, 131, 131, 137, 137, 137, 137, 137, 137, 139, 139, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
244 151, 151, 157, 157, 157, 157, 157, 157, 163, 163, 163, 163, 163, 163, 167, 167, 167, 167, 173, 173, 173, 173,
245 173, 173, 179, 179, 179, 179, 179, 179, 181, 181, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 193, 193,
246 197, 197, 197, 197, 199, 199, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 223, 223, 223, 223,
247 223, 223, 223, 223, 223, 223, 223, 223, 227, 227, 227, 227, 229, 229, 233, 233, 233, 233, 239, 239, 239, 239,
248 239, 239, 241, 241, 251, 251, 251, 251, 251, 251, 251, 251, 251, 251, 257, 257, 257, 257, 257, 257, 263, 263,
249 263, 263, 263, 263, 269, 269, 269, 269, 269, 269, 271, 271, 277, 277, 277, 277, 277, 277, 281, 281, 281, 281,
250 283, 283, 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307,
251 307, 307, 307, 307, 311, 311, 311, 311, 313, 313, 317, 317, 317, 317, 331, 331, 331, 331, 331, 331, 331, 331,
252 331, 331, 331, 331, 331, 331, 337, 337, 337, 337, 337, 337, 347, 347, 347, 347, 347, 347, 347, 347, 347, 347,
253 349, 349, 353, 353, 353, 353, 359, 359, 359, 359, 359, 359, 367, 367, 367, 367, 367, 367, 367, 367, 373, 373,
254 373, 373, 373, 373, 379, 379, 379, 379, 379, 379, 383, 383, 383, 383, 389, 389, 389, 389, 389, 389, 397, 397,
255 397, 397, 397, 397, 397, 397, 401, 401, 401, 401, 409, 409, 409, 409, 409, 409, 409, 409, 419, 419, 419, 419,
256 419, 419, 419, 419, 419, 419, 421, 421, 431, 431, 431, 431, 431, 431, 431, 431, 431, 431, 433, 433, 439, 439,
257 439, 439, 439, 439, 443, 443, 443, 443, 449, 449, 449, 449, 449, 449, 457, 457, 457, 457, 457, 457, 457, 457,
258 461, 461, 461, 461, 463, 463, 467, 467, 467, 467, 479, 479, 479, 479, 479, 479, 479, 479, 479, 479, 479, 479,
259 487, 487, 487, 487, 487, 487, 487, 487, 491, 491, 491, 491, 499, 499, 499, 499, 499, 499, 499, 499, 503 };