00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef LIST_ELEM
00026 #error Define LIST_ELEM before including
00027 #endif
00028
00029 #include <list_void.h>
00030 #include <stdio.h>
00031
00032 #define LIST_CON(a,b) a ## _ ## b
00033 #define LIST_CAT(a,b) LIST_CON(a,b)
00034
00035 #define LIST LIST_CAT(LIST_ELEM, list)
00036
00037 #ifndef LIST_DEFINE
00038
00039 typedef struct LIST LIST;
00040
00041 typedef double (*LIST_CAT(LIST, func_eval))(const LIST_ELEM *,
00042 void *);
00043
00044 typedef bool (*LIST_CAT(LIST, func_lt))(const LIST_ELEM *,
00045 const LIST_ELEM *,
00046 void *);
00047
00048 typedef bool (*LIST_CAT(LIST, func_predicate))(const LIST_ELEM *,
00049 void *);
00050
00051 #endif
00052
00053 LIST *
00054 LIST_CAT(LIST, new)(void)
00055 #ifdef LIST_DEFINE
00056 {
00057 return (LIST *) list_new();
00058 }
00059 #else
00060 ;
00061 #endif
00062
00063
00064 LIST *
00065 LIST_CAT(LIST, duplicate)(const LIST *l,
00066 LIST_ELEM * (*duplicate)(const LIST_ELEM *))
00067 #ifdef LIST_DEFINE
00068 {
00069 return (LIST *)
00070 list_duplicate((const list *)l,
00071 (void *(*)(const void *)) duplicate);
00072 }
00073 #else
00074 ;
00075 #endif
00076
00077 void
00078 LIST_CAT(LIST, delete)(LIST **l,
00079 void (*delete)(LIST_ELEM **))
00080 #ifdef LIST_DEFINE
00081 {
00082 list_delete((list **)l, (void (*)(void **))delete);
00083 }
00084 #else
00085 ;
00086 #endif
00087
00088 void
00089 LIST_CAT(LIST, delete_const)(const LIST **l,
00090 void (*delete)(LIST_ELEM **))
00091 #ifdef LIST_DEFINE
00092 {
00093 list_delete_const((const list **)l, (void (*)(void **))delete);
00094 }
00095 #else
00096 ;
00097 #endif
00098
00099 void
00100 LIST_CAT(LIST, insert)(LIST *l, LIST_ELEM *e)
00101 #ifdef LIST_DEFINE
00102 {
00103 list_insert((list *)l, e);
00104 }
00105 #else
00106 ;
00107 #endif
00108
00109 void
00110 LIST_CAT(LIST, reverse)(LIST *l)
00111 #ifdef LIST_DEFINE
00112 {
00113 list_reverse((list *)l);
00114 }
00115 #else
00116 ;
00117 #endif
00118
00119 int
00120 LIST_CAT(LIST, size)(const LIST *l)
00121 #ifdef LIST_DEFINE
00122 {
00123 return list_size((const list *)l);
00124 }
00125 #else
00126 ;
00127 #endif
00128
00129
00130 LIST_ELEM *
00131 LIST_CAT(LIST, first)(LIST *l)
00132 #ifdef LIST_DEFINE
00133 {
00134 return list_first((list *)l);
00135 }
00136 #else
00137 ;
00138 #endif
00139
00140
00141 LIST_ELEM *
00142 LIST_CAT(LIST, next)(LIST *l)
00143 #ifdef LIST_DEFINE
00144 {
00145 return list_next((list *)l);
00146 }
00147 #else
00148 ;
00149 #endif
00150
00151
00152 const LIST_ELEM *
00153 LIST_CAT(LIST, first_const)(const LIST *l)
00154 #ifdef LIST_DEFINE
00155 {
00156 return list_first_const((list *)l);
00157 }
00158 #else
00159 ;
00160 #endif
00161
00162
00163 const LIST_ELEM *
00164 LIST_CAT(LIST, next_const)(const LIST *l)
00165 #ifdef LIST_DEFINE
00166 {
00167 return list_next_const((const list *)l);
00168 }
00169 #else
00170 ;
00171 #endif
00172
00173 void
00174 LIST_CAT(LIST, first_pair)(LIST *l,
00175 LIST_ELEM **e1,
00176 LIST_ELEM **e2)
00177 #ifdef LIST_DEFINE
00178 {
00179 list_first_pair((list *)l, (void **)e1, (void **)e2);
00180 return;
00181 }
00182 #else
00183 ;
00184 #endif
00185
00186 void
00187 LIST_CAT(LIST, next_pair)(LIST *l,
00188 LIST_ELEM **e1,
00189 LIST_ELEM **e2)
00190 #ifdef LIST_DEFINE
00191 {
00192 list_next_pair((list *)l, (void **)e1, (void **)e2);
00193 return;
00194 }
00195 #else
00196 ;
00197 #endif
00198
00199 void
00200 LIST_CAT(LIST, first_pair_const)(const LIST *l,
00201 const LIST_ELEM **e1,
00202 const LIST_ELEM **e2)
00203 #ifdef LIST_DEFINE
00204 {
00205 list_first_pair((list *)l, (void **)e1, (void **)e2);
00206 return;
00207 }
00208 #else
00209 ;
00210 #endif
00211 void
00212 LIST_CAT(LIST, next_pair_const)(const LIST *l,
00213 const LIST_ELEM **e1,
00214 const LIST_ELEM **e2)
00215 #ifdef LIST_DEFINE
00216 {
00217 list_next_pair((list *)l, (void **)e1, (void **)e2);
00218 return;
00219 }
00220 #else
00221 ;
00222 #endif
00223
00224 const LIST_ELEM *
00225 LIST_CAT(LIST, remove_const)(LIST *l, const LIST_ELEM *e)
00226 #ifdef LIST_DEFINE
00227 {
00228 return list_remove_const((list *)l, e);
00229 }
00230 #else
00231 ;
00232 #endif
00233
00234 LIST_ELEM *
00235 LIST_CAT(LIST, remove)(LIST *l, LIST_ELEM *e)
00236 #ifdef LIST_DEFINE
00237 {
00238 return list_remove((list *)l, e);
00239 }
00240 #else
00241 ;
00242 #endif
00243
00244
00245 LIST *
00246 LIST_CAT(LIST, extract)(const LIST *l,
00247 LIST_ELEM * (*duplicate)(const LIST_ELEM *),
00248 LIST_CAT(LIST, func_predicate) predicate,
00249 void *data)
00250 #ifdef LIST_DEFINE
00251 {
00252 return (LIST *)list_extract((const list *)l,
00253 (void *(*)(const void *))duplicate,
00254 (list_func_predicate) predicate,
00255 data);
00256 }
00257 #else
00258 ;
00259 #endif
00260
00261
00262 const LIST_ELEM *
00263 LIST_CAT(LIST, max_const)(const LIST *l,
00264 LIST_CAT(LIST, func_lt) less_than,
00265 void *data)
00266 #ifdef LIST_DEFINE
00267 {
00268 return list_max_const((list *)l,
00269 (list_func_lt) less_than,
00270 data);
00271 }
00272 #else
00273 ;
00274 #endif
00275
00276 LIST_ELEM *
00277 LIST_CAT(LIST, max)(LIST *l,
00278 LIST_CAT(LIST, func_lt) less_than,
00279 void *data)
00280 #ifdef LIST_DEFINE
00281 {
00282 return list_max((list *)l,
00283 (list_func_lt) less_than,
00284 data);
00285 }
00286 #else
00287 ;
00288 #endif
00289
00290 LIST_ELEM *
00291 LIST_CAT(LIST, min)(LIST *l,
00292 LIST_CAT(LIST, func_lt) less_than,
00293 void *data)
00294 #ifdef LIST_DEFINE
00295 {
00296 return list_min((list *)l,
00297 (list_func_lt) less_than,
00298 data);
00299 }
00300 #else
00301 ;
00302 #endif
00303
00304
00305 LIST_ELEM *
00306 LIST_CAT(LIST, min_val)(LIST *l,
00307 LIST_CAT(LIST, func_eval) eval,
00308 void *data)
00309 #ifdef LIST_DEFINE
00310 {
00311 return list_min_val((list *)l,
00312 (list_func_eval) eval,
00313 data);
00314 }
00315 #else
00316 ;
00317 #endif
00318
00319
00320 LIST_ELEM *
00321 LIST_CAT(LIST, max_val)(LIST *l,
00322 LIST_CAT(LIST, func_eval) eval,
00323 void *data)
00324 #ifdef LIST_DEFINE
00325 {
00326 return list_max_val((list *)l,
00327 (list_func_eval) eval,
00328 data);
00329 }
00330 #else
00331 ;
00332 #endif
00333
00334
00335 const LIST_ELEM *
00336 LIST_CAT(LIST, kth_const)(const LIST *l, int k,
00337 LIST_CAT(LIST, func_lt) less_than,
00338 void *data)
00339 #ifdef LIST_DEFINE
00340 {
00341 return list_kth_const((list *)l, k,
00342 (list_func_lt) less_than,
00343 data);
00344 }
00345 #else
00346 ;
00347 #endif
00348
00349 LIST_ELEM *
00350 LIST_CAT(LIST, kth)(LIST *l, int k,
00351 LIST_CAT(LIST, func_lt) less_than,
00352 void *data)
00353 #ifdef LIST_DEFINE
00354 {
00355 return list_kth((list *)l, k,
00356 (list_func_lt) less_than,
00357 data);
00358 }
00359 #else
00360 ;
00361 #endif
00362
00363
00364 LIST_ELEM *
00365 LIST_CAT(LIST, kth_val)(LIST *l, int k,
00366 LIST_CAT(LIST, func_eval) eval,
00367 void *data)
00368 #ifdef LIST_DEFINE
00369 {
00370 return list_kth_val((list *)l, k,
00371 (list_func_eval) eval,
00372 data);
00373 }
00374 #else
00375 ;
00376 #endif
00377
00378
00379
00380 const LIST_ELEM *
00381 LIST_CAT(LIST, kth_val_const)(const LIST *l, int k,
00382 LIST_CAT(LIST, func_eval) eval,
00383 void *data)
00384 #ifdef LIST_DEFINE
00385 {
00386 return list_kth_val_const((const list *)l, k,
00387 (list_func_eval) eval,
00388 data);
00389 }
00390 #else
00391 ;
00392 #endif
00393
00394
00395
00396
00397 double
00398 LIST_CAT(LIST, mean)(LIST *l,
00399 LIST_CAT(LIST, func_eval) eval,
00400 void *data)
00401 #ifdef LIST_DEFINE
00402 {
00403 return list_mean((list *)l,
00404 (list_func_eval) eval,
00405 data);
00406 }
00407 #else
00408 ;
00409 #endif
00410
00411 double
00412 LIST_CAT(LIST, mean_optimal)(LIST *l,
00413 LIST_CAT(LIST, func_eval) eval, void *data_eval,
00414 LIST_CAT(LIST, func_eval) eval_err, void *data_err,
00415 double *err,
00416 double *red_chisq)
00417 #ifdef LIST_DEFINE
00418 {
00419 return list_mean_optimal((list *)l,
00420 (list_func_eval) eval, data_eval,
00421 (list_func_eval) eval_err, data_err,
00422 err,
00423 red_chisq);
00424 }
00425 #else
00426 ;
00427 #endif
00428
00429
00430 double
00431 LIST_CAT(LIST, median)(const LIST *l,
00432 LIST_CAT(LIST, func_eval) eval,
00433 void *data)
00434 #ifdef LIST_DEFINE
00435 {
00436 return list_median((const list *)l,
00437 (list_func_eval) eval,
00438 data);
00439 }
00440 #else
00441 ;
00442 #endif
00443
00444
00445 double
00446 LIST_CAT(LIST, mad)(LIST *l,
00447 LIST_CAT(LIST, func_eval) eval,
00448 void *data)
00449 #ifdef LIST_DEFINE
00450 {
00451 return list_mad((list *)l,
00452 (list_func_eval) eval,
00453 data);
00454 }
00455 #else
00456 ;
00457 #endif