c++multidimensional-arrayindiceshilbert-curvelinearization

Compact Hilbert Code by Chris Hamilton - to calculate Compact Hilbert Indices


I have a multidimensional points which may have keys of the following 3 types INT(4) i.e. Short , or INT(8) or varchar(512).

For this reason I can't use normal Hilbert curve transformation. I found a very good resource to calculate compact hilbert indices. Here is the link.

http://web.cs.dal.ca/~chamilto/hilbert/index.html

I understand the points and motivation in his paper but I am unable to decipher the code. I can't figure out which functions to call to calculate Compact Hilbert Indices and the inverse of it.


Solution

  • http://code.google.com/p/uzaygezen/ is an open source Java implementation of the Compact Hilbert Index. Here's an example corresponding to 3 dimensions with 4, 8 and 512 bytes, as specified in the question:

    CompactHilbertCurve chc = new CompactHilbertCurve(new int[] {4 * 8, 8 * 8, 512 * 8});
    List<Integer> bitsPerDimension = chc.getSpec().getBitsPerDimension();
    BitVector[] p = new BitVector[bitsPerDimension.size()];
    for (int i = p.length; --i >= 0; ) {
        p[i] = BitVectorFactories.OPTIMAL.apply(bitsPerDimension.get(i));
    }
    p[0].copyFrom(123);
    p[1].copyFrom(32342);
    p[2].copyFrom(BitSet.valueOf("test".getBytes("ISO-8859-1")));
    BitVector chi = BitVectorFactories.OPTIMAL.apply(chc.getSpec().sumBitsPerDimension());
    chc.index(p, 0, chi);
    System.out.println(chi);