@@ -198,8 +198,16 @@ void fvec_sub(size_t d, const float* a, const float* b, float* c);
198
198
* Compute a subset of distances
199
199
***************************************************************************/
200
200
201
- /* compute the inner product between x and a subset y of ny vectors,
202
- whose indices are given by idy. */
201
+ /* * compute the inner product between x and a subset y of ny vectors defined by
202
+ * ids
203
+ *
204
+ * ip(i, j) = inner_product(x(i, :), y(ids(i, j), :))
205
+ *
206
+ * @param ip output array, size nx * ny
207
+ * @param x first-term vector, size nx * d
208
+ * @param y second-term vector, size (max(ids) + 1) * d
209
+ * @param ids ids to sample from y, size nx * ny
210
+ */
203
211
void fvec_inner_products_by_idx (
204
212
float * ip,
205
213
const float * x,
@@ -209,7 +217,16 @@ void fvec_inner_products_by_idx(
209
217
size_t nx,
210
218
size_t ny);
211
219
212
- /* same but for a subset in y indexed by idsy (ny vectors in total) */
220
+ /* * compute the squared L2 distances between x and a subset y of ny vectors
221
+ * defined by ids
222
+ *
223
+ * dis(i, j) = inner_product(x(i, :), y(ids(i, j), :))
224
+ *
225
+ * @param dis output array, size nx * ny
226
+ * @param x first-term vector, size nx * d
227
+ * @param y second-term vector, size (max(ids) + 1) * d
228
+ * @param ids ids to sample from y, size nx * ny
229
+ */
213
230
void fvec_L2sqr_by_idx (
214
231
float * dis,
215
232
const float * x,
@@ -236,7 +253,14 @@ void pairwise_indexed_L2sqr(
236
253
const int64_t * iy,
237
254
float * dis);
238
255
239
- /* same for inner product */
256
+ /* * compute dis[j] = inner_product(x[ix[j]], y[iy[j]]) forall j=0..n-1
257
+ *
258
+ * @param x size (max(ix) + 1, d)
259
+ * @param y size (max(iy) + 1, d)
260
+ * @param ix size n
261
+ * @param iy size n
262
+ * @param dis size n
263
+ */
240
264
void pairwise_indexed_inner_product (
241
265
size_t d,
242
266
size_t n,
0 commit comments