Skip to content

Commit

Permalink
fixed 240 -> -16 and got rid of dependence on NSGDist.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Nov 13, 2024
1 parent 0386719 commit 00c3c04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions algorithms/utils/euclidian_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "parlay/internal/file_map.h"

#include "types.h"
#include "NSGDist.h"
//#include "NSGDist.h"
// #include "common/time_loop.h"

#include <fcntl.h>
Expand Down Expand Up @@ -81,8 +81,12 @@ float euclidian_distance(const int8_t *p, const int8_t *q, unsigned d) {
}

float euclidian_distance(const float *p, const float *q, unsigned d) {
efanna2e::DistanceL2 distfunc;
return distfunc.compare(p, q, d);
//efanna2e::DistanceL2 distfunc;
//return distfunc.compare(p, q, d);
float result = 0.0;
for (int i = 0; i < d; i++)
result += (q[i] - p[i]) * (q[i] - p[i]);
return (float)result;
}

template<typename T_, long range=(1l << sizeof(T_)*8) - 1>
Expand Down
2 changes: 1 addition & 1 deletion algorithms/utils/mips_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ struct Quantized_Mips_Point{
int8_t* p = (int8_t*) p_;
int8_t* q = (int8_t*) q_;
int32_t result = 0;
int8_t mask = 240;
int8_t mask = -16; // bit representation is 11110000, used as mask to extract high 4 bits
for (int i = 0; i < params.dims/2; i++) {
result += (int16_t) ((int8_t) (p[i] << 4)) * (int16_t) ((int8_t) (q[i] << 4));
}
Expand Down

0 comments on commit 00c3c04

Please sign in to comment.