24package umontreal.ssj.util.multidimsort;
98 dimension = batchExponents.length;
116 dimension = batchExponents.length;
118 if (map.dimension() != dimension)
119 throw new IllegalArgumentException(
"HilbertCurveMap has a different dimension! Expecting: " + dimension);
135 if (n == nSavedIndex)
138 indexH =
new long[n][2];
141 int mdim = dimension - 1;
142 int[] ej = bsort.getBitNumbers();
143 int stepj[] =
new int[dimension];
144 int[] icoord =
new int[dimension];
145 for (
int j = 0; j < dimension; ++j) {
147 throw new RuntimeException(
"ej[j] is larger than m");
149 stepj[j] = 1 << (m - ej[j]);
153 for (
int i = 1; i < n; ++i) {
154 icoord[mdim] += stepj[mdim];
155 if (icoord[mdim] == twom) {
156 for (
int j = mdim; j >= 0; --j) {
157 if (icoord[j] < twom)
164 indexH[i][1] = hcMap.coordinatesToIndex(icoord);
176 public void sort(T[] a,
int iMin,
int iMax) {
177 if (iMin + 1 == iMax)
179 if (iMax - iMin != nSavedIndex)
181 bsort.sort(a, iMin, iMax);
184 T[] aclone = a.clone();
188 for (
int i = iMin; i < iMax; ++i) {
189 a[i] = aclone[(int) indexH[i][0]];
197 sort(a, 0, a.length);
200 public void sort(
double[][] a,
int iMin,
int iMax) {
201 if (iMin + 1 == iMax)
203 if (iMax - iMin != nSavedIndex)
205 bsort.
sort(a, iMin, iMax);
208 double[][] aclone = a.clone();
209 for (
int i = iMin; i < iMax; ++i) {
210 a[i] = aclone[(int) indexH[i][0]];
214 public void sort(
double[][] a) {
215 sort(a, 0, a.length);
This is a subclass of BatchSort for which the batch numbers.
void sort(T[] a, int iMin, int iMax)
Sorts the subarray a[iMin..iMax-1] using this batch sort.
void sort(T[] a, int iMin, int iMax)
Sorts the subarray a[iMin..iMax-1] of MultiDimComparable<T> objects with this sort.
void sort(T[] a)
Sorts the entire array.
HilbertCurveBatchSort(double[] batchExponents, int m, HilbertCurveMap map)
This constructor is similar to HilbertCurveBatchSort(double[],int) except that the mapping object is ...
HilbertCurveBatchSort(double[] batchExponents, int m)
Constructs a HilbertCurveBatchSort that will use the.
HilbertCurveMap getHilbertCurveMap()
Returns the HilbertCurveMap used for the mapping.
void computeIndexH(int n)
For the given , ’s, and , computes and sort the table that gives the Hilbert index of each object fr...
int dimension()
Returns the dimension of the unit hypercube.
This class implements the mapping of a Hilbert curve in the.
This class implements a MultiDimSort01<T extends MultiDim01> that can sort an array of points in the ...
static void sortIndexOfLong2(long[][] index, int iMin, int iMax)
Sorts the index table by its second coordinate.
This interface is an extension (or variant) of the Comparable interface in Java.
This interface extends MultiDimSort<T> to implement multivariate sorting algorithms that sort objects...