27package umontreal.ssj.hups;
29import umontreal.ssj.util.*;
30import umontreal.ssj.rng.RandomStream;
31import cern.colt.list.*;
53 protected int numCycles = 0;
55 private double[] shift;
57 protected ObjectArrayList cycles =
new ObjectArrayList();
64 for (k = 0; n <= i; k++)
65 n += l = ((AbstractList) cycles.get(k)).size();
66 AbstractList curCycle = (AbstractList) cycles.get(k - 1);
67 int coordinate = (i - n + l + j) % curCycle.size();
70 double x = ((DoubleArrayList) curCycle).
get(coordinate);
81 throw new IllegalArgumentException(
PrintfFormat.
NEWLINE +
" Calling addRandomShift with null stream");
83 d2 = Math.max(
dim, 1);
85 shift =
new double[d2];
91 double[] temp =
new double[d3];
93 for (
int i = 0; i < d1; i++)
98 for (
int i = d1; i < d2; i++)
107 super.clearRandomShift();
124 return Integer.MAX_VALUE;
132 String s = super.toString();
137 StringBuffer sb =
new StringBuffer(
toString());
138 for (
int c = 0; c < numCycles; c++) {
139 AbstractList curCycle = (AbstractList) cycles.get(c);
140 double[] cycle = ((DoubleArrayList) curCycle).elements();
142 boolean first =
true;
143 for (
int e = 0; e < curCycle.size(); e++) {
152 return sb.toString();
159 protected int startPointInCycle = 0;
161 protected int curCoordInCycle = 0;
163 protected int curCycleIndex = 0;
164 protected AbstractList curCycle;
165 protected double[] curCycleD;
167 public CycleBasedPointSetIterator() {
171 protected void init() {
175 public void resetCurCycle(
int index) {
176 curCycleIndex = index;
177 curCycle = (AbstractList) cycles.get(index);
178 curCycleD = ((DoubleArrayList) curCycle).elements();
183 curCoordInCycle = (i + startPointInCycle) % curCycle.size();
188 curCoordInCycle = startPointInCycle;
204 double x = curCycleD[curCoordInCycle];
216 if (curCoordInCycle >= curCycle.size())
228 int maxj = curCycle.size();
230 for (
int i = 0; i <
dim; i++) {
231 x = curCycleD[curCoordInCycle++];
232 if (curCoordInCycle >= maxj)
250 for (j = 0; n <= i; j++)
251 n += l = ((AbstractList) cycles.get(j)).size();
252 resetCurCycle(j - 1);
253 startPointInCycle = i - n + l;
256 curCoordInCycle = startPointInCycle;
261 startPointInCycle = 0;
270 if (startPointInCycle >= curCycle.size()) {
271 startPointInCycle = 0;
272 if (curCycleIndex < (numCycles - 1))
273 resetCurCycle(curCycleIndex + 1);
276 curCoordInCycle = startPointInCycle;
284 int j = startPointInCycle;
285 int maxj = curCycle.size() - 1;
286 for (
int i = 0; i <
dim; i++) {
boolean hasNextCoordinate()
int nextPoint(double p[], int dim)
Same as nextPoint(p, 0, d).
void resetCurPointIndex()
Resets both the current point index and the current coordinate to 0.
void setCurPointIndex(int i)
Resets the current point index to i and current coordinate to 0.
double nextDouble()
Same as nextCoordinate().
void nextCoordinates(double p[], int dim)
void resetCurCoordIndex()
Set current coordinate to 0.
void setCurCoordIndex(int i)
Set current coordinate to j.
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...
void addCycle(AbstractList c)
Adds the cycle c to the list of all cycles.
PointSetIterator iterator()
Constructs and returns a point set iterator.
int getDimension()
Returns the dimension (number of available coordinates) of the points.
String formatPoints()
Same as invoking formatPoints(n, d) with and equal to the number of points and the dimension of thi...
void addRandomShift(int d1, int d2, RandomStream stream)
Same as the same method in PointSet.
double getCoordinate(int i, int j)
Returns , the coordinate of the point .
void clearRandomShift()
Erases the current random shift, if any.
String toString()
Formats a string that contains information about the point set.
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.
int getNumPoints()
Returns the number of points.
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...
double nextDouble()
Returns a (pseudo)random number from the uniform distribution over the interval , using this stream,...