25package umontreal.ssj.hups;
27import java.util.NoSuchElementException;
28import umontreal.ssj.rng.RandomStream;
29import umontreal.ssj.util.Num;
30import umontreal.ssj.util.PrintfFormat;
242 if (d1 < 0 || d1 > d2)
243 throw new IllegalArgumentException(
"illegal parameter d1 or d2");
248 double[] temp =
new double[d3];
250 for (
int i = 0; i < d1; i++)
256 for (
int i = d1; i < d2; i++)
302 StringBuffer sb =
new StringBuffer(
"Number of points: ");
304 if (x == Integer.MAX_VALUE)
305 sb.append(
"infinite");
310 if (x == Integer.MAX_VALUE)
311 sb.append(
"infinite");
314 return sb.toString();
364 if (n == Integer.MAX_VALUE)
365 throw new UnsupportedOperationException(
"Number of points is infinite");
367 if (d == Integer.MAX_VALUE)
368 throw new UnsupportedOperationException(
"Dimension is infinite");
388 StringBuffer sb =
new StringBuffer(
toString());
390 for (
int i = 0; i < n; i++) {
391 for (
int j = 0; j < d; j++) {
398 return sb.toString();
444 if (n == Integer.MAX_VALUE)
445 throw new UnsupportedOperationException(
"Number of points is infinite");
447 if (d == Integer.MAX_VALUE)
448 throw new UnsupportedOperationException(
"Dimension is infinite");
468 StringBuffer sb =
new StringBuffer(
toString());
480 for (
int i = 0; i < n; i++) {
481 for (
int j = 0; j < d; j++) {
490 return sb.toString();
505 if (n == Integer.MAX_VALUE)
506 throw new UnsupportedOperationException(
"Number of points is infinite");
508 if (d == Integer.MAX_VALUE)
509 throw new UnsupportedOperationException(
"Dimension is infinite");
527 StringBuffer sb =
new StringBuffer(
toString());
530 for (
int i = 0; i < n; i++) {
534 boolean first =
true;
535 for (
int j = 0; j < d; j++) {
545 return sb.toString();
578 throw new NoSuchElementException(
"Not enough points available");
580 throw new NoSuchElementException(
"Not enough coordinates available");
626 for (
int j = 0; j < d; j++)
721 throw new UnsupportedOperationException();
737 throw new IllegalArgumentException(
"n must be positive.");
738 for (
int i = start; i < start + n; i++)
747 return (i + (
int) (
nextDouble() * (j - i + 1.0)));
756 throw new IllegalArgumentException(
"n must be positive.");
757 for (
int k = start; k < start + n; k++)
This class implements a default point set iterator.
int curPointIndex
Index of the current point.
void nextCoordinates(double p[], int d)
void resetCurPointIndex()
Resets both the current point index and the current coordinate to 0.
void resetNextSubstream()
Same as resetToNextPoint().
void setCurCoordIndex(int j)
Set current coordinate to j.
boolean hasNextCoordinate()
int nextPoint(double p[], int d)
Same as nextPoint(p, 0, d).
int curCoordIndex
Index of the current coordinate.
int resetToNextPoint()
Resets the current point index to the next one and current coordinate to 0, and returns the new curre...
double EpsilonHalf
Default constant epsilon/2 added to the points after a random shift.
void nextArrayOfDouble(double[] u, int start, int n)
Returns in p[start..start+n-1] a block of n successive coordinates of the current point,...
int nextInt(int i, int j)
Similar to nextDouble(), but returns an integer uniformly distributed in [i..j].
void resetStartSubstream()
Same as resetCurCoordIndex().
void nextArrayOfInt(int i, int j, int[] u, int start, int n)
Similar to nextArrayOfDouble but returns in u[start..start+n-1] a block of n integers uniformly distr...
void setCurPointIndex(int i)
Resets the current point index to i and current coordinate to 0.
void setAntithetic(boolean b)
Not implemented here, raises an exception.
int nextPoint(double p[], int fromDim, int d)
Returns in p a block of d successive coordinates of the current point, starting at coordinate fromDim...
void resetCurCoordIndex()
Set current coordinate to 0.
void resetStartStream()
Same as resetCurPointIndex().
void outOfBounds()
Error message for index out of bounds.
double nextDouble()
Same as nextCoordinate().
This abstract class represents a general point set.
static final int MAXBITS
Since Java has no unsigned type, the 32nd bit cannot be used efficiently, so we have only 31 bits.
int dimShift
Current dimension of the shift.
String formatPoints(PointSetIterator iter, int n, int d)
Same as invoking formatPoints(n, d), but prints the points by calling iter repeatedly.
String formatPoints()
Same as invoking formatPoints(n, d) with and equal to the number of points and the dimension of thi...
void addRandomShift()
Same as addRandomShift(0, dim), where dim is the dimension of the point set.
static int getMaxBits()
Returns the maximum number of usable bits.
String formatPointsNumbered(int n, int d)
Same as invoking formatPoints(n,d), except that the points are numbered.
void randomize(PointSetRandomization rand)
Randomizes this point set using the given rand.
String formatPointsBase(int b)
Similar to formatPoints(), but the points coordinates are printed in base .
PointSetIterator iterator()
Constructs and returns a point set iterator.
void addRandomShift(int d1, int d2)
Refreshes the random shift (generates new uniform values for the random shift coordinates) for coordi...
int numPoints
Number of points.
String formatPointsBase(int n, int d, int b)
Similar to formatPoints(n, d), but the points coordinates are printed in base .
int getNumPoints()
Returns the number of points.
double EpsilonHalf
To avoid 0 for nextCoordinate when random shifting, we add this to each coordinate.
double[] shift
This is the shift vector as a double[] array, which contains the current random shift in case we appl...
int capacityShift
Number of array elements in the shift vector, always >= dimShift.
void clearRandomShift()
Erases the current random shift, if any.
abstract double getCoordinate(int i, int j)
Returns , the coordinate of the point .
String formatPoints(PointSetIterator iter)
Same as invoking formatPoints(iter, n, d) with and equal to the number of points and the dimension,...
String formatPointsBase(PointSetIterator iter, int b)
Similar to formatPoints(iter), but the points coordinates are printed in base.
int getDimension()
Returns the dimension (number of available coordinates) of the points.
int dim
Dimension of the points.
String formatPointsNumbered()
Same as invoking formatPointsNumbered(n, d) with and equal to the number of points and the dimensio...
RandomStream shiftStream
Stream used to generate the random shifts.
void addRandomShift(int d1, int d2, RandomStream stream)
By default, this method generates a random shift in the protected double[] array shift,...
String formatPoints(int n, int d)
Formats a string that displays the same information as returned by toString, together with the first ...
String formatPointsBase(PointSetIterator iter, int n, int d, int b)
Similar to formatPoints(iter,n, d), but the points coordinates are printed in base .
void addRandomShift(RandomStream stream)
Same as addRandomShift(0, dim, stream), where dim is the dimension of the point set.
String toString()
Formats a string that contains information about the point set.
This class provides various constants and methods to compute numerical quantities such as factorials,...
static final double TWOEXP[]
Contains the precomputed positive powers of 2.
This is the interface for iterators that permit one to go through the points of a PointSet and the su...
int resetToNextPoint()
Increases the current point index by 1 and returns its new value.
double nextCoordinate()
Returns the current coordinate and advances to the next one.
This interface is for a randomization that can be used to randomize a umontreal.ssj....
void randomize(PointSet p)
This method must randomize p.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...