5858#include "nondominated.h" // minmax_from_bool
5959
6060static inline double
61- gd_common ( int dim , const signed char * restrict minmax ,
62- const double * restrict points_a , int size_a ,
63- const double * restrict points_r , int size_r ,
64- bool plus , bool psize , uint_fast8_t p )
61+ gd_common ( dimension_t dim , const signed char * restrict minmax ,
62+ const double * restrict points_a , size_t size_a ,
63+ const double * restrict points_r , size_t size_r ,
64+ bool plus , bool psize , uint_fast8_t p )
6565{
6666 if (size_a == 0 ) return INFINITY ;
6767 ASSUME (size_a > 0 );
6868 ASSUME (size_r > 0 );
6969 ASSUME (dim >= 2 );
70- ASSUME (dim <= 32 );
7170
7271 double gd = 0 ;
73- for (int a = 0 ; a < size_a ; a ++ ) {
72+ for (size_t a = 0 ; a < size_a ; a ++ ) {
7473 double min_dist = INFINITY ;
75- for (int r = 0 ; r < size_r ; r ++ ) {
74+ for (size_t r = 0 ; r < size_r ; r ++ ) {
7675 double dist = 0.0 ;
77- for (int d = 0 ; d < dim ; d ++ ) {
76+ for (dimension_t d = 0 ; d < dim ; d ++ ) {
7877 if (minmax [d ] == 0 ) continue ;
7978 double a_d = points_a [a * dim + d ];
8079 double r_d = points_r [r * dim + d ];
@@ -84,9 +83,8 @@ gd_common (int dim, const signed char * restrict minmax,
8483 // TODO: Implement taxicab and infinity norms
8584 dist += diff * diff ;
8685 }
87- // We should calculate here the sqrt() of the Euclidean, however
88- // that would not change which one is the minimum, so we compute it
89- // outside the loop, which is faster.
86+ // We calculate the sqrt() of the Euclidean outside the loop, which
87+ // is faster and does not change the minimum.
9088 if (dist < min_dist ) min_dist = dist ;
9189 }
9290 // Here we calculate the actual Euclidean distance.
@@ -108,114 +106,112 @@ gd_common (int dim, const signed char * restrict minmax,
108106}
109107
110108static inline double
111- GD_minmax ( int dim , const signed char * restrict minmax ,
112- const double * restrict points_a , int size_a ,
113- const double * restrict points_r , int size_r )
109+ GD_minmax ( dimension_t dim , const signed char * restrict minmax ,
110+ const double * restrict points_a , size_t size_a ,
111+ const double * restrict points_r , size_t size_r )
114112{
115- return gd_common (dim , minmax ,
116- points_a , size_a ,
117- points_r , size_r ,
118- /*plus=*/ false, /*psize=*/ false,
119- /*p=*/ (uint_fast8_t )1 );
113+ return gd_common (dim , minmax ,
114+ points_a , size_a ,
115+ points_r , size_r ,
116+ /*plus=*/ false, /*psize=*/ false, /*p=*/ 1 );
120117}
121118
122119static inline double
123- IGD_minmax ( int dim , const signed char * restrict minmax ,
124- const double * restrict points_a , int size_a ,
125- const double * restrict points_r , int size_r )
120+ IGD_minmax ( dimension_t dim , const signed char * restrict minmax ,
121+ const double * restrict points_a , size_t size_a ,
122+ const double * restrict points_r , size_t size_r )
126123{
127- return gd_common (dim , minmax ,
128- points_r , size_r ,
129- points_a , size_a ,
130- /*plus=*/ false, /*psize=*/ false,
131- /*p=*/ (uint_fast8_t )1 );
124+ return gd_common (dim , minmax ,
125+ points_r , size_r ,
126+ points_a , size_a ,
127+ /*plus=*/ false, /*psize=*/ false, /*p=*/ 1 );
132128}
133129
134130_attr_maybe_unused static double
135- IGD (const double * restrict data , int nobj , int npoints ,
136- const double * restrict ref , int ref_size ,
137- const bool * restrict maximise )
131+ IGD (const double * restrict data , size_t npoints , dimension_t nobj ,
132+ const double * restrict ref , size_t ref_size ,
133+ const bool * restrict maximise )
138134{
139- ASSUME (nobj > 0 && nobj <= 128 );
140- const signed char * minmax = minmax_from_bool (maximise , (dimension_t ) nobj );
141- double value = IGD_minmax (nobj , minmax , data , npoints , ref , ref_size );
135+ const signed char * minmax = minmax_from_bool (maximise , nobj );
136+ double value = IGD_minmax (nobj , minmax , data , npoints , ref , ref_size );
142137 free ((void * )minmax );
143138 return value ;
144139}
145140
146141static inline double
147- GD_p ( int dim , const signed char * restrict minmax ,
148- const double * restrict points_a , int size_a ,
149- const double * restrict points_r , int size_r , unsigned int p )
142+ GD_p ( dimension_t dim , const signed char * restrict minmax ,
143+ const double * restrict points_a , size_t size_a ,
144+ const double * restrict points_r , size_t size_r , unsigned int p )
150145{
151- return gd_common (dim , minmax ,
152- points_a , size_a ,
153- points_r , size_r ,
154- /*plus=*/ false, /*psize=*/ true, (uint_fast8_t )p );
146+ return gd_common (dim , minmax ,
147+ points_a , size_a ,
148+ points_r , size_r ,
149+ /*plus=*/ false, /*psize=*/ true, (uint_fast8_t )p );
155150}
156151
157152static inline double
158- IGD_p ( int dim , const signed char * restrict minmax ,
159- const double * restrict points_a , int size_a ,
160- const double * restrict points_r , int size_r , unsigned int p )
153+ IGD_p ( dimension_t dim , const signed char * restrict minmax ,
154+ const double * restrict points_a , size_t size_a ,
155+ const double * restrict points_r , size_t size_r , unsigned int p )
161156{
162- return gd_common (dim , minmax ,
163- points_r , size_r ,
164- points_a , size_a ,
165- /*plus=*/ false, /*psize=*/ true, (uint_fast8_t ) p );
157+ return gd_common (dim , minmax ,
158+ points_r , size_r ,
159+ points_a , size_a ,
160+ /*plus=*/ false, /*psize=*/ true, (uint_fast8_t ) p );
166161}
167162
168163static inline double
169- IGD_plus_minmax ( int dim , const signed char * restrict minmax ,
170- const double * restrict points_a , int size_a ,
171- const double * restrict points_r , int size_r )
164+ IGD_plus_minmax ( dimension_t dim , const signed char * restrict minmax ,
165+ const double * restrict points_a , size_t size_a ,
166+ const double * restrict points_r , size_t size_r )
172167{
173- return gd_common (dim , minmax ,
174- points_r , size_r ,
175- points_a , size_a ,
176- /*plus=*/ true, /*psize=*/ true, /*p=*/ ( uint_fast8_t ) 1 );
168+ return gd_common (dim , minmax ,
169+ points_r , size_r ,
170+ points_a , size_a ,
171+ /*plus=*/ true, /*psize=*/ true, /*p=*/ 1 );
177172}
178173
179174_attr_maybe_unused static double
180- IGD_plus (const double * restrict data , int nobj , int npoints , const double * restrict ref , int ref_size ,
181- const bool * restrict maximise )
175+ IGD_plus (const double * restrict data , size_t npoints , dimension_t nobj ,
176+ const double * restrict ref , int ref_size ,
177+ const bool * restrict maximise )
182178{
183- ASSUME (nobj > 0 && nobj <= 128 );
184- const signed char * minmax = minmax_from_bool (maximise , ( dimension_t ) nobj );
185- double value = IGD_plus_minmax (nobj , minmax , data , npoints , ref , ref_size );
179+ ASSUME (nobj > 0 );
180+ const signed char * minmax = minmax_from_bool (maximise , nobj );
181+ double value = IGD_plus_minmax (nobj , minmax , data , npoints , ref , ref_size );
186182 free ((void * )minmax );
187- return ( value ) ;
183+ return value ;
188184}
189185
190186static inline double
191- avg_Hausdorff_dist_minmax ( int dim , const signed char * restrict minmax ,
192- const double * restrict points_a , int size_a ,
193- const double * restrict points_r , int size_r ,
194- unsigned int p )
187+ avg_Hausdorff_dist_minmax ( dimension_t dim , const signed char * restrict minmax ,
188+ const double * restrict points_a , size_t size_a ,
189+ const double * restrict points_r , size_t size_r ,
190+ unsigned int p )
195191{
196- double gd_p = gd_common (dim , minmax ,
197- points_a , size_a ,
192+ double gd_p = gd_common (dim , minmax ,
193+ points_a , size_a ,
194+ points_r , size_r ,
195+ /*plus=*/ false, /*psize=*/ true, (uint_fast8_t )p );
196+
197+ double igd_p = gd_common (dim , minmax ,
198198 points_r , size_r ,
199+ points_a , size_a ,
199200 /*plus=*/ false, /*psize=*/ true, (uint_fast8_t )p );
200-
201- double igd_p = gd_common (dim , minmax ,
202- points_r , size_r ,
203- points_a , size_a ,
204- /*plus=*/ false, /*psize=*/ true, (uint_fast8_t )p );
205201 return MAX (gd_p , igd_p );
206202}
207203/* TODO: Implement p=INFINITY See [4] */
208204
209205_attr_maybe_unused static double
210- avg_Hausdorff_dist (const double * restrict data , int nobj , int npoints ,
211- const double * restrict ref , int ref_size ,
212- const bool * restrict maximise , unsigned int p )
206+ avg_Hausdorff_dist (const double * restrict data , size_t npoints , dimension_t nobj ,
207+ const double * restrict ref , size_t ref_size ,
208+ const bool * restrict maximise , unsigned int p )
213209{
214- ASSUME (nobj > 0 && nobj <= 128 );
215- const signed char * minmax = minmax_from_bool (maximise , ( dimension_t ) nobj );
216- double value = avg_Hausdorff_dist_minmax (nobj , minmax , data , npoints , ref , ref_size , p );
210+ ASSUME (nobj > 0 );
211+ const signed char * minmax = minmax_from_bool (maximise , nobj );
212+ double value = avg_Hausdorff_dist_minmax (nobj , minmax , data , npoints , ref , ref_size , p );
217213 free ((void * )minmax );
218- return ( value ) ;
214+ return value ;
219215}
220216
221217#endif /* IGD_H */
0 commit comments