@@ -258,9 +258,19 @@ generate_row_pointers_asc_rev_3d(const double * restrict points, size_t size)
258258 return p ;
259259}
260260
261- static inline size_t
262- find_nondominated_2d_helper_ (const double * restrict points , size_t size ,
263- const bool keep_weakly , boolvec * restrict nondom )
261+ /**
262+ Store which points are nondominated in nondom and return the number of
263+ nondominated points.
264+
265+ 2D dimension-sweep algorithm by H. T. Kung, F. Luccio, and F. P. Preparata.
266+ On Finding the Maxima of a Set of Vectors. Journal of the ACM,
267+ 22(4):469–476, 1975.
268+
269+ Duplicated points may be removed in any order due to qsort not being stable.
270+ */
271+ static __force_inline__ size_t
272+ find_nondominated_2d_impl (const double * restrict points , size_t size ,
273+ const bool keep_weakly , boolvec * restrict nondom )
264274{
265275 ASSUME (size > 1 );
266276 const double * * p = generate_row_pointers_asc_rev_2d (points , size );
@@ -280,7 +290,7 @@ find_nondominated_2d_helper_(const double * restrict points, size_t size,
280290 SWAP (pj , pk );
281291
282292 size_t pos_first_dom = row_index_from_ptr (points , pj , 2 );
283- if (unlikely ( nondom == NULL ) ) {
293+ if (nondom == NULL ) {
284294 // In this context, it means "position of the first dominated solution found".
285295 n_nondom = pos_first_dom ;
286296 goto early_end ;
@@ -305,29 +315,19 @@ static inline size_t
305315find_dominated_2d_ (const double * restrict points , size_t size , const bool keep_weakly )
306316{
307317 return keep_weakly
308- ? find_nondominated_2d_helper_ (points , size , true, /*nondom=*/ NULL )
309- : find_nondominated_2d_helper_ (points , size , false, /*nondom=*/ NULL );
318+ ? find_nondominated_2d_impl (points , size , true, /*nondom=*/ NULL )
319+ : find_nondominated_2d_impl (points , size , false, /*nondom=*/ NULL );
310320}
311321
312322
313- /**
314- Store which points are nondominated in nondom and return the number of
315- nondominated points.
316-
317- 2D dimension-sweep algorithm by H. T. Kung, F. Luccio, and F. P. Preparata.
318- On Finding the Maxima of a Set of Vectors. Journal of the ACM,
319- 22(4):469–476, 1975.
320-
321- Duplicated points may be removed in any order due to qsort not being stable.
322- */
323323static inline size_t
324324find_nondominated_set_2d_ (const double * restrict points , size_t size ,
325325 const bool keep_weakly , boolvec * restrict nondom )
326326{
327327 ASSUME (nondom != NULL );
328328 return keep_weakly
329- ? find_nondominated_2d_helper_ (points , size , true, nondom )
330- : find_nondominated_2d_helper_ (points , size , false, nondom );
329+ ? find_nondominated_2d_impl (points , size , true, nondom )
330+ : find_nondominated_2d_impl (points , size , false, nondom );
331331}
332332
333333/**
@@ -665,17 +665,17 @@ find_nondominated_set_(const double * restrict points, size_t size, dimension_t
665665 if (dim <= 3 || size > KUNG_SMALL_THRESHOLD ) {
666666 const double * pp = force_agree_minimize (points , size , & dim , agree , minmax );
667667 ASSUME (dim >= 2 );
668- size_t res ;
668+ size_t new_size ;
669669 if (dim == 2 ) {
670- res = find_nondominated_set_2d_ (pp , size , keep_weakly , nondom );
670+ new_size = find_nondominated_set_2d_ (pp , size , keep_weakly , nondom );
671671 } else if (dim == 3 ) {
672- res = find_nondominated_set_3d_ (pp , size , keep_weakly , nondom );
672+ new_size = find_nondominated_set_3d_ (pp , size , keep_weakly , nondom );
673673 } else {
674- res = find_nondominated_set_agree_kung (pp , size , dim , keep_weakly , nondom );
674+ new_size = find_nondominated_set_agree_kung (pp , size , dim , keep_weakly , nondom );
675675 }
676676 if (pp != points )
677677 free ((void * ) pp );
678- return res ;
678+ return new_size ;
679679 }
680680
681681 /* FIXME: Do not handle agree here, assume that objectives have been fixed
0 commit comments