Skip to content

Commit

Permalink
Another 32bit fix (R1OKM & R2OKM)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neplex committed Sep 15, 2017
1 parent e2ff9ac commit b0dff2b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: COveR
Title: Clustering with Overlaps in R
Version: 0.10.5
Version: 0.10.6
Authors@R: c(
person("Guillaume", "Cleuziou", email = "guillaume.cleuziou@univ-orleans.fr", role = "cre"),
person("Nicolas", "Hiot", email = "nicolas.hiot@etu.univ-orleans.fr", role = "aut"))
Expand Down
2 changes: 1 addition & 1 deletion R/r1okm.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ r1okm <- function(x, centers, alpha = 0, nstart = 10, trace = FALSE, iter.max =
#'
#' @export
print.r1okm <- function(x, ...) {
cat("NEOKM clustering with ", length(x$size), " clusters of sizes ", paste(x$size,
cat("R1OKM clustering with ", length(x$size), " clusters of sizes ", paste(x$size,
collapse = ", "), "\n", sep = "")
cat("\nCluster means:\n")
print(x$centers, ...)
Expand Down
2 changes: 1 addition & 1 deletion R/r2okm.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ r2okm <- function(x, centers, lambda = 0, nstart = 10, trace = FALSE, iter.max =
#'
#' @export
print.r2okm <- function(x, ...) {
cat("NEOKM clustering with ", length(x$size), " clusters of sizes ", paste(x$size,
cat("R2OKM clustering with ", length(x$size), " clusters of sizes ", paste(x$size,
collapse = ", "), "\n", sep = "")
cat("\nCluster means:\n")
print(x$centers, ...)
Expand Down
6 changes: 5 additions & 1 deletion src/r1okm/r1okm.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ void r1_assign(double **elements, double **centers, bool **asso,
dists[k] = vector_square_distance(elements[i], centers[k], nb_dim);
}

unsigned nb_clusters_check = 0;

do {
double min_dist = INFINITY;
unsigned ck = 0; ///< The next closest cluster
end = true;

nb_clusters_check++;

// Search closest cluster, that not associated
for (size_t k = 0; k < nb_clusters; k++) {
if (!new_asso[k]) {
Expand Down Expand Up @@ -111,7 +115,7 @@ void r1_assign(double **elements, double **centers, bool **asso,
end = false; // Not the end
}

} while (!end);
} while (!end && nb_clusters_check<=nb_clusters);

// If the new association is better than previous iteration, choose it
if (new_dist <= withinss[i]) {
Expand Down
6 changes: 5 additions & 1 deletion src/r2okm/r2okm.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ void r2_assign(double **elements, double **centers, bool **asso,
dists[k] = vector_square_distance(elements[i], centers[k], nb_dim);
}

unsigned nb_clusters_check = 0;

do {
double min_dist = INFINITY;
unsigned ck = 0; ///< The next closest cluster
end = true;

nb_clusters_check++;

// Search closest cluster, that not associated
for (size_t k = 0; k < nb_clusters; k++) {
if (!new_asso[k]) {
Expand Down Expand Up @@ -118,7 +122,7 @@ void r2_assign(double **elements, double **centers, bool **asso,
end = false; // Not the end
}

} while (!end);
} while (!end && nb_clusters_check<=nb_clusters);

// If the new association is better than previous iteration, choose it
if (new_dist <= withinss[i]) {
Expand Down

0 comments on commit b0dff2b

Please sign in to comment.