Skip to content

Commit 109d7a2

Browse files
committed
* c/nondominated.h (find_nondominated_3d_impl): Delete and inline in callers.
(find_dominated_3d_): Rename as find_dominated_3d_impl. (find_nondominated_set_3d_): Rename as find_nondominated_set_3d_impl. * hv3d_priv.h: Update comment. * pareto.c: Update comment.
1 parent 12189f3 commit 109d7a2

3 files changed

Lines changed: 16 additions & 24 deletions

File tree

c/hv3d_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ new_avl_node(dlnode_t * restrict p, avl_node_t * restrict node)
3737
3838
The main difference is that the order of the points in 2D is tracked by p->cnext/p->closest.
3939
40-
See also find_nondominated_set_3d_helper().
40+
See also find_nondominated_set_3d_impl().
4141
*/
4242
static inline void
4343
hv3d_preprocessing(dlnode_t * restrict list, size_t n)

c/nondominated.h

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -451,24 +451,14 @@ find_nondominated_3d_impl_sorted(const double ** rows, size_t size,
451451
return new_size;
452452
}
453453

454-
static __force_inline__ size_t
455-
find_nondominated_3d_impl(const double ** restrict rows, size_t size,
456-
const bool keep_weakly,
457-
const bool find_dominated)
458-
{
459-
// Sort in ascending lexicographic order from the last dimension.
460-
qsort_typesafe(rows, size, cmp_ppdouble_asc_rev_3d);
461-
// Help GCC generate all possible specializations of this function.
462-
return keep_weakly
463-
? find_nondominated_3d_impl_sorted(rows, size, true, find_dominated)
464-
: find_nondominated_3d_impl_sorted(rows, size, false, find_dominated);
465-
}
466-
467454
static inline size_t
468-
find_dominated_3d_(const double * restrict points, size_t size, bool keep_weakly)
455+
find_dominated_3d_impl(const double * restrict points, size_t size, bool keep_weakly)
469456
{
470-
const double ** rows = generate_row_pointers(points, size, 3);
471-
size_t pos = find_nondominated_3d_impl(rows, size, keep_weakly, /* find_dominated=*/true);
457+
// Sort in ascending lexicographic order from the last dimension.
458+
const double ** rows = generate_row_pointers_asc_rev_3d(points, size);
459+
size_t pos = keep_weakly
460+
? find_nondominated_3d_impl_sorted(rows, size, true, /* find_dominated=*/true)
461+
: find_nondominated_3d_impl_sorted(rows, size, false, /* find_dominated=*/true);
472462
if (pos < size)
473463
pos = row_index_from_ptr(points, rows[pos], 3);
474464
free(rows);
@@ -480,12 +470,14 @@ find_dominated_3d_(const double * restrict points, size_t size, bool keep_weakly
480470
nondominated points.
481471
*/
482472
static inline size_t
483-
find_nondominated_set_3d_(const double * restrict points, size_t size,
484-
const bool keep_weakly, boolvec * restrict nondom)
473+
find_nondominated_set_3d_impl(const double * restrict points, size_t size,
474+
const bool keep_weakly, boolvec * restrict nondom)
485475
{
486476
ASSUME(nondom != NULL);
487-
const double ** rows = generate_row_pointers(points, size, 3);
488-
size_t new_size = find_nondominated_3d_impl(rows, size, keep_weakly, /* find_dominated=*/false);
477+
const double ** rows = generate_row_pointers_asc_rev_3d(points, size);
478+
size_t new_size = keep_weakly
479+
? find_nondominated_3d_impl_sorted(rows, size, true, /* find_dominated=*/false)
480+
: find_nondominated_3d_impl_sorted(rows, size, false, /* find_dominated=*/false);
489481

490482
if (new_size < size) {
491483
memset(nondom, false, size * sizeof(*nondom));
@@ -652,7 +644,7 @@ find_dominated_point_(const double * restrict points, size_t size, dimension_t d
652644
if (dim == 2) {
653645
res = find_dominated_2d_(pp, size, keep_weakly);
654646
} else {
655-
res = find_dominated_3d_(pp, size, keep_weakly);
647+
res = find_dominated_3d_impl(pp, size, keep_weakly);
656648
}
657649
if (pp != points)
658650
free((void *) pp);
@@ -696,7 +688,7 @@ find_nondominated_set_(const double * restrict points, size_t size, dimension_t
696688
if (dim == 2) {
697689
new_size = find_nondominated_set_2d_(pp, size, keep_weakly, nondom);
698690
} else if (dim == 3) {
699-
new_size = find_nondominated_set_3d_(pp, size, keep_weakly, nondom);
691+
new_size = find_nondominated_set_3d_impl(pp, size, keep_weakly, nondom);
700692
} else {
701693
new_size = find_nondominated_set_kung(pp, size, dim, keep_weakly, nondom);
702694
}

c/pareto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
Nondominated sorting in 3D in O(k * n log n), where k is the number of fronts.
99
10-
Uses the same algorithm as find_nondominated_set_3d_helper().
10+
Uses the same algorithm as find_nondominated_set_3d_impl().
1111
*/
1212

1313
static void

0 commit comments

Comments
 (0)