Skip to content

Commit

Permalink
BUG: fix compilation on solaris with gcc.
Browse files Browse the repository at this point in the history
CS is a reserved keyword on Solaris - thanks to John Hunter.
  • Loading branch information
cournape committed Sep 26, 2009
1 parent ca02f87 commit 6250277
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions scipy/cluster/src/hierarchy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ void inconsistency_calculation_alt(const double *Z, double *R, int n, int d) {
free(rvisited);
}

void calculate_cluster_sizes(const double *Z, double *CS, int n) {
void calculate_cluster_sizes(const double *Z, double *cs, int n) {
int i, j, k, q;
const double *row;
for (k = 0; k < n - 1; k++) {
Expand All @@ -1079,22 +1079,22 @@ void calculate_cluster_sizes(const double *Z, double *CS, int n) {
/** If the left node is a non-singleton, add its count. */
if (i >= n) {
q = i - n;
CS[k] += CS[q];
cs[k] += cs[q];
}
/** Otherwise just add 1 for the leaf. */
else {
CS[k] += 1.0;
cs[k] += 1.0;
}
/** If the right node is a non-singleton, add its count. */
if (j >= n) {
q = j - n;
CS[k] += CS[q];
cs[k] += cs[q];
}
/** Otherwise just add 1 for the leaf. */
else {
CS[k] += 1.0;
cs[k] += 1.0;
}
CPY_DEBUG_MSG("i=%d, j=%d, CS[%d]=%d\n", i, j, k, (int)CS[k]);
CPY_DEBUG_MSG("i=%d, j=%d, cs[%d]=%d\n", i, j, k, (int)cs[k]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion scipy/cluster/src/hierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void linkage_alt(double *dm, double *Z, double *X, int m, int n, int ml, int kc,

void cophenetic_distances(const double *Z, double *d, int n);
void cpy_to_tree(const double *Z, cnode **tnodes, int n);
void calculate_cluster_sizes(const double *Z, double *CS, int n);
void calculate_cluster_sizes(const double *Z, double *cs, int n);

void form_member_list(const double *Z, int *members, int n);
void form_flat_clusters_from_in(const double *Z, const double *R, int *T,
Expand Down
6 changes: 3 additions & 3 deletions scipy/cluster/src/hierarchy_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ extern PyObject *linkage_euclid_wrap(PyObject *self, PyObject *args) {

extern PyObject *calculate_cluster_sizes_wrap(PyObject *self, PyObject *args) {
int n;
PyArrayObject *Z, *CS_;
PyArrayObject *Z, *cs_;
if (!PyArg_ParseTuple(args, "O!O!i",
&PyArray_Type, &Z,
&PyArray_Type, &CS_,
&PyArray_Type, &cs_,
&n)) {
return 0;
}
calculate_cluster_sizes((const double*)Z->data, (double*)CS_->data, n);
calculate_cluster_sizes((const double*)Z->data, (double*)cs_->data, n);
return Py_BuildValue("");
}

Expand Down

0 comments on commit 6250277

Please sign in to comment.