25package umontreal.ssj.discrepancy;
27import umontreal.ssj.util.Num;
28import umontreal.ssj.hups.KorobovLattice;
48 protected void print(
int y) {
50 System.out.printf(
" a = %d%n", y);
53 private void calcAs(
int n,
int s,
int a) {
56 for (
int j = 1; j < s; ++j)
57 bestAs[j] = (
int) ((b * bestAs[j - 1]) % n);
60 private double exhaust(
int s,
boolean relPrime) {
61 int n = disc.getNumPoints();
63 gamma = disc.getGamma();
64 bestVal = Double.MAX_VALUE;
67 for (
int i = 2; i < n; i++) {
80 err = disc.compute(lat, gamma);
91 private double random(
int s,
int k,
boolean relPrime) {
92 int n = disc.getNumPoints();
94 return exhaust(s, relPrime);
96 gamma = disc.getGamma();
97 final int nm1 = n - 1;
99 bestVal = Double.MAX_VALUE;
106 a = gen.nextInt(2, nm1);
111 a = gen.nextInt(2, nm1);
112 }
while (relPrime && (
Num.
gcd(n, a) != 1));
117 err = disc.compute(lat, gamma);
148 return exhaust(s,
false);
157 return exhaust(s,
false);
159 return exhaust(s,
true);
170 return random(s, k,
false);
179 return random(s, k,
false);
181 return random(s, k,
true);
This abstract class is the base class of all discrepancy classes.
double exhaustPrime(int s)
Similar to exhaust(s), except that only values of relatively prime to are considered.
double exhaust(int s)
Exhaustive search to find the best Korobov lattice (i.e.
double randomPrime(int s, int k)
Similar to random(s, k), except that only values of relatively prime to are considered.
SearcherKorobov(Discrepancy disc, boolean primeN)
The number of points , the dimension , and possibly the weight factors must be given in disc.
double random(int s, int k)
Random search to find the best Korobov lattice (with the smallest discrepancy) in dimension .
int getBestA()
Returns the generator of the lattice which gave the best value of the discrepancy in the last search...
Searcher(Discrepancy disc, boolean primeN)
The number of points , the dimension , and possibly the weight factors must be given in disc.
This class implements a Korobov lattice, which represents the same point set as in class LCGPointSet,...
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 .