63 double rand_double ();
69 void float_rand (
float * x,
size_t n,
long seed);
70 void float_randn (
float * x,
size_t n,
long seed);
71 void long_rand (
long * x,
size_t n,
long seed);
72 void byte_rand (uint8_t * x,
size_t n,
long seed);
75 void rand_perm (
int * perm,
size_t n,
long seed);
91 float fvec_inner_product (
114 long nq,
const float *xq,
115 long nb,
const float *xb,
117 long ldq = -1,
long ldb = -1,
long ldd = -1);
121 void fvec_inner_products_ny (
125 size_t d,
size_t ny);
129 float * __restrict dis,
132 size_t d,
size_t ny);
144 void fvec_norms_L2 (
float * ip,
const float * x,
size_t d,
size_t nx);
147 void fvec_norms_L2sqr (
float * ip,
const float * x,
size_t d,
size_t nx);
150 void fvec_renorm_L2 (
size_t d,
size_t nx,
float * x);
156 void inner_product_to_L2sqr (
float * __restrict dis,
159 size_t n1,
size_t n2);
167 void fvec_inner_products_by_idx (
168 float * __restrict ip,
171 const long * __restrict ids,
172 size_t d,
size_t nx,
size_t ny);
175 void fvec_L2sqr_by_idx (
176 float * __restrict dis,
179 const long * __restrict ids,
180 size_t d,
size_t nx,
size_t ny);
187 extern int distance_compute_blas_threshold;
199 size_t d,
size_t nx,
size_t ny,
206 size_t d,
size_t nx,
size_t ny,
217 size_t d,
size_t nx,
size_t ny,
219 const float *base_shift);
224 void knn_inner_products_by_idx (
228 size_t d,
size_t nx,
size_t ny,
231 void knn_L2sqr_by_idx (
const float * x,
233 const long * __restrict ids,
234 size_t d,
size_t nx,
size_t ny,
257 size_t d,
size_t nx,
size_t ny,
265 size_t d,
size_t nx,
size_t ny,
285 void fvec_madd (
size_t n,
const float *a,
286 float bf,
const float *b,
float *c);
293 float bf,
const float *b,
float *c);
297 void reflection (
const float * u,
float * x,
size_t n,
size_t d,
size_t nu);
312 size_t d,
size_t k,
size_t n,
327 size_t k2,
const long *v2);
339 const long *I1,
const float *D1,
340 bool keep_min =
true,
341 long translation = 0);
345 void fvec_argsort (
size_t n,
const float *vals,
348 void fvec_argsort_parallel (
size_t n,
const float *vals,
353 int ivec_hist (
size_t n,
const int * v,
int vmax,
int *hist);
360 void bincode_hist(
size_t n,
size_t nbits,
const uint8_t *codes,
int *hist);
377 size_t d,
size_t *n,
size_t nmax,
const float *x,
378 bool verbose =
false,
long seed = 1234);
399 uint64_t
hash_bytes (
const uint8_t *bytes,
long n);
random generator that can be used in multithreaded contexts
int km_update_centroids(const float *x, float *centroids, long *assign, size_t d, size_t k, size_t n, size_t k_frozen)
void knn_L2sqr_base_shift(const float *x, const float *y, size_t d, size_t nx, size_t ny, float_maxheap_array_t *res, const float *base_shift)
float fvec_L2sqr(const float *x, const float *y, size_t d)
Squared L2 distance between two vectors.
void bincode_hist(size_t n, size_t nbits, const uint8_t *codes, int *hist)
const float * fvecs_maybe_subsample(size_t d, size_t *n, size_t nmax, const float *x, bool verbose, long seed)
void ranklist_handle_ties(int k, long *idx, const float *dis)
float rand_float()
between 0 and 1
void fvec_madd(size_t n, const float *a, float bf, const float *b, float *c)
size_t get_mem_usage_kb()
get current RSS usage in kB
int ivec_hist(size_t n, const int *v, int vmax, int *hist)
compute histogram on v
long rand_long()
random long
uint64_t hash_bytes(const uint8_t *bytes, long n)
size_t merge_result_table_with(size_t n, size_t k, long *I0, float *D0, const long *I1, const float *D1, bool keep_min, long translation)
int rand_int()
random positive integer
size_t ranklist_intersection_size(size_t k1, const long *v1, size_t k2, const long *v2_in)
void pairwise_L2sqr(long d, long nq, const float *xq, long nb, const float *xb, float *dis, long ldq, long ldb, long ldd)
void range_search_inner_product(const float *x, const float *y, size_t d, size_t nx, size_t ny, float radius, RangeSearchResult *res)
same as range_search_L2sqr for the inner product similarity
void knn_inner_product(const float *x, const float *y, size_t d, size_t nx, size_t ny, float_minheap_array_t *res)
double getmillisecs()
ms elapsed since some arbitrary epoch
void real_to_binary(size_t d, const float *x_in, uint8_t *x_out)
double imbalance_factor(int k, const int *hist)
same, takes a histogram as input
float fvec_norm_L2sqr(const float *x, size_t d)
void range_search_L2sqr(const float *x, const float *y, size_t d, size_t nx, size_t ny, float radius, RangeSearchResult *res)
void matrix_qr(int m, int n, float *a)
size_t ivec_checksum(size_t n, const int *a)
compute a checksum on a table.
int fvec_madd_and_argmin(size_t n, const float *a, float bf, const float *b, float *c)
void knn_L2sqr(const float *x, const float *y, size_t d, size_t nx, size_t ny, float_maxheap_array_t *res)
void binary_to_real(size_t d, const uint8_t *x_in, float *x_out)