@@ -134,7 +134,8 @@ hvc_1point_diffs_nondom(double * restrict hvc, double * restrict points,
134134#undef swap_points
135135}
136136
137- /* O(n log n) dimension-sweep algorithm.
137+ /**
138+ O(n log n) dimension-sweep algorithm.
138139
139140 hvc[] must be already allocated with size n. Points that are duplicated
140141 have zero exclusive contribution. Thus, the sum of contributions may
@@ -147,34 +148,35 @@ hvc2d(double * restrict hvc, const double * restrict data, size_t n,
147148 const double * restrict ref )
148149{
149150 ASSUME (n > 0 );
150- const double * * p = generate_sorted_doublep_2d_filter_by_ref (data , & n , ref [0 ]);
151+ const double * * p = generate_sorted_doublep_2d_filter_by_ref (data , & n , ref [0 ]);
151152 if (unlikely (n == 0 )) return 0 ;
152153 if (unlikely (!p )) return -1 ;
153154
154155 size_t j = 0 ;
155156 // Find first point below the reference point.
156- while (j < n && p [j ][1 ] >= ref [1 ])
157+ while (p [j ][1 ] >= ref [1 ]) {
157158 j ++ ;
158- if (unlikely (j == n )) {
159- free (p );
160- return 0 ;
159+ if (unlikely (j == n )) {
160+ free (p );
161+ return 0 ;
162+ }
161163 }
162- double height = ref [1 ] - p [j ][1 ];
163- double hyperv = (ref [0 ] - p [j ][0 ]) * height ;
164164 const double * prev = p [j ];
165+ double height = ref [1 ] - prev [1 ];
166+ double hyperv = (ref [0 ] - prev [0 ]) * height ;
165167 j ++ ;
166168 while (j < n ) {
167- DEBUG2_PRINT ("[%lld ]=(%g, %g) -> [%lld ]=(%g,%g) (height=%g)\n" ,
168- (long long )(prev - data ) / 2 , prev [0 ], prev [1 ],
169- (long long )(p [j ] - data ) / 2 , p [j ][0 ], p [j ][1 ], height );
169+ DEBUG2_PRINT ("[%zu ]=(%g, %g) -> [%zu ]=(%g,%g) (height=%g)\n" ,
170+ (( size_t )(prev - data ) ) / 2 , prev [0 ], prev [1 ],
171+ (( size_t )(p [j ] - data ) ) / 2 , p [j ][0 ], p [j ][1 ], height );
170172 // likely() because most points will be non-dominated.
171173 if (likely (prev [1 ] > p [j ][1 ])) {
172174 assert (prev [0 ] < p [j ][0 ]);
173175 /* Compute the contribution of prev. We have to accumulate because
174176 we may have computed partial contributions. */
175177 hvc [(prev - data ) / 2 ] += (p [j ][0 ] - prev [0 ]) * height ;
176- DEBUG2_PRINT ("hvc[%lld ] += %g * %g = %g\n" ,
177- (long long ) (prev - data ) / 2 ,
178+ DEBUG2_PRINT ("hvc[%zu ] += %g * %g = %g\n" ,
179+ (( size_t ) (prev - data ) ) / 2 ,
178180 p [j ][0 ] - prev [0 ], height ,
179181 (p [j ][0 ] - prev [0 ]) * height );
180182 height = prev [1 ] - p [j ][1 ];
@@ -183,20 +185,20 @@ hvc2d(double * restrict hvc, const double * restrict data, size_t n,
183185 prev = p [j ];
184186 j ++ ;
185187 } else if (prev [0 ] < p [j ][0 ]) {
186- // prev[1] <= p[j][1], thus pj contributes partially to hvc[prev].
188+ // prev[1] <= p[j][1], thus p[j] contributes partially to hvc[prev].
187189 double new_h = p [j ][1 ] - prev [1 ];
188190 if (new_h < height ) {
189191 hvc [(prev - data ) / 2 ] += (p [j ][0 ] - prev [0 ]) * (height - new_h );
190- DEBUG2_PRINT ("hvc[%lld ] += %g * %g = %g\n" ,
191- (long long ) (prev - data ) / 2 ,
192+ DEBUG2_PRINT ("hvc[%zu ] += %g * %g = %g\n" ,
193+ (( size_t ) (prev - data ) ) / 2 ,
192194 p [j ][0 ] - prev [0 ], height - new_h ,
193195 (p [j ][0 ] - prev [0 ]) * (height - new_h ));
194196 height = new_h ;
195197 }
196198 j ++ ;
197199 } else if (prev [1 ] == p [j ][1 ]) { // && prev[0] == p[j][0]
198200 // Duplicates contribute zero.
199- DEBUG2_PRINT ("hvc[%lld ] = %g\n" , (long long )(prev - data ) / 2 ,
201+ DEBUG2_PRINT ("hvc[%zu ] = %g\n" , (( size_t )(prev - data ) ) / 2 ,
200202 hvc [(prev - data ) / 2 ]);
201203 assert (hvc [(prev - data ) / 2 ] == 0 );
202204 /* We set height=0 here so that we set hvc[prev] = 0 when we find the
@@ -221,7 +223,7 @@ hvc2d(double * restrict hvc, const double * restrict data, size_t n,
221223 }
222224
223225 hvc [(prev - data ) / 2 ] += (ref [0 ] - prev [0 ]) * height ;
224- DEBUG2_PRINT ("hvc[%lld ] = %g * %g = %g\n" , (long long )(prev - data ) / 2 ,
226+ DEBUG2_PRINT ("hvc[%zu ] = %g * %g = %g\n" , (( size_t )(prev - data ) ) / 2 ,
225227 ref [0 ] - prev [0 ], height , (ref [0 ] - prev [0 ]) * height );
226228 free (p );
227229 return hyperv ;
@@ -232,33 +234,34 @@ hvc2d_nondom(double * restrict hvc, const double * restrict data, size_t n,
232234 const double * restrict ref )
233235{
234236 ASSUME (n > 0 );
235- const double * * p = generate_sorted_doublep_2d_filter_by_ref (data , & n , ref [0 ]);
237+ const double * * p = generate_sorted_doublep_2d_filter_by_ref (data , & n , ref [0 ]);
236238 if (unlikely (n == 0 )) return 0 ;
237239 if (unlikely (!p )) return -1 ;
238240
239241 size_t j = 0 ;
240242 // Find first point below the reference point.
241- while (j < n && p [j ][1 ] >= ref [1 ])
243+ while (p [j ][1 ] >= ref [1 ]) {
242244 j ++ ;
243- if (unlikely (j == n )) {
244- free (p );
245- return 0 ;
245+ if (unlikely (j == n )) {
246+ free (p );
247+ return 0 ;
248+ }
246249 }
247- double height = ref [1 ] - p [j ][1 ];
248- double hyperv = (ref [0 ] - p [j ][0 ]) * height ;
249250 const double * prev = p [j ];
251+ double height = ref [1 ] - prev [1 ];
252+ double hyperv = (ref [0 ] - prev [0 ]) * height ;
250253 j ++ ;
251254 while (j < n ) {
252- DEBUG2_PRINT ("[%lld ]=(%g, %g) -> [%lld ]=(%g,%g) (height=%g)\n" ,
253- (long long )(prev - data ) / 2 , prev [0 ], prev [1 ],
254- (long long )(p [j ] - data ) / 2 , p [j ][0 ], p [j ][1 ], height );
255+ DEBUG2_PRINT ("[%zu ]=(%g, %g) -> [%zu ]=(%g,%g) (height=%g)\n" ,
256+ (( size_t )(prev - data ) ) / 2 , prev [0 ], prev [1 ],
257+ (( size_t )(p [j ] - data ) ) / 2 , p [j ][0 ], p [j ][1 ], height );
255258 // likely() because most points will be non-dominated.
256259 if (likely (prev [1 ] > p [j ][1 ])) {
257260 assert (prev [0 ] < p [j ][0 ]);
258- /* Compute the contribution of prev. */
261+ // Compute the contribution of prev.
259262 hvc [(prev - data ) / 2 ] = (p [j ][0 ] - prev [0 ]) * height ;
260- DEBUG2_PRINT ("hvc[%lld ] = %g * %g = %g\n" ,
261- (long long ) (prev - data ) / 2 ,
263+ DEBUG2_PRINT ("hvc[%zu ] = %g * %g = %g\n" ,
264+ (( size_t ) (prev - data ) ) / 2 ,
262265 p [j ][0 ] - prev [0 ], height ,
263266 (p [j ][0 ] - prev [0 ]) * height );
264267 height = prev [1 ] - p [j ][1 ];
@@ -269,16 +272,16 @@ hvc2d_nondom(double * restrict hvc, const double * restrict data, size_t n,
269272 } else if (prev [0 ] == p [j ][0 ]) { // && prev[1] <= p[j][1]
270273 if (prev [1 ] == p [j ][1 ]) {
271274 // Duplicates contribute zero.
272- DEBUG2_PRINT ("hvc[%lld ] = %g\n" , (long long )(prev - data ) / 2 ,
275+ DEBUG2_PRINT ("hvc[%zu ] = %g\n" , (( size_t )(prev - data ) ) / 2 ,
273276 hvc [(prev - data ) / 2 ]);
274277 assert (hvc [(prev - data ) / 2 ] == 0 );
275- /* We set this here so that we set hvc[prev] = 0 when we find the next
276- non-duplicate. */
278+ /* We set this here so that we set hvc[prev] = 0 when we find
279+ the next non-duplicate. */
277280 height = 0 ;
278281 prev = p [j ];
279282 }
280- /* All points with same 0-coordinate are weakly dominated by
281- prev, so they can be ignored. */
283+ /* All points with same 0-coordinate are weakly dominated by prev,
284+ so they can be ignored. */
282285 do {
283286 j ++ ;
284287 } while (j < n && prev [0 ] == p [j ][0 ]);
@@ -291,7 +294,7 @@ hvc2d_nondom(double * restrict hvc, const double * restrict data, size_t n,
291294 }
292295
293296 hvc [(prev - data ) / 2 ] = (ref [0 ] - prev [0 ]) * height ;
294- DEBUG2_PRINT ("hvc[%lld ] = %g * %g = %g\n" , (long long )(prev - data ) / 2 ,
297+ DEBUG2_PRINT ("hvc[%zu ] = %g * %g = %g\n" , (( size_t )(prev - data ) ) / 2 ,
295298 ref [0 ] - prev [0 ], height , (ref [0 ] - prev [0 ]) * height );
296299 free (p );
297300 return hyperv ;
0 commit comments