use of zemberek.core.collections.IntVector in project zemberek-nlp by ahmetaa.
the class ProductQuantizer method kmeans.
void kmeans(FArray x, FArray c, int n, int d) {
int[] values = new int[n];
IntVector perm = new IntVector(values);
for (int i = 0; i < n; i++) {
perm.safeSet(i, i);
}
perm.shuffle(rng);
for (int i = 0; i < ksub_; i++) {
// x -> src
x.arrayCopy(// src pos
perm.get(i) * d, // destination
c, // destination pos
i * d, // amount of data
d);
}
BArray codes = new BArray(new byte[n]);
for (int i = 0; i < niter_; i++) {
Estep(x, c, codes, d, n);
MStep(x, c, codes, d, n);
}
}
Aggregations