Skip to content

Commit

Permalink
fix lint and rng nextInt (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 authored Jul 1, 2023
1 parent 6ba7bf3 commit 8392c51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions clustering/pam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ std::vector<int> BUILD::run(const std::vector<int>& ids, int k)
continue;
}
double sum = 0., v;
for (int k=0; k<nn; ++k) {
v = std::min(dist->getDistance(ids[j], ids[k]), mindist[ids[k]]);
for (int m=0; m<nn; ++m) {
v = std::min(dist->getDistance(ids[j], ids[m]), mindist[ids[m]]);
sum += v;
tempd[ ids[k] ] = v;
tempd[ ids[m] ] = v;
}
if(sum < best) {
best = sum;
Expand Down
5 changes: 2 additions & 3 deletions rng.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ class Xoroshiro128Random
}
int nextInt(int n) {
if (n <=0) return 0;
int r = (int)((n & -n) == n ? (nextLong() & n) - 1 // power of two
: (unsigned long long)(((unsigned long long)nextLong() >> 32) * n) >> 32);
return r >= 0 && r < n ? r : 0;
int r = (int)((((unsigned long long)nextLong() >> 32) * n) >> 32);
return r;
}

long long nextLong() {
Expand Down

0 comments on commit 8392c51

Please sign in to comment.