34package umontreal.ssj.util.multidimsort;
36import java.util.Comparator;
37import java.util.Arrays;
122 long[][] indexForSort;
150 this.dimension = map.dimension();
159 double b[][] =
new double[iMax][dimension];
160 for (
int i = iMin; i < iMax; ++i)
161 b[i] = a[i].getPoint();
169 for (
int i = iMin; i < iMax; ++i)
170 a[i] = aclone[(
int) indexForSort[i][0]];
177 sort(a, 0, a.length);
183 public void sort(
double[][] a,
int iMin,
int iMax) {
184 if (iMin + 1 == iMax)
186 indexForSort =
new long[iMax][2];
187 int[] icoord =
new int[dimension];
188 for (
int i = 0; i < a.length; ++i) {
190 hcMap.pointToCoordinates(a[i], icoord);
191 indexForSort[i][0] = i;
192 indexForSort[i][1] = hcMap.coordinatesToIndex(icoord);
197 double[][] aclone = a.clone();
198 for (
int i = iMin; i < iMax; ++i) {
199 a[i] = aclone[(int) indexForSort[i][0]];
203 public void sort(
double[][] a) {
204 sort(a, 0, a.length);
238 public int compare(
long[] p1,
long[] p2) {
241 else if (p1[1] < p2[1])
This class implements the mapping of a Hilbert curve in the.
The comparator class used by sortIndexOfLong2.
HilbertCurveSort(int d, int m)
Constructs a HilbertCurveSort object that will use the first.
void sort(MultiDim01[] a)
Sorts the entire array: same as sort (a, 0, a.length).
static void sortIndexOfLong2(long[][] index, int iMin, int iMax)
Sorts the index table by its second coordinate.
long[][] getIndexAfterSort()
Returns the index computed by the last sort, which is sorted by the second coordinate.
HilbertCurveMap getHilbertCurveMap()
Returns the HilbertCurveMap used for the mapping.
void sort(double[][] a, int iMin, int iMax)
Sort the array with Hilbert sort.
int dimension()
Returns the dimension of the unit hypercube.
HilbertCurveSort(HilbertCurveMap map)
Constructs a HilbertCurveSort object with a given mapping of the Hilbert curve in the unit hypercube.
void sort(MultiDim01[] a, int iMin, int iMax)
Sorts the subarray a[iMin..iMax-1] with this Hilbert curve sort.
This interface represents a point or array of dimensions in a unit hypercube .
This interface extends MultiDimSort<T> to implement multivariate sorting algorithms that sort points ...