Skip to content

Commit

Permalink
Memory leak fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Neplex committed Dec 6, 2017
1 parent 43af319 commit 06300df
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 11 deletions.
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: COveR
Title: Clustering with Overlaps
Version: 1.0.0
Version: 1.0.3
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 All @@ -17,5 +17,3 @@ LazyData: true
RoxygenNote: 6.0.1
Suggests: testthat
SystemRequirements: Gnu Scientific Library version >= 1.12


1 change: 0 additions & 1 deletion R/r1okm.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ r1okm <- function(x, centers, alpha = 0, nstart = 10, trace = FALSE, iter.max =
centers <- as.matrix(data.matrix(centers))
nc <- nrow(centers)
c <- as.numeric(as.vector(centers))
print(c)
if (ncol(centers) != ncol(x))
stop("x and centers must have the same number of dimensions")

Expand Down
1 change: 0 additions & 1 deletion R/r2okm.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ r2okm <- function(x, centers, lambda = 0, nstart = 10, trace = FALSE, iter.max =
centers <- as.matrix(data.matrix(centers))
nc <- nrow(centers)
c <- as.numeric(as.vector(centers))
print(c)
if (ncol(centers) != ncol(x))
stop("x and centers must have the same number of dimensions")

Expand Down
4 changes: 3 additions & 1 deletion src/icmeans/icmeans.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ double ic_getBetweenss(Interval **centers, unsigned nb_clusters,
for (size_t k = 0; k < nb_clusters; k++) {

// Get the mean element of other centers
Interval mean[nb_interval];
Interval* mean = new_array_Interval(nb_interval);
for (size_t j = 0; j < nb_interval; j++) {
mean[j].min = 0;
mean[j].max = 0;
Expand All @@ -115,6 +115,8 @@ double ic_getBetweenss(Interval **centers, unsigned nb_clusters,
res += haus_distance(centers[k], mean, nb_interval);
break;
}

delete_array(&mean);
}

return res;
Expand Down
4 changes: 3 additions & 1 deletion src/ikmeans/ikmeans.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ double ik_getBetweenss(Interval **centers, unsigned nb_clusters,
for (size_t k = 0; k < nb_clusters; k++) {

// Get the mean element of other centers
Interval mean[nb_interval];
Interval* mean = new_array_Interval(nb_interval);
for (size_t j = 0; j < nb_interval; j++) {
mean[j].min = 0;
mean[j].max = 0;
Expand All @@ -97,6 +97,8 @@ double ik_getBetweenss(Interval **centers, unsigned nb_clusters,
res += haus_distance(centers[k], mean, nb_interval);
break;
}

delete_array(&mean);
}

return res;
Expand Down
4 changes: 3 additions & 1 deletion src/ineokm/ineokm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ double ineo_betweenss(Interval **centers, unsigned nb_clusters,
for (size_t k = 0; k < nb_clusters; k++) {

// Get the mean element of other centers
Interval mean[nb_interval];
Interval* mean = new_array_Interval(nb_interval);
for (size_t j = 0; j < nb_interval; j++) {
mean[j].min = 0;
mean[j].max = 0;
Expand All @@ -32,6 +32,8 @@ double ineo_betweenss(Interval **centers, unsigned nb_clusters,

// Sum distance
res += square_distance(centers[k], mean, nb_interval);

delete_array(&mean);
}

return res;
Expand Down
4 changes: 3 additions & 1 deletion src/neokm/neokm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ double neo_betweenss(double **centers, unsigned nb_clusters, unsigned nb_dim) {
for (size_t k = 0; k < nb_clusters; k++) {

// Get the mean element of other clusters center
double mean[nb_dim];
double* mean = new_array_double(nb_dim);
for (size_t j = 0; j < nb_dim; j++) {
for (size_t i = 0; i < nb_clusters; i++) {
if (i != k) {
Expand All @@ -25,6 +25,8 @@ double neo_betweenss(double **centers, unsigned nb_clusters, unsigned nb_dim) {

// Sum distance
res += vector_square_distance(centers[k], mean, nb_dim);

delete_array(&mean);
}

return res;
Expand Down
4 changes: 3 additions & 1 deletion src/r1okm/r1okm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ double r1_betweenss(double **centers, unsigned nb_clusters, unsigned nb_dim) {
for (size_t k = 0; k < nb_clusters; k++) {

// Get the mean element of other clusters center
double mean[nb_dim];
double* mean = new_array_double(nb_dim);
for (size_t j = 0; j < nb_dim; j++) {
for (size_t i = 0; i < nb_clusters; i++) {
if (i != k) {
Expand All @@ -25,6 +25,8 @@ double r1_betweenss(double **centers, unsigned nb_clusters, unsigned nb_dim) {

// Sum distance
res += vector_square_distance(centers[k], mean, nb_dim);

delete_array(&mean);
}

return res;
Expand Down
4 changes: 3 additions & 1 deletion src/r2okm/r2okm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ double r2_betweenss(double **centers, unsigned nb_clusters, unsigned nb_dim) {
for (size_t k = 0; k < nb_clusters; k++) {

// Get the mean element of other clusters center
double mean[nb_dim];
double* mean = new_array_double(nb_dim);
for (size_t j = 0; j < nb_dim; j++) {
for (size_t i = 0; i < nb_clusters; i++) {
if (i != k) {
Expand All @@ -25,6 +25,8 @@ double r2_betweenss(double **centers, unsigned nb_clusters, unsigned nb_dim) {

// Sum distance
res += vector_square_distance(centers[k], mean, nb_dim);

delete_array(&mean);
}

return res;
Expand Down

0 comments on commit 06300df

Please sign in to comment.