Class PointSet
- java.lang.Object
-
- umontreal.iro.lecuyer.hups.PointSet
-
- Direct Known Subclasses:
- CachedPointSet, ContainerPointSet, CycleBasedPointSet, DigitalNet, HaltonSequence, HammersleyPointSet, PaddedPointSet, Rank1Lattice, SubsetOfPointSet
public abstract class PointSet extends java.lang.ObjectThis abstract class defines the basic methods for accessing and manipulating point sets. A point set can be represented as a two-dimensional array, whose element (i, j) contains ui, j, the coordinate j of point i. Each coordinate ui, j is assumed to be in the unit interval [0, 1]. Whether the values 0 and 1 can occur may depend on the actual implementation of the point set.All points have the same number of coordinates (their dimension) and this number can be queried by
getDimension. The number of points is queried bygetNumPoints. The points and coordinates are both numbered starting from 0 and their number can actually be infinite.The
iteratormethod provides a point set iterator which permits one to enumerate the points and their coordinates. Several iterators over the same point set can coexist at any given time. These iterators are instances of a hidden inner-class that implements thePointSetIteratorinterface. The default implementation of iterator provided here relies on the methodgetCoordinateto access the coordinates directly. However, this approach is rarely efficient. Specialized implementations that dramatically improve the performance are provided in subclasses ofPointSet. ThePointSetIteratorinterface actually extends theRandomStreaminterface, so that the iterator can also be seen as aRandomStreamand used wherever such a stream is required for generating uniform random numbers. This permits one to easily replace pseudorandom numbers by the coordinates of a selected set of highly-uniform points, i.e., to replace Monte Carlo by quasi-Monte Carlo in a simulation program.This abstract class has only one abstract method:
getCoordinate. Providing an implementation for this method is already sufficient for the subclass to work. However, in practically all cases, efficiency can be dramatically improved by overwritingiteratorto provide a custom iterator that does not necessarily rely ongetCoordinate. In fact, direct use ofgetCoordinateto access the coordinates is discouraged. One should access the coordinates only via the iterators.
-
-
Constructor Summary
Constructors Constructor and Description PointSet()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidaddRandomShift()Deprecated.voidaddRandomShift(int d1, int d2)Deprecated.voidaddRandomShift(int d1, int d2, RandomStream stream)This method does nothing for this generic class.voidaddRandomShift(RandomStream stream)This method does nothing for this generic class.voidclearRandomShift()Erases the current random shift, if any.java.lang.StringformatPoints()Same as invokingformatPoints(n, d) with n and d equal to the number of points and the dimension of this object, respectively.java.lang.StringformatPoints(int n, int d)Formats a string that displays the same information as returned bytoString, together with the first d coordinates of the first n points.java.lang.StringformatPoints(PointSetIterator iter)Same as invokingformatPoints(iter, n, d) with n and d equal to the number of points and the dimension, respectively.java.lang.StringformatPoints(PointSetIterator iter, int n, int d)Same as invokingformatPoints(n, d), but prints the points by calling iter repeatedly.java.lang.StringformatPointsBase(int b)Similar toformatPoints(), but the points coordinates are printed in base b.java.lang.StringformatPointsBase(int n, int d, int b)Similar toformatPoints(n, d), but the points coordinates are printed in base b.java.lang.StringformatPointsBase(PointSetIterator iter, int b)Similar toformatPoints(iter), but the points coordinates are printed in base b.java.lang.StringformatPointsBase(PointSetIterator iter, int n, int d, int b)Similar toformatPoints(iter, n, d), but the points coordinates are printed in base b.java.lang.StringformatPointsNumbered()Same as invokingformatPointsNumbered(n, d) with n and d equal to the number of points and the dimension, respectively.java.lang.StringformatPointsNumbered(int n, int d)Same as invokingformatPoints(n,d), except that the points are numbered.abstract doublegetCoordinate(int i, int j)Returns ui, j, the coordinate j of the point i.intgetDimension()Returns the dimension (number of available coordinates) of the point set.intgetNumPoints()Returns the number of points.RandomStreamgetStream()Returns the random stream used to generate random shifts.PointSetIteratoriterator()Constructs and returns a point set iterator.voidrandomize()Deprecated.voidrandomize(int d1, int d2)Deprecated.voidrandomize(int d1, int d2, RandomStream stream)By default, this method simply calls addRandomShift(d1, d2, stream).voidrandomize(PointSetRandomization rand)Randomizes the point set using the given rand.voidrandomize(RandomStream stream)By default, this method simply calls addRandomShift(stream).voidsetStream(RandomStream stream)Sets the random stream used to generate random shifts to stream.java.lang.StringtoString()Formats a string that contains information about the point set.voidunrandomize()By default, this method simply calls clearRandomShift().
-
-
-
Method Detail
-
getDimension
public int getDimension()
Returns the dimension (number of available coordinates) of the point set. If the dimension is actually infinite, Integer.MAX_VALUE is returned.- Returns:
- the dimension of the point set or Integer.MAX_VALUE if it is infinite
-
getNumPoints
public int getNumPoints()
Returns the number of points. If this number is actually infinite, Integer.MAX_VALUE is returned.- Returns:
- the number of points in the point set or Integer.MAX_VALUE if the point set has an infinity of points.
-
getCoordinate
public abstract double getCoordinate(int i, int j)Returns ui, j, the coordinate j of the point i.- Parameters:
i- index of the point to look forj- index of the coordinate to look for- Returns:
- the value of ui, j
-
iterator
public PointSetIterator iterator()
Constructs and returns a point set iterator. The default implementation returns an iterator that uses the methodgetCoordinate(i,j) to iterate over the points and coordinates, but subclasses can reimplement it for better efficiency.- Returns:
- point set iterator for the point set
-
setStream
public void setStream(RandomStream stream)
Sets the random stream used to generate random shifts to stream.- Parameters:
stream- the new random stream
-
getStream
public RandomStream getStream()
Returns the random stream used to generate random shifts.- Returns:
- the random stream used
-
randomize
public void randomize(PointSetRandomization rand)
Randomizes the point set using the given rand.- Parameters:
rand-PointSetRandomizationto use
-
addRandomShift
public void addRandomShift(int d1, int d2, RandomStream stream)This method does nothing for this generic class. In some subclasses, it adds a random shift to all the points of the point set, using stream stream to generate the random numbers, for coordinates d1 to d2-1.
-
addRandomShift
public void addRandomShift(RandomStream stream)
This method does nothing for this generic class. Similar to addRandomShift (0, d2, stream), with d2 the dimension of the current random shift.
-
addRandomShift
@Deprecated public void addRandomShift(int d1, int d2)Deprecated.Similar to addRandomShift(d1, d2, stream), with the current random stream.
-
addRandomShift
@Deprecated public void addRandomShift()
Deprecated.
-
clearRandomShift
public void clearRandomShift()
Erases the current random shift, if any.
-
randomize
public void randomize(int d1, int d2, RandomStream stream)By default, this method simply calls addRandomShift(d1, d2, stream).
-
randomize
public void randomize(RandomStream stream)
By default, this method simply calls addRandomShift(stream).
-
randomize
@Deprecated public void randomize(int d1, int d2)Deprecated.By default, this method simply calls addRandomShift(d1, d2).
-
randomize
@Deprecated public void randomize()
Deprecated.
-
unrandomize
public void unrandomize()
By default, this method simply calls clearRandomShift().
-
toString
public java.lang.String toString()
Formats a string that contains information about the point set.- Overrides:
toStringin classjava.lang.Object- Returns:
- string representation of the point set information
-
formatPoints
public java.lang.String formatPoints()
Same as invokingformatPoints(n, d) with n and d equal to the number of points and the dimension of this object, respectively.- Returns:
- string representation of all the points in the point set
- Throws:
java.lang.UnsupportedOperationException- if the number of points or dimension of the point set is infinite
-
formatPoints
public java.lang.String formatPoints(int n, int d)Formats a string that displays the same information as returned bytoString, together with the first d coordinates of the first n points. If n is larger than the number of points in the point set, it is reset to that number. If d is larger than the dimension of the points, it is reset to that dimension. The points are printed in the simplest format, separated by spaces, by calling the default iterator repeatedly.- Parameters:
n- number of pointsd- dimension- Returns:
- string representation of first d coordinates of first n points in the point set
-
formatPoints
public java.lang.String formatPoints(PointSetIterator iter)
Same as invokingformatPoints(iter, n, d) with n and d equal to the number of points and the dimension, respectively.- Parameters:
iter- iterator associated to the point set- Returns:
- string representation of all the points in the point set
- Throws:
java.lang.UnsupportedOperationException- if the number of points or dimension of the point set is infinite
-
formatPoints
public java.lang.String formatPoints(PointSetIterator iter, int n, int d)
Same as invokingformatPoints(n, d), but prints the points by calling iter repeatedly. The order of the printed points may be different than the one resulting from the default iterator.- Parameters:
iter- iterator associated to the point setn- number of pointsd- dimension- Returns:
- string representation of first d coordinates of first n points in the point set
-
formatPointsBase
public java.lang.String formatPointsBase(int b)
Similar toformatPoints(), but the points coordinates are printed in base b.- Parameters:
b- base- Returns:
- string representation of all the points in the point set
- Throws:
java.lang.UnsupportedOperationException- if the number of points or dimension of the point set is infinite
-
formatPointsBase
public java.lang.String formatPointsBase(int n, int d, int b)Similar toformatPoints(n, d), but the points coordinates are printed in base b.- Parameters:
n- number of pointsd- dimensionb- base- Returns:
- string representation of first d coordinates of first n points in the point set
-
formatPointsBase
public java.lang.String formatPointsBase(PointSetIterator iter, int b)
Similar toformatPoints(iter), but the points coordinates are printed in base b.- Parameters:
iter- iterator associated to the point setb- base- Returns:
- string representation of all the points in the point set
- Throws:
java.lang.UnsupportedOperationException- if the number of points or dimension of the point set is infinite
-
formatPointsBase
public java.lang.String formatPointsBase(PointSetIterator iter, int n, int d, int b)
Similar toformatPoints(iter, n, d), but the points coordinates are printed in base b.- Parameters:
iter- iterator associated to the point setn- number of pointsd- dimensionb- base- Returns:
- string representation of first d coordinates of first n points in the point set
-
formatPointsNumbered
public java.lang.String formatPointsNumbered()
Same as invokingformatPointsNumbered(n, d) with n and d equal to the number of points and the dimension, respectively.- Returns:
- string representation of all the points in the point set
- Throws:
java.lang.UnsupportedOperationException- if the number of points or dimension of the point set is infinite
-
formatPointsNumbered
public java.lang.String formatPointsNumbered(int n, int d)Same as invokingformatPoints(n,d), except that the points are numbered.- Parameters:
n- number of pointsd- dimension- Returns:
- string representation of first d coordinates of first n points in the point set
-
-
DMelt 3.0 © DataMelt by jWork.ORG