# HG changeset patch # User mas01mc # Date 1232777760 0 # Node ID 01cb73dfcddd49dfc8f82fc3c259de99a197c33e # Parent a30948382f568fa9a11bda71590871754b5dba89 Removed redundant copy in LSH hashfunction computation when #!defined USE_U_FUNCTIONS. Moved LSH macro definitions into lshlib.h diff -r a30948382f56 -r 01cb73dfcddd lshlib.cpp --- a/lshlib.cpp Fri Jan 23 21:44:32 2009 +0000 +++ b/lshlib.cpp Sat Jan 24 06:16:00 2009 +0000 @@ -1,19 +1,5 @@ #include "lshlib.h" -//#define LSH_DUMP_CORE_TABLES -//#define USE_U_FUNCTIONS - -// Use backward-compatible CORE ARRAY lsh index -#define LSH_CORE_ARRAY // Set to use arrays for hashtables rather than linked-lists -#define LSH_LIST_HEAD_COUNTERS // Enable counters in hashtable list heads - -// Critical path logic -#if defined LSH_CORE_ARRAY && !defined LSH_LIST_HEAD_COUNTERS -#define LSH_LIST_HEAD_COUNTERS -#endif - -#define LSH_CORE_ARRAY_BIT (0x80000000) // LSH_CORE_ARRAY test bit for list head - void err(char*s){cout << s << endl;exit(2);} @@ -162,10 +148,6 @@ H::uu = vector >(H::m); for( Uns32T aa=0 ; aa < H::m ; aa++ ) H::uu[aa] = vector( H::k/2 ); -#else - H::uu = vector >(H::L); - for( Uns32T aa=0 ; aa < H::L ; aa++ ) - H::uu[aa] = vector( H::k ); #endif } @@ -309,8 +291,8 @@ } #else for( aa=0; aa < H::L ; aa++ ){ - ui = H::uu[aa].begin(); - for( kk = 0 ; kk < H::k ; kk++ ){ + pg= *( H::g + aa ); // L \times functions g_j(v) \in Z^k + for( kk = 0 ; kk != H::k ; kk++ ){ pb = *( H::b + aa ) + kk; pA = * ( * ( H::A + aa ) + kk ); dd = H::d; @@ -320,18 +302,9 @@ tmp += *pA++ * *vi++; // project tmp += *pb; // translate tmp *= iw; // scale - *ui++ = (Uns32T) (floor(tmp)); // floor + *pg++ = (Uns32T) (floor(tmp)); // hash function g_j(v)=[x1 x2 ... xk]; xk \in Z } } - // Compute hash functions - for( aa=0 ; aa < H::L ; aa++ ){ - pg= *( H::g + aa ); // L \times functions g_j(v) \in Z^k - // u_1 \in Z^{k \times d} - ui = H::uu[aa].begin(); - kk=H::k; - while( kk-- ) - *pg++ = *ui++; // hash function g_j(v)=[x1 x2 ... xk]; xk \in Z - } #endif } diff -r a30948382f56 -r 01cb73dfcddd lshlib.h --- a/lshlib.h Fri Jan 23 21:44:32 2009 +0000 +++ b/lshlib.h Sat Jan 24 06:16:00 2009 +0000 @@ -93,6 +93,20 @@ #define WRITE_UNS32(VAL, TOKENSTR) if( fwrite(VAL, sizeof(Uns32T), 1, dbFile) != 1 ){\ fclose(dbFile);error("write error in serial_write_format2",TOKENSTR);} +//#define LSH_DUMP_CORE_TABLES // set to dump hashtables on load +//#define USE_U_FUNCTIONS // set to use partial hashfunction re-use + +// Backward-compatible CORE ARRAY lsh index +#define LSH_CORE_ARRAY // Set to use arrays for hashtables rather than linked-lists +#define LSH_LIST_HEAD_COUNTERS // Enable counters in hashtable list heads + +// Critical path logic +#if defined LSH_CORE_ARRAY && !defined LSH_LIST_HEAD_COUNTERS +#define LSH_LIST_HEAD_COUNTERS +#endif + +#define LSH_CORE_ARRAY_BIT (0x80000000) // LSH_CORE_ARRAY test bit for list head + using namespace std; Uns32T get_page_logn(); @@ -206,8 +220,9 @@ bucket*** h; // The LSH hash tables bool use_u_functions; // flag to optimize computation of hashes +#ifdef USE_U_FUNCTIONS vector > uu; // Storage for m patial hash evaluations ( g_j = [u_a,u_b] ) - +#endif Uns32T maxp; // highest pointID stored in database Uns32T bucketCount; // count of number of point buckets allocated Uns32T pointCount; // count of number of points inserted