25package umontreal.ssj.hups;
27import umontreal.ssj.util.PrintfFormat;
28import umontreal.ssj.rng.RandomStream;
29import cern.colt.list.*;
53 private int[] digitalShift;
55 protected int numBits;
56 protected double normFactor;
63 for (k = 0; n <= i; k++)
64 n += l = ((AbstractList) cycles.get(k)).size();
65 AbstractList curCycle = (AbstractList) cycles.get(k - 1);
66 int[] curCycleI = ((IntArrayList) curCycle).elements();
67 int coordinate = (i - n + l + j) % curCycle.size();
69 if (digitalShift !=
null) {
70 shift = digitalShift[j];
71 return (shift ^ curCycleI[coordinate]) * normFactor +
EpsilonHalf;
73 return (shift ^ curCycleI[coordinate]) * normFactor;
88 throw new IllegalArgumentException(
PrintfFormat.
NEWLINE +
" Calling addRandomShift with null stream");
90 d2 = Math.max(1,
dim);
91 if (digitalShift ==
null) {
92 digitalShift =
new int[d2];
98 int[] temp =
new int[d3];
101 temp[i] = digitalShift[i];
107 maxj = (1 << numBits) - 1;
111 for (
int i = d1; i < d2; i++)
112 digitalShift[i] = stream.
nextInt(0, maxj);
121 super.clearRandomShift();
126 StringBuffer sb =
new StringBuffer(
toString());
127 for (
int c = 0; c < numCycles; c++) {
128 AbstractList curCycle = (AbstractList) cycles.get(c);
129 int[] cycle = ((IntArrayList) curCycle).elements();
131 boolean first =
true;
132 for (
int e = 0; e < curCycle.size(); e++) {
141 return sb.toString();
146 public class CycleBasedPointSetBase2Iterator
extends CycleBasedPointSetIterator {
148 protected int[] curCycleI;
150 public CycleBasedPointSetBase2Iterator() {
155 protected void init() {
158 public void resetCurCycle(
int index) {
159 curCycleIndex = index;
160 curCycle = (AbstractList) cycles.get(index);
161 curCycleI = ((IntArrayList) curCycle).elements();
168 int x = curCycleI[curCoordInCycle];
169 if (digitalShift !=
null) {
176 if (curCoordInCycle >= curCycle.size())
178 if (digitalShift ==
null)
179 return x * normFactor;
191 int maxj = curCycle.size();
193 for (
int i = 0; i <
dim; i++) {
194 x = curCycleI[curCoordInCycle++];
195 if (curCoordInCycle >= maxj)
197 if (digitalShift ==
null)
198 p[i] = x * normFactor;
209 curCoordInCycle = startPointInCycle;
int nextPoint(double p[], int dim)
Same as nextPoint(p, 0, d).
void nextCoordinates(double p[], int dim)
Similar to CycleBasedPointSet, except that the successive values in the cycles are stored as integers...
PointSetIterator iterator()
Constructs and returns a point set iterator.
void addRandomShift(int d1, int d2, RandomStream stream)
Adds a random digital shift in base 2 to all the points of the point set, using stream stream to gene...
void clearRandomShift()
Erases the current digital random shift, if any.
String formatPoints()
Same as invoking formatPoints(n, d) with and equal to the number of points and the dimension of thi...
double getCoordinate(int i, int j)
Returns , the coordinate of the point .
int resetToNextPoint()
Resets the current point index to the next one and current coordinate to 0, and returns the new curre...
This abstract class provides the basic structures for storing and manipulating a point set defined by...
String toString()
Formats a string that contains information about the point set.
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.
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.
int getNumPoints()
Returns the number of points.
double EpsilonHalf
To avoid 0 for nextCoordinate when random shifting, we add this to each coordinate.
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.
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...
int nextInt(int i, int j)
Returns a (pseudo)random number from the discrete uniform distribution over the integers ,...