Skip to content

Commit 18b5439

Browse files
committed
* c/sort.h (cmp_pdouble_asc_rev): dim is the last valid component instead of the length of the vectors.
(cmp_ppdouble_asc_rev_3d, cmp_ppdouble_asc_rev_4d): Update. * c/nondominated_kung.h (cmp_shifted_row_asc_rev_3d): Update.
1 parent 109d7a2 commit 18b5439

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

c/nondominated_kung.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ DEFINE_QSORT_CMP(cmp_shifted_row_asc_x_nonzero_stable, shifted_row_t *)
360360
DEFINE_QSORT_CMP(cmp_shifted_row_asc_rev_3d, shifted_row_t *)
361361
{
362362
ASSUME(a != b);
363-
return cmp_pdouble_asc_rev(a->row, b->row, 3);
363+
return cmp_pdouble_asc_rev(a->row, b->row, 2);
364364
}
365365

366366
static shifted_row_t *

c/sort.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,18 @@ cmp_double_asc(double a, double b)
112112
return (a > b) - (a < b);
113113
}
114114

115+
/**
116+
Compare vectors starting from the last component, where dim is the last
117+
valid component.
118+
*/
115119
static inline int
116120
cmp_pdouble_asc_rev(const double * restrict a, const double * restrict b, dimension_t dim)
117121
{
118-
ASSUME(dim >= 2);
119-
int i = dim - 1;
120-
int res = cmp_double_asc(a[i], b[i]);
121-
while (!res && i > 0) {
122-
i--;
123-
res = cmp_double_asc(a[i], b[i]);
122+
ASSUME(dim >= 1);
123+
int res = cmp_double_asc(a[dim], b[dim]);
124+
while (!res && dim > 0) {
125+
dim--;
126+
res = cmp_double_asc(a[dim], b[dim]);
124127
}
125128
return res;
126129
}
@@ -141,12 +144,12 @@ DEFINE_QSORT_CMP(cmp_ppdouble_asc_rev_2d, double **)
141144
// Lexicographic order of coordinates (z,y,x)
142145
DEFINE_QSORT_CMP(cmp_ppdouble_asc_rev_3d, double **)
143146
{
144-
return cmp_pdouble_asc_rev(*a, *b, 3);
147+
return cmp_pdouble_asc_rev(*a, *b, 2);
145148
}
146149

147150
DEFINE_QSORT_CMP(cmp_ppdouble_asc_rev_4d, double **)
148151
{
149-
return cmp_pdouble_asc_rev(*a, *b, 4);
152+
return cmp_pdouble_asc_rev(*a, *b, 3);
150153
}
151154

152155
static inline int

0 commit comments

Comments
 (0)