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 int
00110 LIST_CAT(LIST, size)(const LIST *l)
00111 #ifdef LIST_DEFINE
00112 {
00113 return list_size((const list *)l);
00114 }
00115 #else
00116 ;
00117 #endif
00118
00119
00120 LIST_ELEM *
00121 LIST_CAT(LIST, first)(LIST *l)
00122 #ifdef LIST_DEFINE
00123 {
00124 return list_first((list *)l);
00125 }
00126 #else
00127 ;
00128 #endif
00129
00130
00131 LIST_ELEM *
00132 LIST_CAT(LIST, next)(LIST *l)
00133 #ifdef LIST_DEFINE
00134 {
00135 return list_next((list *)l);
00136 }
00137 #else
00138 ;
00139 #endif
00140
00141
00142 const LIST_ELEM *
00143 LIST_CAT(LIST, first_const)(const LIST *l)
00144 #ifdef LIST_DEFINE
00145 {
00146 return list_first_const((list *)l);
00147 }
00148 #else
00149 ;
00150 #endif
00151
00152
00153 const LIST_ELEM *
00154 LIST_CAT(LIST, next_const)(const LIST *l)
00155 #ifdef LIST_DEFINE
00156 {
00157 return list_next_const((const list *)l);
00158 }
00159 #else
00160 ;
00161 #endif
00162
00163 void
00164 LIST_CAT(LIST, first_pair)(LIST *l,
00165 LIST_ELEM **e1,
00166 LIST_ELEM **e2)
00167 #ifdef LIST_DEFINE
00168 {
00169 list_first_pair((list *)l, (void **)e1, (void **)e2);
00170 return;
00171 }
00172 #else
00173 ;
00174 #endif
00175
00176 void
00177 LIST_CAT(LIST, next_pair)(LIST *l,
00178 LIST_ELEM **e1,
00179 LIST_ELEM **e2)
00180 #ifdef LIST_DEFINE
00181 {
00182 list_next_pair((list *)l, (void **)e1, (void **)e2);
00183 return;
00184 }
00185 #else
00186 ;
00187 #endif
00188
00189 void
00190 LIST_CAT(LIST, first_pair_const)(const LIST *l,
00191 const LIST_ELEM **e1,
00192 const LIST_ELEM **e2)
00193 #ifdef LIST_DEFINE
00194 {
00195 list_first_pair((list *)l, (void **)e1, (void **)e2);
00196 return;
00197 }
00198 #else
00199 ;
00200 #endif
00201 void
00202 LIST_CAT(LIST, next_pair_const)(const LIST *l,
00203 const LIST_ELEM **e1,
00204 const LIST_ELEM **e2)
00205 #ifdef LIST_DEFINE
00206 {
00207 list_next_pair((list *)l, (void **)e1, (void **)e2);
00208 return;
00209 }
00210 #else
00211 ;
00212 #endif
00213
00214 const LIST_ELEM *
00215 LIST_CAT(LIST, remove_const)(LIST *l, const LIST_ELEM *e)
00216 #ifdef LIST_DEFINE
00217 {
00218 return list_remove_const((list *)l, e);
00219 }
00220 #else
00221 ;
00222 #endif
00223
00224 LIST_ELEM *
00225 LIST_CAT(LIST, remove)(LIST *l, LIST_ELEM *e)
00226 #ifdef LIST_DEFINE
00227 {
00228 return list_remove((list *)l, e);
00229 }
00230 #else
00231 ;
00232 #endif
00233
00234
00235 LIST *
00236 LIST_CAT(LIST, extract)(const LIST *l,
00237 LIST_ELEM * (*duplicate)(const LIST_ELEM *),
00238 LIST_CAT(LIST, func_predicate) predicate,
00239 void *data)
00240 #ifdef LIST_DEFINE
00241 {
00242 return (LIST *)list_extract((const list *)l,
00243 (void *(*)(const void *))duplicate,
00244 (list_func_predicate) predicate,
00245 data);
00246 }
00247 #else
00248 ;
00249 #endif
00250
00251
00252 const LIST_ELEM *
00253 LIST_CAT(LIST, max_const)(const LIST *l,
00254 LIST_CAT(LIST, func_lt) less_than,
00255 void *data)
00256 #ifdef LIST_DEFINE
00257 {
00258 return list_max_const((list *)l,
00259 (list_func_lt) less_than,
00260 data);
00261 }
00262 #else
00263 ;
00264 #endif
00265
00266 LIST_ELEM *
00267 LIST_CAT(LIST, max)(LIST *l,
00268 LIST_CAT(LIST, func_lt) less_than,
00269 void *data)
00270 #ifdef LIST_DEFINE
00271 {
00272 return list_max((list *)l,
00273 (list_func_lt) less_than,
00274 data);
00275 }
00276 #else
00277 ;
00278 #endif
00279
00280 LIST_ELEM *
00281 LIST_CAT(LIST, min)(LIST *l,
00282 LIST_CAT(LIST, func_lt) less_than,
00283 void *data)
00284 #ifdef LIST_DEFINE
00285 {
00286 return list_min((list *)l,
00287 (list_func_lt) less_than,
00288 data);
00289 }
00290 #else
00291 ;
00292 #endif
00293
00294
00295 LIST_ELEM *
00296 LIST_CAT(LIST, min_val)(LIST *l,
00297 LIST_CAT(LIST, func_eval) eval,
00298 void *data)
00299 #ifdef LIST_DEFINE
00300 {
00301 return list_min_val((list *)l,
00302 (list_func_eval) eval,
00303 data);
00304 }
00305 #else
00306 ;
00307 #endif
00308
00309
00310 LIST_ELEM *
00311 LIST_CAT(LIST, max_val)(LIST *l,
00312 LIST_CAT(LIST, func_eval) eval,
00313 void *data)
00314 #ifdef LIST_DEFINE
00315 {
00316 return list_max_val((list *)l,
00317 (list_func_eval) eval,
00318 data);
00319 }
00320 #else
00321 ;
00322 #endif
00323
00324
00325 const LIST_ELEM *
00326 LIST_CAT(LIST, kth_const)(const LIST *l, int k,
00327 LIST_CAT(LIST, func_lt) less_than,
00328 void *data)
00329 #ifdef LIST_DEFINE
00330 {
00331 return list_kth_const((list *)l, k,
00332 (list_func_lt) less_than,
00333 data);
00334 }
00335 #else
00336 ;
00337 #endif
00338
00339 LIST_ELEM *
00340 LIST_CAT(LIST, kth)(LIST *l, int k,
00341 LIST_CAT(LIST, func_lt) less_than,
00342 void *data)
00343 #ifdef LIST_DEFINE
00344 {
00345 return list_kth((list *)l, k,
00346 (list_func_lt) less_than,
00347 data);
00348 }
00349 #else
00350 ;
00351 #endif
00352
00353
00354 LIST_ELEM *
00355 LIST_CAT(LIST, kth_val)(LIST *l, int k,
00356 LIST_CAT(LIST, func_eval) eval,
00357 void *data)
00358 #ifdef LIST_DEFINE
00359 {
00360 return list_kth_val((list *)l, k,
00361 (list_func_eval) eval,
00362 data);
00363 }
00364 #else
00365 ;
00366 #endif
00367
00368
00369
00370 const LIST_ELEM *
00371 LIST_CAT(LIST, kth_val_const)(const LIST *l, int k,
00372 LIST_CAT(LIST, func_eval) eval,
00373 void *data)
00374 #ifdef LIST_DEFINE
00375 {
00376 return list_kth_val_const((const list *)l, k,
00377 (list_func_eval) eval,
00378 data);
00379 }
00380 #else
00381 ;
00382 #endif
00383
00384
00385
00386
00387 double
00388 LIST_CAT(LIST, mean)(LIST *l,
00389 LIST_CAT(LIST, func_eval) eval,
00390 void *data)
00391 #ifdef LIST_DEFINE
00392 {
00393 return list_mean((list *)l,
00394 (list_func_eval) eval,
00395 data);
00396 }
00397 #else
00398 ;
00399 #endif
00400
00401 double
00402 LIST_CAT(LIST, mean_optimal)(LIST *l,
00403 LIST_CAT(LIST, func_eval) eval, void *data_eval,
00404 LIST_CAT(LIST, func_eval) eval_err, void *data_err,
00405 double *err,
00406 double *red_chisq)
00407 #ifdef LIST_DEFINE
00408 {
00409 return list_mean_optimal((list *)l,
00410 (list_func_eval) eval, data_eval,
00411 (list_func_eval) eval_err, data_err,
00412 err,
00413 red_chisq);
00414 }
00415 #else
00416 ;
00417 #endif
00418
00419
00420 double
00421 LIST_CAT(LIST, median)(const LIST *l,
00422 LIST_CAT(LIST, func_eval) eval,
00423 void *data)
00424 #ifdef LIST_DEFINE
00425 {
00426 return list_median((const list *)l,
00427 (list_func_eval) eval,
00428 data);
00429 }
00430 #else
00431 ;
00432 #endif
00433
00434
00435 double
00436 LIST_CAT(LIST, mad)(LIST *l,
00437 LIST_CAT(LIST, func_eval) eval,
00438 void *data)
00439 #ifdef LIST_DEFINE
00440 {
00441 return list_mad((list *)l,
00442 (list_func_eval) eval,
00443 data);
00444 }
00445 #else
00446 ;
00447 #endif