27 static char rcsid[] =
"$Header: /l/spencer/src/urt/lib/RCS/hilbert.c,v 3.0.1.1 1992/04/30 14:07:11 spencer Exp $";
73 for ( b = 0; b < n; b++ )
74 bit[b] = 1 << (n - b - 1);
77 for ( i = 0; i < two_n; i++ )
78 for ( b = 0; b < n; b++ )
82 for ( i = 0; i < two_n; i++ )
83 for ( b = 0; b < n; b++ )
85 ((i << (n - b)) & (two_n - 1));
89 for ( i = 1, b = 1; i < two_n; i++ )
100 for ( i = 0; i < two_n; i++ )
105 for ( b = 1; b < n; b++ )
112 for ( b = 0; b < n; b++ )
142 byte rho[9], rh, J, sigma, tau,
143 sigmaT, tauT, tauT1 = 0, omega, omega1 = 0, alpha[9];
151 for ( i = m - 1; i >= 0; i-- )
153 rho[i] = r & ((1 << n) - 1);
159 for ( i = 0; i < m; i++ )
196 omega = omega1 ^ tauT1;
201 alpha[i] = omega ^ sigmaT;
205 for ( b = 0; b < n; b++ )
215 case 9:
if ( alpha[8] & bt) ab |= 0x01;
216 case 8:
if ( alpha[7] & bt) ab |= 0x02;
217 case 7:
if ( alpha[6] & bt) ab |= 0x04;
218 case 6:
if ( alpha[5] & bt) ab |= 0x08;
219 case 5:
if ( alpha[4] & bt) ab |= 0x10;
220 case 4:
if ( alpha[3] & bt) ab |= 0x20;
221 case 3:
if ( alpha[2] & bt) ab |= 0x40;
222 case 2:
if ( alpha[1] & bt) ab |= 0x80;
223 case 1:
if ( alpha[0] & bt) ab |= 0x100;
225 a[b] = ab >> (9 - m);
251 byte rho[9], J, sigma, tau,
252 sigmaT, tauT, tauT1 = 0, omega, omega1 = 0, alpha[9];
262 case 9: alpha[8] = 0;
263 case 8: alpha[7] = 0;
264 case 7: alpha[6] = 0;
265 case 6: alpha[5] = 0;
266 case 5: alpha[4] = 0;
267 case 4: alpha[3] = 0;
268 case 3: alpha[2] = 0;
269 case 2: alpha[1] = 0;
270 case 1: alpha[0] = 0;
277 for ( b = 0; b < n; b++ )
279 register int bt =
bit[b], t = a[b] << (9 - m);
283 case 9:
if ( t & 0x01 ) alpha[8] |= bt;
284 case 8:
if ( t & 0x02 ) alpha[7] |= bt;
285 case 7:
if ( t & 0x04 ) alpha[6] |= bt;
286 case 6:
if ( t & 0x08 ) alpha[5] |= bt;
287 case 5:
if ( t & 0x10 ) alpha[4] |= bt;
288 case 4:
if ( t & 0x20 ) alpha[3] |= bt;
289 case 3:
if ( t & 0x40 ) alpha[2] |= bt;
290 case 2:
if ( t & 0x80 ) alpha[1] |= bt;
291 case 1:
if ( t & 0x100 ) alpha[0] |= bt;
296 for ( i = 0; i < m; i++ )
302 omega = omega1 ^ tauT1;
304 sigmaT = alpha[i] ^ omega;
340 for ( i = 0; i < m; i++ )
341 rl = (rl << n) | rho[i];
356 printf(
"Enter n, m: " );
361 while ( (i = getchar()) !=
'\n' && i != EOF )
365 for ( r = 0; r < 1 << (n*m); r++ )
367 hilbert_i2c( n, m, r, a );
371 for ( i = 0; i < n; i++ )
372 printf(
"0x%0*x ", (m+3)/4, a[i] );
374 hilbert_c2i( n, m, a, &r1 );
376 printf(
"r = 0x%0*x\n", (n*m+3)/4, r1 );
378 printf(
"r = 0x%0*x; r1 = 0x%0*x\n", (n*m+3)/4, r,
390 for ( i = 0; i < n; i++ )
391 printf(
"%02x ", tbl[i] );
401 for ( i = 0; i < n; i++ )
403 printf(
"%3d: ", i );
static byte circshift[512][9]
void hilbert_i2c(int n, int m, long int r, a)
void hilbert_c2i(int n, int m, a, long int *r)
static byte bitof[512][9]
static void calctables(int n)