34package umontreal.ssj.util.multidimsort;
113 p_to_s =
new int[maxlength];
114 s_to_p =
new int[maxlength];
115 p_to_J =
new int[maxlength];
116 parity =
new int[maxlength];
117 bit =
new int[maxnbits];
118 circshift =
new int[maxlength][maxnbits];
119 bitof =
new int[maxlength][maxnbits];
130 for (b = 0; b < n; b++)
131 bit[b] = (
int) (1 << (n - b - 1));
134 for (i = 0; i < two_n; i++)
135 for (b = 0; b < n; b++)
136 bitof[i][b] = (
int) ((i & bit[b]) != 0 ? 1 : 0);
139 for (i = 0; i < two_n; i++)
140 for (b = 0; b < n; b++)
141 circshift[i][b] = (
int) ((i >> (b)) | ((i << (n - b)) & (two_n - 1)));
145 for (i = 1, b = 1; i < two_n; i++) {
152 parity[i] = (int) (1 - parity[i - b]);
156 for (i = 0; i < two_n; i++) {
159 for (b = 1; b < n; b++)
160 if ((bitof[i][b] ^ bitof[i][b - 1]) != 0)
165 p_to_J[i] = (int) (n - 1);
166 for (b = 0; b < n; b++)
167 if (bitof[i][b] != bitof[i][n - 1])
187 maxlength = 1 << dimension;
237 int[] rho =
new int[9];
238 int rh, J, sigma, tau;
241 int omega, omega1 = 0;
242 int[] alpha =
new int[9];
248 for (i = m - 1; i >= 0; i--) {
249 rho[i] = (int) (r & ((1 << n) - 1));
255 for (i = 0; i < m; i++) {
267 tau = (int) (sigma ^ 1);
268 if (parity[tau] != 0)
274 sigmaT = circshift[sigma][Jsum];
275 tauT = circshift[tau][Jsum];
289 omega = (int) (omega1 ^ tauT1);
294 alpha[i] = (int) (omega ^ sigmaT);
298 for (b = 0; b < n; b++) {
309 if ((alpha[8] & bt) != 0)
312 if ((alpha[7] & bt) != 0)
315 if ((alpha[6] & bt) != 0)
318 if ((alpha[5] & bt) != 0)
321 if ((alpha[4] & bt) != 0)
324 if ((alpha[3] & bt) != 0)
327 if ((alpha[2] & bt) != 0)
330 if ((alpha[1] & bt) != 0)
333 if ((alpha[0] & bt) != 0)
336 a[b] = ab >> (9 - m);
354 int[] rho =
new int[maxnbits];
355 int[] alpha =
new int[maxnbits];
356 int J, sigma, tau, sigmaT, tauT, tauT1 = 0, omega, omega1 = 0;
366 for (i = m; i > 0; --i) {
369 for (b = 0; b < n; b++) {
372 for (i = 1; i <= m; ++i) {
373 if ((t >> (m - i)) != 0) {
375 t = t - (1 << (m - i));
381 for (i = 0; i < m; i++) {
386 omega = (int) (omega1 ^ tauT1);
388 sigmaT = (int) (alpha[i] ^ omega);
391 sigma = circshift[sigmaT][n - Jsum];
395 rho[i] = s_to_p[sigma];
405 tau = (int) (sigma ^ 1);
406 if (parity[tau] != 0)
411 tauT = circshift[tau][Jsum];
425 for (i = 0; i < m; i++)
426 rl = (rl << n) | rho[i];
436 for (
int j = 0; j < dimension; ++j)
437 a[j] = (
int) (p[j] * (1 << m));
int getM()
Returns the number of bits that is used to divide the axis of each coordinate.
long coordinatesToIndex(int a[])
Takes as input in a[] the integer coordinates of a subcube and returns the corresponding Hilbert inde...
HilbertCurveMap(int d, int m)
Constructs a HilbertCurveMap object that will use the first.
HilbertCurveMap(int d)
This constructor is similar to HilbertCurveMap(int,int), but the parameter .
int dimension()
Returns the dimension of the unit hypercube.
void pointToCoordinates(double[] p, int[] a)
Takes in p[] a point with real-valued coordinates and places in a[] the integer coordinates of the co...
void indexToCoordinates(long r, int[] a)
Takes as input the Hilbert index of a subcube and returns in a[] its integer coordinates.