|
SSJ V. 2.6.2. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object umontreal.iro.lecuyer.hups.PointSet
public abstract class PointSet
This 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 by getNumPoints
.
The points and coordinates are both numbered starting from 0
and their number can actually be infinite.
The iterator
method 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
the PointSetIterator
interface.
The default implementation of iterator provided here relies on
the method getCoordinate
to access the coordinates directly.
However, this approach is rarely efficient.
Specialized implementations that dramatically improve the performance
are provided in subclasses of PointSet
.
The PointSetIterator
interface actually extends the
RandomStream
interface, so that the
iterator can also be seen as a RandomStream
and 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
overwriting iterator
to provide a custom iterator that does not
necessarily rely on getCoordinate
.
In fact, direct use of getCoordinate
to access the coordinates
is discouraged.
One should access the coordinates only via the iterators.
Constructor Summary | |
---|---|
PointSet()
|
Method Summary | |
---|---|
void |
addRandomShift()
Deprecated. |
void |
addRandomShift(int d1,
int d2)
Deprecated. |
void |
addRandomShift(int d1,
int d2,
RandomStream stream)
This method does nothing for this generic class. |
void |
addRandomShift(RandomStream stream)
This method does nothing for this generic class. |
void |
clearRandomShift()
Erases the current random shift, if any. |
String |
formatPoints()
Same as invoking formatPoints (n, d) with n and d equal to the
number of points and the dimension of this object, respectively. |
String |
formatPoints(int n,
int d)
Formats a string that displays the same information as returned by toString , together with the first d coordinates of the
first n points. |
String |
formatPoints(PointSetIterator iter)
Same as invoking formatPoints (iter, n, d)
with n and d equal to the number of points and the dimension, respectively. |
String |
formatPoints(PointSetIterator iter,
int n,
int d)
Same as invoking formatPoints (n, d), but
prints the points by calling iter repeatedly. |
String |
formatPointsBase(int b)
Similar to formatPoints (), but the
points coordinates are printed in base b. |
String |
formatPointsBase(int n,
int d,
int b)
Similar to formatPoints (n, d), but the
points coordinates are printed in base b. |
String |
formatPointsBase(PointSetIterator iter,
int b)
Similar to formatPoints (iter),
but the points coordinates are printed in base b. |
String |
formatPointsBase(PointSetIterator iter,
int n,
int d,
int b)
Similar to formatPoints (iter, n, d),
but the points coordinates are printed in base b. |
String |
formatPointsNumbered()
Same as invoking formatPointsNumbered (n, d)
with n and d equal to the number of points and the dimension,
respectively. |
String |
formatPointsNumbered(int n,
int d)
Same as invoking formatPoints (n,d), except that the points are numbered. |
abstract double |
getCoordinate(int i,
int j)
Returns ui, j, the coordinate j of the point i. |
int |
getDimension()
Returns the dimension (number of available coordinates) of the point set. |
int |
getNumPoints()
Returns the number of points. |
RandomStream |
getStream()
Returns the random stream used to generate random shifts. |
PointSetIterator |
iterator()
Constructs and returns a point set iterator. |
void |
randomize()
Deprecated. |
void |
randomize(int d1,
int d2)
Deprecated. |
void |
randomize(int d1,
int d2,
RandomStream stream)
By default, this method simply calls addRandomShift(d1, d2, stream). |
void |
randomize(PointSetRandomization rand)
Randomizes the point set using the given rand. |
void |
randomize(RandomStream stream)
By default, this method simply calls addRandomShift(stream). |
void |
setStream(RandomStream stream)
Sets the random stream used to generate random shifts to stream. |
String |
toString()
Formats a string that contains information about the point set. |
void |
unrandomize()
By default, this method simply calls clearRandomShift(). |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PointSet()
Method Detail |
---|
public int getDimension()
public int getNumPoints()
public abstract double getCoordinate(int i, int j)
i
- index of the point to look forj
- index of the coordinate to look for
public PointSetIterator iterator()
getCoordinate
(i,j) to iterate over the
points and coordinates, but subclasses can reimplement it
for better efficiency.
public void setStream(RandomStream stream)
stream
- the new random streampublic RandomStream getStream()
public void randomize(PointSetRandomization rand)
rand
- PointSetRandomization
to usepublic void addRandomShift(int d1, int d2, RandomStream stream)
public void addRandomShift(RandomStream stream)
@Deprecated public void addRandomShift(int d1, int d2)
@Deprecated public void addRandomShift()
public void clearRandomShift()
public void randomize(int d1, int d2, RandomStream stream)
public void randomize(RandomStream stream)
@Deprecated public void randomize(int d1, int d2)
@Deprecated public void randomize()
public void unrandomize()
public String toString()
toString
in class Object
public String formatPoints()
formatPoints
(n, d) with n and d equal to the
number of points and the dimension of this object, respectively.
UnsupportedOperationException
- if the number of points
or dimension of the point set is infinitepublic String formatPoints(int n, int d)
toString
, 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.
n
- number of pointsd
- dimension
public String formatPoints(PointSetIterator iter)
formatPoints
(iter, n, d)
with n and d equal to the number of points and the dimension, respectively.
iter
- iterator associated to the point set
UnsupportedOperationException
- if the number of points
or dimension of the point set is infinitepublic String formatPoints(PointSetIterator iter, int n, int d)
formatPoints
(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.
iter
- iterator associated to the point setn
- number of pointsd
- dimension
public String formatPointsBase(int b)
formatPoints
(), but the
points coordinates are printed in base b.
b
- base
UnsupportedOperationException
- if the number of points
or dimension of the point set is infinitepublic String formatPointsBase(int n, int d, int b)
formatPoints
(n, d), but the
points coordinates are printed in base b.
n
- number of pointsd
- dimensionb
- base
public String formatPointsBase(PointSetIterator iter, int b)
formatPoints
(iter),
but the points coordinates are printed in base b.
iter
- iterator associated to the point setb
- base
UnsupportedOperationException
- if the number of points
or dimension of the point set is infinitepublic String formatPointsBase(PointSetIterator iter, int n, int d, int b)
formatPoints
(iter, n, d),
but the points coordinates are printed in base b.
iter
- iterator associated to the point setn
- number of pointsd
- dimensionb
- base
public String formatPointsNumbered()
formatPointsNumbered
(n, d)
with n and d equal to the number of points and the dimension,
respectively.
UnsupportedOperationException
- if the number of points
or dimension of the point set is infinitepublic String formatPointsNumbered(int n, int d)
formatPoints
(n,d), except that the points are numbered.
n
- number of pointsd
- dimension
|
SSJ V. 2.6.2. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |