Skip to content

Commit

Permalink
fix permutations extension for compatibility with windows
Browse files Browse the repository at this point in the history
  • Loading branch information
abelcarreras committed Oct 27, 2022
1 parent e65c813 commit f1e6613
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions c/permutations.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

// Support functions
int evaluationFast(int i, int j, double* row1, double* row2);
double evaluationFast(int i, int j, double* row1, double* row2);
void exchangeRows(int i, int j, double* matrix, int n, int m);
void exchangePos(int i, int j, int* vector);
void inversePerm(int* vector, int n);
Expand Down Expand Up @@ -141,7 +141,7 @@ static PyObject* getCrossDistanceTable(PyObject* self, PyObject *arg, PyObject *
return(PyArray_Return(diffCoor_obj));
}

int evaluationFast(int i, int j, double* row1, double* row2)
double evaluationFast(int i, int j, double* row1, double* row2)
{
double off_diagonal = pow(row1[j] - row2[i], 2);
return pow(row1[i], 2) + pow(row2[j], 2) + off_diagonal;
Expand All @@ -168,14 +168,16 @@ void exchangePos(int i, int j, int* vector)

void inversePerm(int* vector, int n)
{
int vectorTemp[n];

int * vectorTemp = (int*) malloc(n * sizeof(int));

int k;
for (int i=0; i<n; i++){
k = vector[i];
vectorTemp[k] = i;
}
for (int i=0; i<n; i++) vector[i] = vectorTemp[i];
free(vectorTemp);

}

Expand Down

0 comments on commit f1e6613

Please sign in to comment.