inline void preparePointAdding(PRNearNeighborStructT nnStruct, PUHashStructureT uhash, PPointT point){ ASSERT(nnStruct != NULL); ASSERT(uhash != NULL); ASSERT(point != NULL); //TIMEV_START(timeComputeULSH); for(IntT d = 0; d < nnStruct->dimension; d++){ nnStruct->reducedPoint[d] = point->coordinates[d] / nnStruct->parameterR; } // Compute all ULSH functions. for(IntT i = 0; i < nnStruct->nHFTuples; i++){ computeULSH(nnStruct, i, nnStruct->reducedPoint, nnStruct->pointULSHVectors[i]); } //printIntVector("pointULSHVectors", 10, (int *) nnStruct->pointULSHVectors[0]); // Compute data for <precomputedHashesOfULSHs>. if (USE_SAME_UHASH_FUNCTIONS) { for(IntT i = 0; i < nnStruct->nHFTuples; i++){ //if (i == 0) printIntVector("masterHash", 10, (int*) uhash->mainHashA); precomputeUHFsForULSH(uhash, nnStruct->pointULSHVectors[i], nnStruct->hfTuplesLength, nnStruct->precomputedHashesOfULSHs[i]); } } //TIMEV_END(timeComputeULSH); }
inline void preparePointAdding(PRNearNeighborStructT nnStruct, PUHashStructureT uhash, PPointT point) { //输入: nnntstuct结构体(降维的向量), uhash(hash的两个主副向量) 特征点 //操作:先计算点的降维结果,然后计算两个hash索引值 保存到nnStruct->precomputedHashesOfULSHs //功能,提前计算好每个点的hash表索引值 //根据传入的多维point。 //计算对应每个hash表的降维=》hash值, //存入了nnStruct->precomputedHashesOfULSHs ASSERT(nnStruct != NULL); ASSERT(uhash != NULL); ASSERT(point != NULL); TIMEV_START(timeComputeULSH); for(IntT d = 0; d < nnStruct->dimension; d++) { nnStruct->reducedPoint[d] = point->coordinates[d] / nnStruct->parameterR; } //降维 // Compute all ULSH functions. for(IntT i = 0; i < nnStruct->nHFTuples; i++) { //nHFTuples是元组个数, //求出nnStruct->reducedPoint向量和多个hansh映射后的值, 对于每个hash: a。v+b 除以 r //结果返回到pointULSHVectors【】 向量上 //pointULSHVectors【i】就是 第一步降维后的向量值 computeULSH(nnStruct, i, nnStruct->reducedPoint, nnStruct->pointULSHVectors[i]); } //模hash // Compute data for <precomputedHashesOfULSHs>. if (USE_SAME_UHASH_FUNCTIONS) { for(IntT i = 0; i < nnStruct->nHFTuples; i++) { precomputeUHFsForULSH(uhash, nnStruct->pointULSHVectors[i], nnStruct->hfTuplesLength, nnStruct->precomputedHashesOfULSHs[i]); //根据降维后的结果向量:pointULSHVectors【i】 计算两个hash值,存入precomputedHashesOfULSHs【i】 } } TIMEV_END(timeComputeULSH); }