25package umontreal.ssj.discrepancy;
27import umontreal.ssj.rng.*;
28import umontreal.ssj.hups.*;
29import umontreal.ssj.util.Num;
56 protected double[] gamma;
57 protected double bestVal;
58 protected int[] bestAs;
59 protected boolean primeN =
false;
60 protected boolean power2F =
false;
62 protected void print(
int[] y,
int s) {
64 System.out.printf(
" a = [ ");
65 for (
int j = 0; j < s; ++j) {
66 System.out.printf(
"%d ", y[j]);
68 System.out.printf(
"]%n");
71 private void incr(
int[] y,
int n,
int s) {
77 for (
int i = s - 1; i >= 1; --i) {
86 private void incrPrime(
int[] y,
int n,
int s) {
89 for (
int i = s - 1; i >= 1; --i) {
94 while (
Num.
gcd(n, y[i]) != 1)
104 private double exhaust(
int s,
boolean relPrime) {
109 gamma = disc.getGamma();
112 int[] y =
new int[s];
113 for (j = 0; j < s; j++)
115 bestVal = Double.MAX_VALUE;
121 err = disc.compute(lat, gamma);
126 for (j = 1; j < s; j++)
138 private double random(
int s,
int k,
boolean relPrime) {
142 int n = disc.getNumPoints();
143 gamma = disc.getGamma();
144 final int nm1 = n - 1;
147 bestVal = Double.MAX_VALUE;
148 int[] y =
new int[s];
149 y[0] = bestAs[0] = 1;
151 for (
int i = 0; i < k; i++) {
152 for (j = 1; j < s; j++) {
154 y[j] = gen.nextInt(1, nm1);
159 y[j] = gen.nextInt(1, nm1);
160 }
while (relPrime && (
Num.
gcd(n, y[j]) != 1));
165 err = disc.compute(lat, gamma);
168 for (j = 1; j < s; j++)
185 int s = disc.getDimension();
186 int n = disc.getNumPoints();
188 this.primeN = primeN;
189 if ((n & (n - 1)) == 0)
204 return exhaust(s,
false);
213 return exhaust(s,
false);
215 return exhaust(s,
true);
227 return random(s, k,
false);
236 return random(s, k,
false);
238 return random(s, k,
true);
263 if (seed == 0 || seed == 1)
266 int[] state = { seed, s, s, s };
This abstract class is the base class of all discrepancy classes.
void initGen(int seed)
Initializes the random number generator used in random searches with the starting seed seed.
double random(int s, int k)
Random search to find the lattice with the best (the smallest) discrepancy in dimension .
double getBestVal()
Returns the best value of the discrepancy found in the last search.
double randomPrime(int s, int k)
Similar to random(s, k), except that only values of relatively prime to are considered.
Searcher(Discrepancy disc, boolean primeN)
The number of points , the dimension , and possibly the weight factors must be given in disc.
double exhaust(int s)
Exhaustive search to find the lattice with the best (the smallest) discrepancy in dimension .
double exhaustPrime(int s)
Similar to exhaust(s), except that only values of relatively prime to are considered.
int[] getBestAs()
Returns the generator of the lattice which gave the best value of the discrepancy in the last search.
This abstract class represents a general point set.
int getNumPoints()
Returns the number of points.
This class implements point sets specified by integration lattices of rank 1.
Extends RandomStreamBase using a composite linear feedback shift register (LFSR) (or Tausworthe) RNG ...
static void setPackageSeed(int[] seed)
Sets the initial seed for the class LFSR113 to the four integers of the vector seed[0....
This class provides various constants and methods to compute numerical quantities such as factorials,...
static int gcd(int x, int y)
Returns the greatest common divisor (gcd) of and .
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...