1

我有一个多维点,可能有以下3种类型INT(4)的键,即Short或INT(8)或varchar(512)。克里斯·汉密尔顿的紧凑希尔伯特代码 - 计算紧凑希尔伯特指数

因为这个原因,我不能使用正常的希尔伯特曲线变换。我发现了一个很好的资源来计算紧致hilbert指数。链接在这里。

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

我知道在他的论文的点和动机,但我无法破译的代码。我无法确定要调用哪些函数来计算紧凑希尔伯特指数及其反函数。

+0

所以你问我们代码的工作原理是什么?为什么不联系作者? – Bart 2012-02-13 18:28:46

+1

C++没有“INT(4)”,“INT(8)”或“varchar(512)”类型。这看起来更像Fortran。你确定你正确地标记了这个问题吗? – 2012-02-13 18:36:57

+0

@DietmarKühliirc,这些SQL类型很容易对应于int32_t,int64_t和char [512]或std :: string - 库本身似乎是用C++编写的,所以标记可能是好的。 – kfmfe04 2012-02-14 00:42:39

回答

1

http://code.google.com/p/uzaygezen/是一个开源的Java实现的紧凑的希尔伯特指数。下面是一个与4,8和512字节三维相对应的例子,如问题中指定的:

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); 
0

如果你下载的代码,并期待在头文件,它应该是不言而喻的(顺便说一句,在LIB建立了良好的,我在Ubuntu):

// Description of parameters: 
// 
// FOR REGULAR HILBERT INDICES 
// 
// CFixBitVec/CBigBitVec *p 
// Pointer to array of non-negative coordinate values. 
// 
// int m 
// Precision of all coordinate values (number of bits required to 
// represent the largest possible coordinate value). 
// 
// int n 
// Number of dimensions (size of the array *p). 
// 
// CFixBitVec/CBigBitVec &h 
// Hilbert index of maximum precision m*n. 
// 
// int *ms 
// Array of precision values, one per dimension. 
// 
// FOR COMPACT HILBERT INDICES 
// 
// CFixBitVec/CBigBitVec &hc 
// Compact Hilbert index of maximum precision M. 
// 
// int M 
// Net precision value, corresponding to the size of the compact 
// Hilbert code. If not provided, defaults to zero and will be calculated 
// by the function (sum_i { ms[i] }). 
// 
// int m 
// Largest precision value (max_i { ms[i] }). If not provided, defaults 
// to zero and will be calculated by the function, 


namespace Hilbert 
{ 
    // fix -> fix 
    void coordsToIndex(const CFixBitVec *p, int m, int n, CFixBitVec &h); 
    void indexToCoords(CFixBitVec *p, int m, int n, const CFixBitVec &h); 
    void coordsToCompactIndex(const CFixBitVec *p, const int *ms, int n, 
     CFixBitVec &hc, int M = 0, int m = 0); 
    void compactIndexToCoords(CFixBitVec *p, const int *ms, int n, 
     const CFixBitVec &hc, int M = 0, int m = 0); 

    // fix -> big 
    void coordsToIndex(const CFixBitVec *p, int m, int n, CBigBitVec &h); 
    void indexToCoords(CFixBitVec *p, int m, int n, const CBigBitVec &h); 
    void coordsToCompactIndex(const CFixBitVec *p, const int *ms, int n, 
     CBigBitVec &hc, int M = 0, int m = 0); 
    void compactIndexToCoords(CFixBitVec *p, const int *ms, int n, 
     const CBigBitVec &hc, int M = 0, int m = 0); 

    // big -> big 
    void coordsToIndex(const CBigBitVec *p, int m, int n, CBigBitVec &h); 
    void indexToCoords(CBigBitVec *p, int m, int n, const CBigBitVec &h); 
    void coordsToCompactIndex(const CBigBitVec *p, const int *ms, int n, 
     CBigBitVec &hc, int M = 0, int m = 0); 
    void compactIndexToCoords(CBigBitVec *p, const int *ms, int n, 
     const CBigBitVec &hc, int M = 0, int m = 0); 
}; 
+0

感谢您的提示,如果您在测试主代码中注意到作者创建了4个维度的点,并且它只进行了转换。然而,当试图将这些代码扩展到5维时,它开始给出垃圾回答。试过了吗? – Basmah 2012-02-14 13:58:25

+0

请阅读作者的文档 - 他的实现可能存在局限性:我不知道。 – kfmfe04 2012-02-14 16:00:48

+0

没有作者的文档;这就是为什么我们不知道如何使用它。 – Basmah 2012-02-15 09:18:04