首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Chris Hamilton的紧致希尔伯特码--计算紧致希尔伯特指数

Chris Hamilton的紧致希尔伯特码--计算紧致希尔伯特指数
EN

Stack Overflow用户
提问于 2012-02-14 02:13:02
回答 3查看 3.4K关注 0票数 1

我有一个多维点,它可能有以下3种类型的键,即INT(4),或INT(8)或varchar(512)。

由于这个原因,我不能使用普通的希尔伯特曲线变换。我找到了一个非常好的资源来计算紧凑的希尔伯特指数。这是链接。

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

我理解他论文中的观点和动机,但我无法破译其中的代码。我想不出应该调用哪个函数来计算紧凑的希尔伯特指数以及它的逆函数。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-04-03 20:23:33

http://code.google.com/p/uzaygezen/是紧凑型希尔伯特索引的开源Java实现。下面是一个4、8和512字节的3个维度的示例,如问题中所述:

代码语言:javascript
复制
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);
票数 1
EN

Stack Overflow用户

发布于 2012-02-14 08:35:58

如果你下载代码并查看头文件,它应该是不言而喻的(顺便说一句,在Ubuntu上为我构建的lib很好):

代码语言:javascript
复制
// 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
EN

Stack Overflow用户

发布于 2012-03-29 20:12:40

http://code.google.com/p/uzaygezen/是Compact Hilbert Index的开源Java实现,计算Compact hilbert index所需的API相当简单。下面是一个4、8和512字节的3个维度的示例,如问题中所述:

代码语言:javascript
复制
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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9265658

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档