25package umontreal.ssj.hups;
27import umontreal.ssj.util.PrintfFormat;
28import umontreal.ssj.rng.RandomStream;
47 protected int[] genAs;
49 protected double normFactor;
51 private void initN(
int n) {
53 normFactor = 1.0 / (double) n;
54 for (
int j = 0; j <
dim; j++) {
55 int amod = (genAs[j] % n) + (genAs[j] < 0 ? n : 0);
56 v[j] = normFactor * amod;
72 for (
int j = 0; j < s; j++) {
108 throw new IllegalArgumentException(
PrintfFormat.
NEWLINE +
" Calling addRandomShift with null stream");
110 d2 = Math.max(1,
dim);
112 shift =
new double[d2];
118 double[] temp =
new double[d3];
120 for (
int i = 0; i < d1; i++)
125 for (
int i = d1; i < d2; i++)
134 super.clearRandomShift();
140 sb.append(super.toString());
141 return sb.toString();
145 double x = (v[j] * i) % 1.0;
159 protected long modPower(
long a,
int e,
int m) {
168 else if ((e & 1) == 1)
169 return (a * modPower(a, e - 1, m)) % m;
171 long p = modPower(a, e / 2, m);
176 protected double radicalInverse(
int base,
int i) {
177 double digit, radical, inverse;
178 digit = radical = 1.0 / (double) base;
179 for (inverse = 0.0; i > 0; i /= base) {
180 inverse += digit * (double) (i % base);
This class implements a default point set iterator.
int curPointIndex
Index of the current point.
int curCoordIndex
Index of the current coordinate.
double EpsilonHalf
Default constant epsilon/2 added to the points after a random shift.
void outOfBounds()
Error message for index out of bounds.
This abstract class represents a general point set.
int dimShift
Current dimension of the shift.
void addRandomShift()
Same as addRandomShift(0, dim), where dim is the dimension of the point set.
int numPoints
Number of points.
double EpsilonHalf
To avoid 0 for nextCoordinate when random shifting, we add this to each coordinate.
double[] shift
This is the shift vector as a double[] array, which contains the current random shift in case we appl...
int capacityShift
Number of array elements in the shift vector, always >= dimShift.
int dim
Dimension of the points.
RandomStream shiftStream
Stream used to generate the random shifts.
Rank1Lattice(int n, int[] a, int s)
Instantiates a Rank1Lattice with points and lattice vector of dimension .
void clearRandomShift()
Clears the random shift.
void setNumPoints(int n)
Resets the number of points of the lattice to .
double getCoordinate(int i, int j)
Returns , the coordinate of the point .
String toString()
Formats a string that contains information about the point set.
PointSetIterator iterator()
Constructs and returns a point set iterator.
int[] getAs()
Returns the generator of the lattice.
void addRandomShift(int d1, int d2, RandomStream stream)
Adds a random shift to all the points of the point set, using stream stream to generate the random nu...
This is the interface for iterators that permit one to go through the points of a PointSet and the su...
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...
double nextDouble()
Returns a (pseudo)random number from the uniform distribution over the interval , using this stream,...