1

J'ai des points multidimensionnels qui peuvent avoir des clés des 3 types suivants INT (4), c'est-à-dire court, ou INT (8) ou varchar (512).Code compact Hilbert par Chris Hamilton - pour calculer les indices compacts de Hilbert

Pour cette raison, je ne peux pas utiliser la transformation de courbe de Hilbert normale. J'ai trouvé une très bonne ressource pour calculer des indices hilbert compacts. Voici le lien.

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

Je comprends les points et la motivation dans son papier, mais je suis incapable de déchiffrer le code. Je ne peux pas deviner quelles fonctions appeler pour calculer les indices Hilbert compacts et l'inverse.

+0

Alors vous nous demandez comment fonctionne le code? Pourquoi ne pas contacter l'auteur? – Bart

+1

C++ n'a pas les types 'INT (4)', 'INT (8)' ou 'varchar (512)'. Cela ressemble plus à Fortran. Etes-vous sûr de bien avoir tagué cette question? –

+0

@ DietmarKühl iirc, ce sont des types SQL qui correspondent facilement à int32_t, int64_t, et char [512] ou std :: string - la bibliothèque elle-même semble être écrite en C++ donc le balisage est probablement ok. – kfmfe04

Répondre

1

http://code.google.com/p/uzaygezen/ est une implémentation Java open source du Indice de Hilbert compact. Voici un exemple correspondant à 3 dimensions avec 4, 8 et 512 octets, comme spécifié dans la 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); 
0

Si vous téléchargez le code et regardez le fichier d'en-tête, il doit être explicite (BTW, la lib construit bien pour moi sur 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

Merci pour l'invite aimable, si vous avez remarqué dans le code principal de test l'auteur crée un point de 4 dimensions et il fait la transformation juste Ok. Cependant, en essayant de mettre à l'échelle ce code jusqu'à 5 dimensions, il commence à donner des réponses erronées. J'ai essayé ça? – Basmah

+0

S'il vous plaît lire la documentation de l'auteur - peut-être il y a des limites dans sa mise en œuvre: je n'en ai aucune idée. – kfmfe04

+0

Il n'y a pas de documentation d'auteur; C'est pourquoi nous n'avons aucune idée de comment l'utiliser. – Basmah

Questions connexes