SSJ  3.2.1
Stochastic Simulation in Java
 All Classes Namespaces Functions Variables Pages
Public Member Functions | List of all members
PointSetIterator Interface Reference

Objects of classes that implement this interface are iterators that permit one to enumerate (or observe) the successive points of a point set and the successive coordinates of these points. More...

Inheritance diagram for PointSetIterator:
[legend]
Collaboration diagram for PointSetIterator:
[legend]

Public Member Functions

void setCurCoordIndex (int j)
 Sets the current coordinate index to \(j\), so that the next calls to nextCoordinate or nextCoordinates will return the values \(u_{i,j}, u_{i,j+1}, …\), where \(i\) is the index of the current point. More...
 
void resetCurCoordIndex ()
 Equivalent to setCurCoordIndex(0).
 
int getCurCoordIndex ()
 Returns the index \(j\) of the current coordinate. More...
 
boolean hasNextCoordinate ()
 Returns true if the current point has another coordinate. More...
 
double nextCoordinate ()
 Returns the current coordinate \(u_{i,j}\) and advances to the next one. More...
 
void nextCoordinates (double[] p, int d)
 Returns the next d coordinates of the current point in p and advances the current coordinate index by d. More...
 
void setCurPointIndex (int i)
 Resets the current point index to \(i\) and the current coordinate index to zero. More...
 
void resetCurPointIndex ()
 Equivalent to setCurPointIndex(0).
 
int resetToNextPoint ()
 Increases the current point index by 1 and returns its new value. More...
 
int getCurPointIndex ()
 Returns the index \(i\) of the current point. More...
 
boolean hasNextPoint ()
 Returns true if there is a next point. More...
 
int nextPoint (double[] p, int fromDim, int d)
 Returns in p the next d coordinates of the current point, starting at coordinate fromDim (i.e., after skipping fromDim coordinates), then advances to the next point and returns the index of the new current point. More...
 
int nextPoint (double[] p, int d)
 Same as nextPoint(p, 0, d).
 
- Public Member Functions inherited from RandomStream
void resetStartStream ()
 Reinitializes the stream to its initial state \(I_g\): \(C_g\) and \(B_g\) are set to \(I_g\).
 
void resetStartSubstream ()
 Reinitializes the stream to the beginning of its current substream: \(C_g\) is set to \(B_g\).
 
void resetNextSubstream ()
 Reinitializes the stream to the beginning of its next substream: \(N_g\) is computed, and \(C_g\) and \(B_g\) are set to \(N_g\).
 
String toString ()
 Returns a string containing the current state of this stream. More...
 
double nextDouble ()
 Returns a (pseudo)random number from the uniform distribution over the interval \((0,1)\), using this stream, after advancing its state by one step. More...
 
void nextArrayOfDouble (double[] u, int start, int n)
 Generates n (pseudo)random numbers from the uniform distribution and stores them into the array u starting at index start. More...
 
int nextInt (int i, int j)
 Returns a (pseudo)random number from the discrete uniform distribution over the integers \(\{i,i+1,…,j\}\), using this stream. More...
 
void nextArrayOfInt (int i, int j, int[] u, int start, int n)
 Generates n (pseudo)random numbers from the discrete uniform distribution over the integers \(\{i,i+1,…,j\}\), using this stream and stores the result in the array u starting at index start. More...
 

Detailed Description

Objects of classes that implement this interface are iterators that permit one to enumerate (or observe) the successive points of a point set and the successive coordinates of these points.

Each PointSetIterator is associated with a given point set and maintains a current point index \(i\) and a current coordinate index \(j\), which are both initialized to zero.

Successive coordinates can be accessed one or many at a time by the methods nextCoordinate and nextCoordinates, respectively. The current coordinate index \(j\) can be set explicitely by setCurCoordIndex and resetCurCoordIndex. This could be used to skip some coordinates for each point, for example. Similar methods are available for resetting and accessing the current point. The method nextPoint permits one to enumerate the successive points in natural order.

This class also implements the umontreal.ssj.rng.RandomStream interface. This permits one to replace random numbers by the coordinates of (randomized) quasi-Monte Carlo points without changing the code that calls the generators in a simulation program. That is, the same simulation program can be used for both Monte Carlo and quasi-Monte Carlo simulations. The method nextDouble does exactly the same as nextCoordinate, it returns the current coordinate of the current point and advances the current coordinate by one. The substreams correspond to the points, so resetStartSubstream resets the current point coordinate to zero, resetNextSubstream resets the iterator to the next point, and resetStartStream resets the iterator to the first point of the point set.

There can be several iterators over the same point set. These iterators are independent from each other. Classes that implement this interface must maintain enough information so that each iterator is unaffected by other iterator’s operations. However, the iterator does not need to be independent of the underlying point set. If the point set is modified (e.g., randomized), the iterator may continue to work as usual.

Point set iterators are implemented as inner classes because this gives a direct access to the private members (or variables) of the class. This is important for efficiency. They are quite similar to the iterators in Java collections.

Member Function Documentation

int getCurCoordIndex ( )

Returns the index \(j\) of the current coordinate.

This may be useful, e.g., for testing if enough coordinates are still available.

Returns
index of the current coordinate

Implemented in PointSet.DefaultPointSetIterator.

int getCurPointIndex ( )

Returns the index \(i\) of the current point.

This can be useful, e.g., for caching point sets.

Returns
index of the current point

Implemented in PointSet.DefaultPointSetIterator.

boolean hasNextCoordinate ( )

Returns true if the current point has another coordinate.

This can be useful for testing if coordinates are still available.

Returns
true if the current point has another coordinate

Implemented in PointSet.DefaultPointSetIterator.

boolean hasNextPoint ( )

Returns true if there is a next point.

This can be useful for testing if points are still available.

Returns
true if a next point is available from the iterated point set

Implemented in PointSet.DefaultPointSetIterator.

double nextCoordinate ( )

Returns the current coordinate \(u_{i,j}\) and advances to the next one.

If no current coordinate is available (either because the current point index has reached the number of points or because the current coordinate index has reached the number of dimensions), it throws a NoSuchElementException.

Returns
value of the current coordinate
Exceptions
NoSuchElementExceptionif no such coordinate is available

Implemented in DigitalNet.DigitalNetIterator, PointSet.DefaultPointSetIterator, CachedPointSet.CachedPointSetIterator, Rank1Lattice.Rank1LatticeIterator, and SortedAndCutPointSet.SortedAndCutPointSetIterator.

void nextCoordinates ( double[]  p,
int  d 
)

Returns the next d coordinates of the current point in p and advances the current coordinate index by d.

If the remaining number of coordinates is too small, a NoSuchElementException is thrown, as in nextCoordinate.

Parameters
parray to be filled with the coordinates, starting at index 0
dnumber of coordinates to get
Exceptions
NoSuchElementExceptionif there are not enough remaining coordinates in the current point

Implemented in PointSet.DefaultPointSetIterator, and CachedPointSet.CachedPointSetIterator.

int nextPoint ( double[]  p,
int  fromDim,
int  d 
)

Returns in p the next d coordinates of the current point, starting at coordinate fromDim (i.e., after skipping fromDim coordinates), then advances to the next point and returns the index of the new current point.

Regardless of the current coordinate index, the point returned starts from coordinate fromDim. After obtaining the last point via this method, the current point index (returned by the method) is equal to the number of points, so it is no longer a valid point index. An exception will then be raised if we attempt to generate additional points or coordinates.

Specialized implementations of this method often allow for increased efficiency, e.g., for cycle-based point sets where the cycles (but not the points) are stored explicitly or for digital nets by allowing non-incremental point enumerations via Gray-code counters.

Parameters
parray to be filled with the coordinates, starting from array index 0
fromDimnumber of coordinates to be skipped
dnumber of coordinates to return
Returns
index of the new current point
Exceptions
NoSuchElementExceptionif there are not enough coordinates available in the current point for filling p

Implemented in PointSet.DefaultPointSetIterator.

int resetToNextPoint ( )

Increases the current point index by 1 and returns its new value.

If there is no more point, an exception will be raised only if we ask for a new coordinate or point later on.

Returns
index of the new current point

Implemented in DigitalNet.DigitalNetIteratorNoGray, DigitalNet.DigitalNetIterator, and PointSet.DefaultPointSetIterator.

void setCurCoordIndex ( int  j)

Sets the current coordinate index to \(j\), so that the next calls to nextCoordinate or nextCoordinates will return the values \(u_{i,j}, u_{i,j+1}, …\), where \(i\) is the index of the current point.

This can be useful to skip certain coordinates for each point, for example.

Parameters
jindex of the new current coordinate

Implemented in PointSet.DefaultPointSetIterator.

void setCurPointIndex ( int  i)

Resets the current point index to \(i\) and the current coordinate index to zero.

If i is larger or equal to the number of points, an exception will not be raised here, but only later if we ask for a new coordinate or point.

Parameters
inew index of the current point

Implemented in DigitalNet.DigitalNetIteratorNoGray, DigitalNet.DigitalNetIterator, and PointSet.DefaultPointSetIterator.


The documentation for this interface was generated from the following file: