k: = hc2ind (Z)
k: = hc2ind (X,Y)

Converts Hilbert curve to linear matrix indices.

[x,y] = hilbert_curve (2);
hc2ind (x, y);
ans =
  1
  2
  4
  3

Demonstration 1

The following code

 M      = idxmatrix (4)
 [x, y] = hilbert_curve (4);
 ind    = hc2ind (x, y);
 M(ind)

Produces the following output

M =

   11   12   13   14
   21   22   23   24
   31   32   33   34
   41   42   43   44

ans =

   11
   12
   22
   21
   31
   41
   42
   32
   33
   43
   44
   34
   24
   23
   13
   14

Package: miscellaneous