docs: public static long[] coordinatesToHilbert(long[] coords, int bitsperdim, int offset) {
      final int numdim = coords.length;
      final int numbits = numdim * bitsperdim;
      final long[] output = BitsUtil.zero(numbits);
  
      int rotation = 0;
      long[] refl = BitsUtil.zero(numdim);
      for(int i = 0; i < bitsperdim; i++) {
        final long[] hist = interleaveBits(coords, i + offset);
        // System.err.println(BitsUtil.toString(hist,
        // numdim)+" rot:"+rotation+" refl: "+BitsUtil.toString(refl, numdim));
        final long[] bits = BitsUtil.copy(hist);
        BitsUtil.xorI(bits, refl);
        BitsUtil.cycleRightI(bits, rotation, numdim);
        final int nextrot = (rotation + BitsUtil.numberOfTrailingZerosSigned(bits) + 2) % numdim;
        BitsUtil.invgrayI(bits);
        BitsUtil.orI(output, bits, numbits - (i + 1) * numdim);
        // System.err.println(BitsUtil.toString(output,
        // numbits)+" bits: "+BitsUtil.toString(bits, numdim));
        refl = hist;
        BitsUtil.flipI(refl, rotation);
        if(!BitsUtil.get(bits, 0)) {
          BitsUtil.flipI(refl, (nextrot - 1 + numdim) % numdim);
        }
        rotation = nextrot;
      }
  
      return output;
    }