// Compute the value of a hash function u=lshFunctions[gNumber] (a // vector of <hfTuplesLength> LSH functions) in the point <point>. The // result is stored in the vector <vectorValue>. <vectorValue> must be // already allocated (and have space for <hfTuplesLength> Uns32T-words). inline void computeULSH(PRNearNeighborStructT nnStruct, IntT gNumber, RealT *point, Uns32T *vectorValue){ CR_ASSERT(nnStruct != NULL); CR_ASSERT(point != NULL); CR_ASSERT(vectorValue != NULL); for(IntT i = 0; i < nnStruct->hfTuplesLength; i++){ RealT value = 0; for(IntT d = 0; d < nnStruct->dimension; d++){ value += point[d] * nnStruct->lshFunctions[gNumber][i].a[d]; } vectorValue[i] = (Uns32T)(FLOOR_INT32((value + nnStruct->lshFunctions[gNumber][i].b) / nnStruct->parameterW) /* - MIN_INT32T*/); } }
// Compute the value of a hash function u=lshFunctions[gNumber] (a // vector of <hfTuplesLength> LSH functions) in the point <point>. The // result is stored in the vector <vectorValue>. <vectorValue> must be // already allocated (and have space for <hfTuplesLength> Uns32T-words). inline void computeULSH(PRNearNeighborStructT nnStruct, IntT gNumber, RealT *point, Uns32T *vectorValue) { //求出point向量和多个hansh映射后的值, 对于每个hash: a。v+b 除以 r //结果返回到vectorValue 向量上 CR_ASSERT(nnStruct != NULL); CR_ASSERT(point != NULL); CR_ASSERT(vectorValue != NULL); // FILE *file=fopen("vector.txt","a+"); // fprintf(file,"\n\n"); for(IntT i = 0; i < nnStruct->hfTuplesLength; i++) { RealT value = 0; for(IntT d = 0; d < nnStruct->dimension; d++) { value += point[d] * nnStruct->lshFunctions[gNumber][i].a[d]; //两个向量point[]。第gnumber的hash向量 点乘 ; 就是a。v } value=value*97;//放大10倍看看 double tempv=( (value + nnStruct->lshFunctions[gNumber][i].b) ); double temp_w=tempv/ nnStruct->parameterW ; int vi=temp_w; if ( vi < 0) { vi+=1793; } vectorValue[i] = (Uns32T)(FLOOR_INT32( (value + nnStruct->lshFunctions[gNumber][i].b) / nnStruct->parameterW )) ; vectorValue[i] =vi; // fprintf(file,"%lf %lf %d ||",value,temp_w ,vi ); // vectorValue[i] = (Uns32T)(FLOOR_INT32( (value + nnStruct->lshFunctions[gNumber][i].b) / nnStruct->parameterW) /* - MIN_INT32T*/); //a。v+b 除以 r } // fclose(file); }