25package umontreal.ssj.hups;
27import umontreal.ssj.rng.RandomStream;
28import umontreal.ssj.util.PrintfFormat;
59 protected int i_from, i_to, i_index[];
60 protected int j_from, j_to, j_index[];
88 if (0 > from || from >= to || to > P.getNumPoints())
89 throw new IllegalArgumentException(
"Invalid range for points");
106 throw new IllegalArgumentException(
"Number of indices too large");
107 i_index = pointIndices;
121 if (0 > from || from >= to || to > P.getDimension())
122 throw new IllegalArgumentException(
"Invalid column range");
138 if (numCoord > P.getDimension() || numCoord > coordIndices.length)
139 throw new IllegalArgumentException(
"Number of indices too large");
141 j_index = coordIndices;
146 int access_i, access_j;
150 if (i_index ==
null) {
152 throw new IllegalArgumentException(
"Row out of range");
154 access_i = i + i_from;
156 access_i = i_index[i];
158 if (j_index ==
null) {
159 if (j < 0 || j >
dim)
160 throw new IllegalArgumentException(
"Column out of range");
162 access_j = j + j_from;
164 access_j = j_index[j];
166 return P.getCoordinate(access_i, access_j);
170 return new SubsetIterator();
176 sb.append(P.toString());
182 sb.append(
"Point indices: [");
183 boolean first =
true;
189 sb.append(i_index[i]);
195 sb.append(
"Coordinates range from " + j_from +
" to " + j_to +
".");
197 sb.append(
"Coordinate indices: [");
198 boolean first =
true;
199 for (
int i = 0; i <
dim; i++) {
204 sb.append(j_index[i]);
209 return sb.toString();
214 private class SubsetIterator
extends DefaultPointSetIterator {
249 if (i_index ==
null) {
257 if (j_index ==
null) {
266 public void setCurCoordIndex(
int j) {
270 innerIterator.setCurCoordIndex(j_index[j]);
275 if (j_index ==
null) {
277 innerIterator.resetCurCoordIndex();
279 innerIterator.setCurCoordIndex(j_from);
282 innerIterator.resetCurCoordIndex();
284 innerIterator.setCurCoordIndex(j_index[0]);
297 coord = innerIterator.nextCoordinate();
301 coord = innerIterator.nextCoordinate();
302 if (futureIndex != (currentIndex + 1))
303 innerIterator.setCurCoordIndex(futureIndex);
309 public void nextCoordinates(
double[] p,
int d) {
312 if (j_index !=
null) {
313 super.nextCoordinates(p, d);
316 innerIterator.nextCoordinates(p, d);
320 public void setCurPointIndex(
int i) {
322 innerIterator.setCurPointIndex(i + i_from);
324 innerIterator.setCurPointIndex(i_index[i]);
330 if (i_index ==
null) {
332 innerIterator.resetCurPointIndex();
334 innerIterator.setCurPointIndex(i_from);
337 innerIterator.resetCurPointIndex();
339 innerIterator.setCurPointIndex(i_index[0]);
347 innerIterator.resetToNextPoint();
int curPointIndex
Index of the current point.
void resetCurPointIndex()
Resets both the current point index and the current coordinate to 0.
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...
void resetCurCoordIndex()
Set current coordinate to 0.
void outOfBounds()
Error message for index out of bounds.
This abstract class represents a general point set.
PointSetIterator iterator()
Constructs and returns a point set iterator.
int numPoints
Number of points.
int getNumPoints()
Returns the number of points.
int getDimension()
Returns the dimension (number of available coordinates) of the points.
int dim
Dimension of the points.
SubsetOfPointSet(PointSet p)
Constructs a new PointSet object, initially identical to p, and from which a subset of the points and...
String toString()
Formats a string that contains information about the point set.
double getCoordinate(int i, int j)
Returns , the coordinate of the point .
void selectPointsRange(int from, int to)
Selects the points numbered from "<tt>from</tt>" to "<tt>to -1</tt>" from the original point set.
void selectCoordinatesRange(int from, int to)
Selects the coordinates from "<tt>from</tt>" to "<tt>to - 1</tt>" from the original point set.
PointSetIterator iterator()
Constructs and returns a point set iterator.
void selectPoints(int[] pointIndices, int numPoints)
Selects the numPoints points whose numbers are provided in the array pointIndices.
void selectCoordinates(int[] coordIndices, int numCoord)
Selects the numCoord coordinates whose numbers are provided in the array coordIndices.
This is the interface for iterators that permit one to go through the points of a PointSet and the su...
void setCurPointIndex(int i)
Resets the current point index to and the current coordinate index to zero.
void setCurCoordIndex(int j)
Sets the current coordinate index to , so that the next calls to nextCoordinate or nextCoordinates wi...