LALPulsar  6.1.0.1-89842e6
CrossCorrToplist.c
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2010 Christine Chung (based closely on CrossCorrToplist.c)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19 
20 #include "config.h"
21 
22 #include <stdio.h>
23 #ifdef HAVE_UNISTD_H
24 #include <unistd.h>
25 #endif
26 
27 #include <lal/StringInput.h>
28 #include <lal/LALConstants.h>
29 #include <lal/LALStdio.h>
30 #include <lal/LogPrintf.h>
31 #include <lal/HeapToplist.h>
32 
33 #include "CrossCorrToplist.h"
34 
35 /* Windows specifics */
36 #ifdef _WIN32
37 #include <io.h>
38 
39 /* errno */
40 extern int errno;
41 extern int _doserrno;
42 
43 /* snprintf */
44 #define snprintf _snprintf
45 
46 /* fsync */
47 #define fsync _commit
48 #define fileno _fileno
49 
50 /* finite */
51 #include <float.h>
52 #define finite _finite
53 
54 #else /* WIN32 */
55 
56 /* errno */
57 #include <errno.h>
58 
59 /* this is defined in C99 and *should* be in math.h. Long term
60  protect this with a HAVE_FINITE */
61 int finite( double );
62 
63 #endif /* WIN32 */
64 
65 
66 
67 
68 
69 /* define min macro if not already defined */
70 #ifndef min
71 #define min(a,b) ((a)<(b)?(a):(b))
72 #endif
73 
74 /* maximum number of succesive failures before switching off syncing */
75 #define SYNC_FAIL_LIMIT 5
76 
77 /* local prototypes */
79 static int _atomic_write_crossCorr_toplist_to_file( toplist_t *l, const char *filename, UINT4 *checksum, int write_done );
80 static int _atomic_write_crossCorrBinary_toplist_to_file( toplist_t *l, const char *filename, UINT4 *checksum, int write_done );
81 
82 static int print_crossCorrline_to_str( CrossCorrOutputEntry fline, char *buf, int buflen );
83 static int print_crossCorrBinaryline_to_str( CrossCorrBinaryOutputEntry fline, char *buf, int buflen );
84 
85 
86 /* ordering function for sorting the list */
87 static int crossCorr_toplist_qsort_function( const void *a, const void *b )
88 {
89  if ( ( ( const CrossCorrOutputEntry * )a )->Freq < ( ( const CrossCorrOutputEntry * )b )->Freq ) {
90  return -1;
91  } else if ( ( ( const CrossCorrOutputEntry * )a )->Freq > ( ( const CrossCorrOutputEntry * )b )->Freq ) {
92  return 1;
93  }
94  if ( ( ( const CrossCorrOutputEntry * )a )->Q1 < ( ( const CrossCorrOutputEntry * )b )->Q1 ) {
95  return -1;
96  } else if ( ( ( const CrossCorrOutputEntry * )a )->Q1 > ( ( const CrossCorrOutputEntry * )b )->Q1 ) {
97  return 1;
98  }
99  if ( ( ( const CrossCorrOutputEntry * )a )->Q2 < ( ( const CrossCorrOutputEntry * )b )->Q2 ) {
100  return -1;
101  } else if ( ( ( const CrossCorrOutputEntry * )a )->Q2 > ( ( const CrossCorrOutputEntry * )b )->Q2 ) {
102  return 1;
103  }
104  if ( ( ( const CrossCorrOutputEntry * )a )->BrakingIndex < ( ( const CrossCorrOutputEntry * )b )->BrakingIndex ) {
105  return -1;
106  } else if ( ( ( const CrossCorrOutputEntry * )a )->BrakingIndex > ( ( const CrossCorrOutputEntry * )b )->BrakingIndex ) {
107  return 1;
108  } else if ( ( ( const CrossCorrOutputEntry * )a )->Alpha < ( ( const CrossCorrOutputEntry * )b )->Alpha ) {
109  return -1;
110  } else if ( ( ( const CrossCorrOutputEntry * )a )->Alpha > ( ( const CrossCorrOutputEntry * )b )->Alpha ) {
111  return 1;
112  } else if ( ( ( const CrossCorrOutputEntry * )a )->Delta < ( ( const CrossCorrOutputEntry * )b )->Delta ) {
113  return -1;
114  } else if ( ( ( const CrossCorrOutputEntry * )a )->Delta > ( ( const CrossCorrOutputEntry * )b )->Delta ) {
115  return 1;
116  } else {
117  return 0;
118  }
119 }
120 
121 
122 /* ordering function for sorting the list */
123 static int crossCorrBinary_toplist_qsort_function( const void *a, const void *b )
124 {
125  if ( ( ( const CrossCorrBinaryOutputEntry * )a )->freq < ( ( const CrossCorrBinaryOutputEntry * )b )->freq ) {
126  return -1;
127  } else if ( ( ( const CrossCorrBinaryOutputEntry * )a )->freq > ( ( const CrossCorrBinaryOutputEntry * )b )->freq ) {
128  return 1;
129  }
130  if ( ( ( const CrossCorrBinaryOutputEntry * )a )->tp < ( ( const CrossCorrBinaryOutputEntry * )b )->tp ) {
131  return -1;
132  } else if ( ( ( const CrossCorrBinaryOutputEntry * )a )->tp > ( ( const CrossCorrBinaryOutputEntry * )b )->tp ) {
133  return 1;
134  }
135  if ( ( ( const CrossCorrBinaryOutputEntry * )a )->argp < ( ( const CrossCorrBinaryOutputEntry * )b )->argp ) {
136  return -1;
137  } else if ( ( ( const CrossCorrBinaryOutputEntry * )a )->argp > ( ( const CrossCorrBinaryOutputEntry * )b )->argp ) {
138  return 1;
139  }
140  if ( ( ( const CrossCorrBinaryOutputEntry * )a )->asini < ( ( const CrossCorrBinaryOutputEntry * )b )->asini ) {
141  return -1;
142  } else if ( ( ( const CrossCorrBinaryOutputEntry * )a )->asini > ( ( const CrossCorrBinaryOutputEntry * )b )->asini ) {
143  return 1;
144  } else if ( ( ( const CrossCorrBinaryOutputEntry * )a )->ecc < ( ( const CrossCorrBinaryOutputEntry * )b )->ecc ) {
145  return -1;
146  } else if ( ( ( const CrossCorrBinaryOutputEntry * )a )->ecc > ( ( const CrossCorrBinaryOutputEntry * )b )->ecc ) {
147  return 1;
148  } else if ( ( ( const CrossCorrBinaryOutputEntry * )a )->period < ( ( const CrossCorrBinaryOutputEntry * )b )->period ) {
149  return -1;
150  } else if ( ( ( const CrossCorrBinaryOutputEntry * )a )->period > ( ( const CrossCorrBinaryOutputEntry * )b )->period ) {
151  return 1;
152  } else {
153  return 0;
154  }
155 }
156 
157 
158 /* ordering function defining the toplist */
159 static int crossCorr_smaller( const void *a, const void *b )
160 {
161  if ( ( ( const CrossCorrOutputEntry * )a )->Rho < ( ( const CrossCorrOutputEntry * )b )->Rho ) {
162  return ( 1 );
163  } else if ( ( ( const CrossCorrOutputEntry * )a )->Rho > ( ( const CrossCorrOutputEntry * )b )->Rho ) {
164  return ( -1 );
165  } else {
166  return ( crossCorr_toplist_qsort_function( a, b ) );
167  }
168 }
169 
170 
171 static int crossCorrBinary_smaller( const void *a, const void *b )
172 {
173  if ( ( ( const CrossCorrBinaryOutputEntry * )a )->rho < ( ( const CrossCorrBinaryOutputEntry * )b )->rho ) {
174  return ( 1 );
175  } else if ( ( ( const CrossCorrBinaryOutputEntry * )a )->rho > ( ( const CrossCorrBinaryOutputEntry * )b )->rho ) {
176  return ( -1 );
177  } else {
178  return ( crossCorrBinary_toplist_qsort_function( a, b ) );
179  }
180 }
181 
182 
183 
184 /* creates a toplist with length elements,
185  returns -1 on error (usually out of memory), else 0 */
187 {
188  return ( create_toplist( tl, length, sizeof( CrossCorrOutputEntry ), crossCorr_smaller ) );
189 }
190 
192 {
193  return ( create_toplist( tl, length, sizeof( CrossCorrBinaryOutputEntry ), crossCorrBinary_smaller ) );
194 }
195 
196 
197 /* frees the space occupied by the toplist */
199 {
200  free_toplist( l );
201 }
202 
203 
204 /* Inserts an element in to the toplist either if there is space left
205  or the element is larger than the smallest element in the toplist.
206  In the latter case, remove the smallest element from the toplist and
207  look for the now smallest one.
208  Returns 1 if the element was actually inserted, 0 if not. */
210 {
211  if ( !tl ) {
212  return 0;
213  } else {
214  return ( insert_into_toplist( tl, ( void * )&elem ) );
215  }
216 }
217 
218 
220 {
221  if ( !tl ) {
222  return 0;
223  } else {
224  return ( insert_into_toplist( tl, ( void * )&elem ) );
225  }
226 }
227 
228 
229 
230 
231 /* (q)sort the toplist according to the sorting function. */
233 {
235 }
236 
237 
239 {
241 }
242 
243 /* /\* reads a (created!) toplist from an open filepointer */
244 /* returns the number of bytes read, */
245 /* 0 if we found a %DONE marker at the end, */
246 /* -1 if the file contained a syntax error, */
247 /* -2 if given an improper toplist *\/ */
248 /* int read_crossCorr_toplist_from_fp(toplist_t*l, FILE*fp, UINT4*checksum, UINT4 maxbytes) { */
249 /* CHAR line[256]; /\* buffer for reading a line *\/ */
250 /* UINT4 items, lines; /\* number of items read from a line, linecounter *\/ */
251 /* UINT4 len, chars = 0; /\* length of a line, total characters read from the file *\/ */
252 /* UINT4 i; /\* loop counter *\/ */
253 /* CHAR lastchar; /\* last character of a line read, should be newline *\/ */
254 /* CrossCorrOutputEntry CrossCorrLine; */
255 /* REAL8 epsilon=1e-5; */
256 
257 /* /\* basic check that the list argument is valid *\/ */
258 /* if(!l) */
259 /* return -2; */
260 
261 /* /\* make sure the line buffer is terminated correctly *\/ */
262 /* XLAL_LAST_ELEM(line)='\0'; */
263 
264 /* /\* init the checksum if given *\/ */
265 /* if(checksum) */
266 /* *checksum = 0; */
267 
268 /* /\* set maxbytes to maximum if zero *\/ */
269 /* if (maxbytes == 0) */
270 /* maxbytes--; */
271 
272 /* lines=1; */
273 /* while(fgets(line,sizeof(line)-1, fp)) { */
274 
275 /* if (!strncmp(line,"%DONE\n",strlen("%DONE\n"))) { */
276 /* LogPrintf(LOG_NORMAL,"WARNING: found end marker - the task was already finished\n"); */
277 /* return(0); */
278 /* } */
279 
280 /* len = strlen(line); */
281 /* chars += len; */
282 
283 /* if (len==0) { */
284 /* LogPrintf (LOG_CRITICAL, "Line %d is empty.\n", lines); */
285 /* return -1; */
286 /* } */
287 /* else if (line[len-1] != '\n') { */
288 /* LogPrintf (LOG_CRITICAL, */
289 /* "Line %d is too long or has no NEWLINE. First %d chars are:\n'%s'\n", */
290 /* lines,sizeof(line)-1, line); */
291 /* return -1; */
292 /* } */
293 
294 /* items = sscanf (line, */
295 /* "%" LAL_REAL8_FORMAT */
296 /* " %" LAL_REAL8_FORMAT */
297 /* " %" LAL_REAL8_FORMAT */
298 /* " %" LAL_REAL8_FORMAT */
299 /* " %" LAL_REAL8_FORMAT */
300 /* " %" LAL_REAL8_FORMAT */
301 /* " %" LAL_REAL8_FORMAT */
302 /* " %" LAL_REAL8_FORMAT "%c", */
303 /* &CrossCorrLine.Freq, */
304 /* &CrossCorrLine.Q1, */
305 /* &CrossCorrLine.Q2, */
306 /* &CrossCorrLine.BrakingIndex, */
307 /* &CrossCorrLine.Alpha, */
308 /* &CrossCorrLine.Delta, */
309 /* &CrossCorrLine.Rho, */
310 /* &lastchar); */
311 
312 /* /\* check the values scanned *\/ */
313 /* if ( */
314 /* items != 7 || */
315 
316 /* !finite(CrossCorrLine.Freq) || */
317 /* !finite(CrossCorrLine.Q1) || */
318 /* !finite(CrossCorrLine.Q2) || */
319 /* !finite(CrossCorrLine.BrakingIndex) || */
320 /* !finite(CrossCorrLine.Alpha) || */
321 /* !finite(CrossCorrLine.Delta) || */
322 /* !finite(CrossCorrLine.Rho) || */
323 
324 /* CrossCorrLine.Freq < 0.0 || */
325 /* CrossCorrLine.Alpha < 0.0 - epsilon || */
326 /* CrossCorrLine.Alpha > LAL_TWOPI + epsilon || */
327 /* CrossCorrLine.Delta < -0.5*LAL_PI - epsilon || */
328 /* CrossCorrLine.Delta > 0.5*LAL_PI + epsilon || */
329 
330 /* lastchar != '\n' */
331 /* ) { */
332 /* LogPrintf (LOG_CRITICAL, */
333 /* "Line %d has invalid values.\n" */
334 /* "First %d chars are:\n" */
335 /* "%s\n" */
336 /* "All fields should be finite\n" */
337 /* "1st field should be positive.\n" */
338 /* "2nd field should lie between 0 and %1.15f.\n" */
339 /* "3rd field should lie between %1.15f and %1.15f.\n", */
340 /* lines, sizeof(line)-1, line, */
341 /* (double)LAL_TWOPI, (double)-LAL_PI/2.0, (double)LAL_PI/2.0); */
342 /* return -1; */
343 /* } */
344 
345 /* if (checksum) */
346 /* for(i=0;i<len;i++) */
347 /* *checksum += line[i]; */
348 
349 /* insert_into_toplist(l, &CrossCorrLine); */
350 /* lines++; */
351 
352 /* /\* NOTE: it *CAN* happen (and on Linux it DOES) that the fully buffered CrossCorr stream */
353 /* * gets written to the File at program termination. */
354 /* * This does not seem to happen on Mac though, most likely due to different */
355 /* * exit()-calls used (_exit() vs exit() etc.....) */
356 /* * */
357 /* * The bottom-line is: the File-contents CAN legally extend beyond maxbytes, */
358 /* * which is why we'll ensure here that we don't actually read more than */
359 /* * maxbytes. */
360 /* *\/ */
361 /* if ( chars == maxbytes ) */
362 /* { */
363 /* LogPrintf (LOG_DEBUG, "Read exactly %d == maxbytes from CrossCorr-file, that's enough.\n", */
364 /* chars); */
365 /* break; */
366 /* } */
367 /* /\* however, if we've read more than maxbytes, something is gone wrong *\/ */
368 /* if ( chars > maxbytes ) */
369 /* { */
370 /* LogPrintf (LOG_CRITICAL, "Read %d bytes > maxbytes %d from CrossCorr-file ... corrupted.\n", */
371 /* chars, maxbytes ); */
372 /* return -1; */
373 /* } */
374 
375 /* } /\* while (fgets() ) *\/ */
376 
377 /* return chars; */
378 
379 /* } /\* read_crossCorr_toplist_from_fp() *\/ */
380 
381 
382 /* int read_crossCorrBinary_toplist_from_fp(toplist_t*l, FILE*fp, UINT4*checksum, UINT4 maxbytes) { */
383 /* CHAR line[256]; /\* buffer for reading a line *\/ */
384 /* UINT4 items, lines; /\* number of items read from a line, linecounter *\/ */
385 /* UINT4 len, chars = 0; /\* length of a line, total characters read from the file *\/ */
386 /* UINT4 i; /\* loop counter *\/ */
387 /* CHAR lastchar; /\* last character of a line read, should be newline *\/ */
388 /* CrossCorrBinaryOutputEntry CrossCorrLine; */
389 /* REAL8 epsilon=1e-5; */
390 
391 /* /\* basic check that the list argument is valid *\/ */
392 /* if(!l) */
393 /* return -2; */
394 
395 /* /\* make sure the line buffer is terminated correctly *\/ */
396 /* XLAL_LAST_ELEM(line)='\0'; */
397 
398 /* /\* init the checksum if given *\/ */
399 /* if(checksum) */
400 /* *checksum = 0; */
401 
402 /* /\* set maxbytes to maximum if zero *\/ */
403 /* if (maxbytes == 0) */
404 /* maxbytes--; */
405 
406 /* lines=1; */
407 /* while(fgets(line,sizeof(line)-1, fp)) { */
408 
409 /* if (!strncmp(line,"%DONE\n",strlen("%DONE\n"))) { */
410 /* LogPrintf(LOG_NORMAL,"WARNING: found end marker - the task was already finished\n"); */
411 /* return(0); */
412 /* } */
413 
414 /* len = strlen(line); */
415 /* chars += len; */
416 
417 /* if (len==0) { */
418 /* LogPrintf (LOG_CRITICAL, "Line %d is empty.\n", lines); */
419 /* return -1; */
420 /* } */
421 /* else if (line[len-1] != '\n') { */
422 /* LogPrintf (LOG_CRITICAL, */
423 /* "Line %d is too long or has no NEWLINE. First %d chars are:\n'%s'\n", */
424 /* lines,sizeof(line)-1, line); */
425 /* return -1; */
426 /* } */
427 
428 /* items = sscanf (line, */
429 /* "%" LAL_REAL8_FORMAT */
430 /* " %" LAL_REAL8_FORMAT */
431 /* " %" LAL_REAL8_FORMAT */
432 /* " %" LAL_REAL8_FORMAT */
433 /* " %" LAL_REAL8_FORMAT */
434 /* " %" LAL_REAL8_FORMAT "%c", */
435 /* &CrossCorrBinaryLine.freq, */
436 /* &CrossCorrBinaryLine.tp, */
437 /* &CrossCorrBinaryLine.argp, */
438 /* &CrossCorrBinaryLine.asini, */
439 /* &CrossCorrBinaryLine.ecc, */
440 /* &CrossCorrBinaryLine.period, */
441 /* &CrossCorrBinaryLine.rho, */
442 /* &lastchar); */
443 
444 /* /\* check the values scanned *\/ */
445 /* if ( */
446 /* items != 7 || */
447 
448 /* !finite(CrossCorrBinaryLine.freq) || */
449 /* !finite(CrossCorrBinaryLine.tp) || */
450 /* !finite(CrossCorrBinaryLine.argp) || */
451 /* !finite(CrossCorrBinaryLine.asini) || */
452 /* !finite(CrossCorrBinaryLine.ecc) || */
453 /* !finite(CrossCorrBinaryLine.period) || */
454 /* !finite(CrossCorrBinaryLine.rho) || */
455 
456 /* CrossCorrBinaryLine.Freq < 0.0 || */
457 
458 /* lastchar != '\n' */
459 /* ) { */
460 /* LogPrintf (LOG_CRITICAL, "Line %d has invalid values.\n",lines); */
461 /* return -1; */
462 /* } */
463 
464 /* if (checksum) */
465 /* for(i=0;i<len;i++) */
466 /* *checksum += line[i]; */
467 
468 /* insert_into_toplist(l, &CrossCorrBinaryLine); */
469 /* lines++; */
470 
471 /* /\* NOTE: it *CAN* happen (and on Linux it DOES) that the fully buffered CrossCorr stream */
472 /* * gets written to the File at program termination. */
473 /* * This does not seem to happen on Mac though, most likely due to different */
474 /* * exit()-calls used (_exit() vs exit() etc.....) */
475 /* * */
476 /* * The bottom-line is: the File-contents CAN legally extend beyond maxbytes, */
477 /* * which is why we'll ensure here that we don't actually read more than */
478 /* * maxbytes. */
479 /* *\/ */
480 /* if ( chars == maxbytes ) */
481 /* { */
482 /* LogPrintf (LOG_DEBUG, "Read exactly %d == maxbytes from CrossCorr-file, that's enough.\n", */
483 /* chars); */
484 /* break; */
485 /* } */
486 /* /\* however, if we've read more than maxbytes, something is gone wrong *\/ */
487 /* if ( chars > maxbytes ) */
488 /* { */
489 /* LogPrintf (LOG_CRITICAL, "Read %d bytes > maxbytes %d from CrossCorr-file ... corrupted.\n", */
490 /* chars, maxbytes ); */
491 /* return -1; */
492 /* } */
493 
494 /* } /\* while (fgets() ) *\/ */
495 
496 /* return chars; */
497 
498 /* } /\* read_crossCorr_toplist_from_fp() *\/ */
499 
500 
501 
502 
503 /* Prints a Toplist line to a string buffer.
504  Separate function to assure consistency of output and reduced precision for sorting */
505 static int print_crossCorrline_to_str( CrossCorrOutputEntry fline, char *buf, int buflen )
506 {
507  return ( snprintf( buf, buflen,
508  /* output precision: choose by following (generous!) significant-digit constraints:
509  * Freq, Q1, Q2:1e-13
510  * BrakingIndex: 1e-5 (?)
511  * Alpha,Delta:1e-7
512  * Rho:1e-7
513  */
514  "%.13g %.13g %.13g %.5g %.7g %.7g %.7g\n",
515  fline.Freq,
516  fline.Q1,
517  fline.Q2,
518  fline.BrakingIndex,
519  fline.Alpha,
520  fline.Delta,
521  fline.Rho ) );
522 }
523 
524 
525 static int print_crossCorrBinaryline_to_str( CrossCorrBinaryOutputEntry fline, char *buf, int buflen )
526 {
527  return ( snprintf( buf, buflen,
528  /* output precision: choose to 10 for no real reason -- FIXME:
529  */
530  "%.10f %.10f %.10g %.10f %.10g %.5f %.10g %.10g %.10g\n",
531  fline.freq,
532  fline.tp,
533  fline.argp,
534  fline.asini,
535  fline.ecc,
536  fline.period,
537  fline.estSens,
538  fline.evSquared,
539  fline.rho ) );
540 }
541 
542 
543 /* writes an CrossCorrOutputEntry line to an open filepointer.
544  Returns the number of chars written, -1 if in error
545  Updates checksum if given */
547 {
548  char linebuf[256];
549  UINT4 i;
550 
551  UINT4 length = print_crossCorrline_to_str( fline, linebuf, sizeof( linebuf ) - 1 );
552 
553  if ( length > sizeof( linebuf ) - 1 ) {
554  return -1;
555  }
556 
557  if ( checksum )
558  for ( i = 0; i < length; i++ ) {
559  *checksum += linebuf[i];
560  }
561 
562  XLAL_LAST_ELEM( linebuf ) = '\0';
563 
564  return ( fprintf( fp, "%s", linebuf ) );
565 }
566 
567 
569 {
570  char linebuf[256];
571  UINT4 i;
572 
573  UINT4 length = print_crossCorrBinaryline_to_str( fline, linebuf, sizeof( linebuf ) - 1 );
574 
575  if ( length > sizeof( linebuf ) - 1 ) {
576  return -1;
577  }
578 
579  if ( checksum )
580  for ( i = 0; i < length; i++ ) {
581  *checksum += linebuf[i];
582  }
583 
584  XLAL_LAST_ELEM( linebuf ) = '\0';
585 
586  return ( fprintf( fp, "%s", linebuf ) );
587 }
588 
589 /* Reduces the precision of all elements in the toplist which influence the sorting order.
590  To be called before sorting and finally writing out the list */
591 static void reduce_crossCorrline_precision( void *line )
592 {
593  char linebuf[256];
594  print_crossCorrline_to_str( ( *( CrossCorrOutputEntry * )line ), linebuf, sizeof( linebuf ) );
595  sscanf( linebuf,
596  "%" LAL_REAL8_FORMAT
597  " %" LAL_REAL8_FORMAT
598  " %" LAL_REAL8_FORMAT
599  " %" LAL_REAL8_FORMAT
600  " %" LAL_REAL8_FORMAT
601  " %" LAL_REAL8_FORMAT
602  "%*s\n",
603  &( ( *( CrossCorrOutputEntry * )line ).Freq ),
604  &( ( *( CrossCorrOutputEntry * )line ).Q1 ),
605  &( ( *( CrossCorrOutputEntry * )line ).Q2 ),
606  &( ( *( CrossCorrOutputEntry * )line ).BrakingIndex ),
607  &( ( *( CrossCorrOutputEntry * )line ).Alpha ),
608  &( ( *( CrossCorrOutputEntry * )line ).Delta ) );
609 }
610 
611 static void reduce_crossCorrBinaryline_precision( void *line )
612 {
613  char linebuf[256];
614  print_crossCorrBinaryline_to_str( ( *( CrossCorrBinaryOutputEntry * )line ), linebuf, sizeof( linebuf ) );
615  sscanf( linebuf,
616  "%" LAL_REAL8_FORMAT
617  " %" LAL_REAL8_FORMAT
618  " %" LAL_REAL8_FORMAT
619  " %" LAL_REAL8_FORMAT
620  " %" LAL_REAL8_FORMAT
621  " %" LAL_REAL8_FORMAT
622  "%*s\n",
623  &( ( *( CrossCorrBinaryOutputEntry * )line ).freq ),
624  &( ( *( CrossCorrBinaryOutputEntry * )line ).tp ),
625  &( ( *( CrossCorrBinaryOutputEntry * )line ).argp ),
626  &( ( *( CrossCorrBinaryOutputEntry * )line ).asini ),
627  &( ( *( CrossCorrBinaryOutputEntry * )line ).ecc ),
628  &( ( *( CrossCorrBinaryOutputEntry * )line ).period ) );
629 }
630 
631 
633 {
635 }
636 
637 
639 {
641 }
642 
643 
644 /* Writes the toplist to an (already open) filepointer
645  Returns the number of written charactes
646  Returns something <0 on error */
647 int write_crossCorr_toplist_to_fp( toplist_t *tl, FILE *fp, UINT4 *checksum )
648 {
649  UINT8 c = 0, i;
650  INT8 r;
651  if ( checksum ) {
652  *checksum = 0;
653  }
654  for ( i = 0; i < tl->elems; i++ )
655  if ( ( r = write_crossCorr_toplist_item_to_fp( *( ( CrossCorrOutputEntry * )( void * )( tl->heap[i] ) ), fp, checksum ) ) < 0 ) {
656  LogPrintf( LOG_CRITICAL, "Failed to write toplistitem to output fp: %d: %s\n",
657  errno, strerror( errno ) );
658 #ifdef _MSC_VER
659  LogPrintf( LOG_CRITICAL, "Windows system call returned: %d\n", _doserrno );
660 #endif
661  return ( r );
662  } else {
663  c += r;
664  }
665  return ( c );
666 }
667 
668 
670 {
671  UINT8 c = 0, i;
672  INT8 r;
673  if ( checksum ) {
674  *checksum = 0;
675  }
676  for ( i = 0; i < tl->elems; i++ )
677  if ( ( r = write_crossCorrBinary_toplist_item_to_fp( *( ( CrossCorrBinaryOutputEntry * )( void * )( tl->heap[i] ) ), fp, checksum ) ) < 0 ) {
678  LogPrintf( LOG_CRITICAL, "Failed to write toplistitem to output fp: %d: %s\n",
679  errno, strerror( errno ) );
680 #ifdef _MSC_VER
681  LogPrintf( LOG_CRITICAL, "Windows system call returned: %d\n", _doserrno );
682 #endif
683  return ( r );
684  } else {
685  c += r;
686  }
687  return ( c );
688 }
689 
690 
691 /* writes the given toplitst to a temporary file, then renames the temporary file to filename.
692  The name of the temporary file is derived from the filename by appending ".tmp". Returns the
693  number of chars written or -1 if the temp file could not be opened.
694  This just calls _atomic_write_crossCorr_toplist_to_file() telling it not to write a %DONE marker*/
696 {
697  return ( _atomic_write_crossCorr_toplist_to_file( l, filename, checksum, 0 ) );
698 }
699 
701 {
702  return ( _atomic_write_crossCorrBinary_toplist_to_file( l, filename, checksum, 0 ) );
703 }
704 
705 /* function that does the actual work of atomic_write_crossCorr_toplist_to_file(),
706  appending a %DONE marker if specified (not when called from atomic_write_crossCorr_toplist_to_file().
707  NOTE that the checksum will be a little wrong when %DOME is appended, as this line is not counted */
708 static int _atomic_write_crossCorr_toplist_to_file( toplist_t *l, const char *filename, UINT4 *checksum, int write_done )
709 {
710  char *tempname;
711  INT4 length;
712  FILE *fpnew;
713  UINT4 s;
714 
715 #define TEMP_EXT ".tmp"
716  s = strlen( filename ) + strlen( TEMP_EXT ) + 1;
717  tempname = ( char * )malloc( s );
718  if ( !tempname ) {
719  LogPrintf( LOG_CRITICAL, "Could not allocate new filename\n" );
720  return ( -1 );
721  }
722  strcpy( tempname, filename );
723  strcat( tempname, TEMP_EXT );
724 
725  fpnew = fopen( tempname, "wb" );
726  if ( !fpnew ) {
727  LogPrintf( LOG_CRITICAL, "Failed to open temp CrossCorr file \"%s\" for writing: %d: %s\n",
728  tempname, errno, strerror( errno ) );
729 #ifdef _MSC_VER
730  LogPrintf( LOG_CRITICAL, "Windows system call returned: %d\n", _doserrno );
731 #endif
732  free( tempname );
733  return -1;
734  }
735  length = write_crossCorr_toplist_to_fp( l, fpnew, checksum );
736 
737  if ( ( write_done ) && ( length >= 0 ) ) {
738  int ret;
739  ret = fprintf( fpnew, "%%DONE\n" );
740  if ( ret < 0 ) {
741  length = ret;
742  } else {
743  length += ret;
744  }
745  }
746 
747  fclose( fpnew );
748 
749  if ( length < 0 ) {
750  LogPrintf( LOG_CRITICAL, "Failed to write temp CrossCorr file \"%s\": %d: %s\n",
751  tempname, errno, strerror( errno ) );
752 #ifdef _MSC_VER
753  LogPrintf( LOG_CRITICAL, "Windows system call returned: %d\n", _doserrno );
754 #endif
755  free( tempname );
756  return ( length );
757  }
758 
759  if ( rename( tempname, filename ) ) {
760  LogPrintf( LOG_CRITICAL, "Failed to rename CrossCorr file to \"%s\": %d: %s\n",
761  filename, errno, strerror( errno ) );
762 #ifdef _MSC_VER
763  LogPrintf( LOG_CRITICAL, "Windows system call returned: %d\n", _doserrno );
764 #endif
765  free( tempname );
766  return -1;
767  }
768 
769  free( tempname );
770  return length;
771 }
772 
773 
774 static int _atomic_write_crossCorrBinary_toplist_to_file( toplist_t *l, const char *filename, UINT4 *checksum, int write_done )
775 {
776  char *tempname;
777  INT4 length;
778  FILE *fpnew;
779  UINT4 s;
780 
781 #define TEMP_EXT ".tmp"
782  s = strlen( filename ) + strlen( TEMP_EXT ) + 1;
783  tempname = ( char * )malloc( s );
784  if ( !tempname ) {
785  LogPrintf( LOG_CRITICAL, "Could not allocate new filename\n" );
786  return ( -1 );
787  }
788  strcpy( tempname, filename );
789  strcat( tempname, TEMP_EXT );
790 
791  fpnew = fopen( tempname, "wb" );
792  if ( !fpnew ) {
793  LogPrintf( LOG_CRITICAL, "Failed to open temp CrossCorr file \"%s\" for writing: %d: %s\n",
794  tempname, errno, strerror( errno ) );
795 #ifdef _MSC_VER
796  LogPrintf( LOG_CRITICAL, "Windows system call returned: %d\n", _doserrno );
797 #endif
798  free( tempname );
799  return -1;
800  }
801  length = write_crossCorrBinary_toplist_to_fp( l, fpnew, checksum );
802 
803  if ( ( write_done ) && ( length >= 0 ) ) {
804  int ret;
805  ret = fprintf( fpnew, "%%DONE\n" );
806  if ( ret < 0 ) {
807  length = ret;
808  } else {
809  length += ret;
810  }
811  }
812 
813  fclose( fpnew );
814 
815  if ( length < 0 ) {
816  LogPrintf( LOG_CRITICAL, "Failed to write temp CrossCorr file \"%s\": %d: %s\n",
817  tempname, errno, strerror( errno ) );
818 #ifdef _MSC_VER
819  LogPrintf( LOG_CRITICAL, "Windows system call returned: %d\n", _doserrno );
820 #endif
821  free( tempname );
822  return ( length );
823  }
824 
825  if ( rename( tempname, filename ) ) {
826  LogPrintf( LOG_CRITICAL, "Failed to rename CrossCorr file to \"%s\": %d: %s\n",
827  filename, errno, strerror( errno ) );
828 #ifdef _MSC_VER
829  LogPrintf( LOG_CRITICAL, "Windows system call returned: %d\n", _doserrno );
830 #endif
831  free( tempname );
832  return -1;
833  }
834 
835  free( tempname );
836  return length;
837 }
838 
839 
840 
841 /* meant for the final writing of the toplist
842  - reduces toplist precision
843  - sorts the toplist
844  - then calls atomic_write_crossCorr_toplist_to_file() */
846 {
849  return ( atomic_write_crossCorr_toplist_to_file( l, filename, checksum ) );
850 }
851 
852 
854 {
858 }
859 
860 
861 /* New easier checkpointing - simply dump the whole toplist (plus a counter and
862  a checksum) into a binary file.
863  The heap structure array is hard to dump because it's based on pointers, so it
864  is restored after reding the data back in by sorting the list once.
865 */
866 
867 /** log an I/O error, i.e. source code line no., ferror, errno and strerror, and doserrno on Windows, too */
868 #ifndef __func__
869 #ifdef __FUNCTION__
870 #define __func__ __FUNCTION__
871 #else
872 #define __func__ ""
873 #endif
874 #endif
875 
876 #ifdef _WIN32
877 #define LOGIOERROR(mess,filename) \
878  LogPrintf(LOG_CRITICAL, "ERROR: %s %s: %s (%s:%d): doserr:%d, errno:%d: %s\n",\
879  mess,filename,__func__,__FILE__,__LINE__,_doserrno,errno,strerror(errno))
880 #else
881 #define LOGIOERROR(mess,filename) \
882  LogPrintf(LOG_CRITICAL, "ERROR: %s %s: %s (%s:%d): errno:%d: %s\n",\
883  mess,filename,__func__,__FILE__,__LINE__,errno,strerror(errno))
884 #endif
885 
886 /* dumps toplist to a temporary file, then renames the file to filename */
887 int write_cc_checkpoint( const char *filename, toplist_t *tl, UINT4 counter, BOOLEAN do_sync )
888 {
889 #define TMP_EXT ".tmp"
890  char *tmpfilename;
891  FILE *fp;
892  UINT4 len;
893  UINT4 checksum;
894  static UINT4 sync_fail_counter = 0;
895 
896  /* construct temporary filename */
897  len = strlen( filename ) + strlen( TMP_EXT ) + 1;
898  tmpfilename = LALCalloc( len, sizeof( char ) );
899  if ( !tmpfilename ) {
900  LogPrintf( LOG_CRITICAL, "Couldn't allocate tmpfilename\n" );
901  return ( -2 );
902  }
903  strcpy( tmpfilename, filename );
904  strcat( tmpfilename, TMP_EXT );
905 
906  /* calculate checksum */
907  checksum = 0;
908  for ( len = 0; len < sizeof( tl->elems ); len++ ) {
909  checksum += *( ( ( char * ) & ( tl->elems ) ) + len );
910  }
911  for ( len = 0; len < ( tl->elems * tl->size ); len++ ) {
912  checksum += *( ( ( char * )tl->data ) + len );
913  }
914  for ( len = 0; len < sizeof( counter ); len++ ) {
915  checksum += *( ( ( char * )&counter ) + len );
916  }
917 
918  /* open tempfile */
919  fp = fopen( tmpfilename, "wb" );
920  if ( !fp ) {
921  LOGIOERROR( "Couldn't open", tmpfilename );
922  return ( -1 );
923  }
924 
925  /* write number of elements */
926  len = fwrite( &( tl->elems ), sizeof( tl->elems ), 1, fp );
927  if ( len != 1 ) {
928  LOGIOERROR( "Couldn't write elems to", tmpfilename );
929  LogPrintf( LOG_CRITICAL, "fwrite() returned %d, length was %d\n", len, 1 );
930  if ( fclose( fp ) ) {
931  LOGIOERROR( "In addition: couldn't close", tmpfilename );
932  }
933  return ( -1 );
934  }
935 
936  /* write data */
937  len = fwrite( tl->data, tl->size, tl->elems, fp );
938  if ( len != tl->elems ) {
939  LOGIOERROR( "Couldn't write data to", tmpfilename );
940  LogPrintf( LOG_CRITICAL, "fwrite() returned %d, length was %zu\n", len, tl->elems );
941  if ( fclose( fp ) ) {
942  LOGIOERROR( "In addition: couldn't close", tmpfilename );
943  }
944  return ( -1 );
945  }
946 
947  /* write counter */
948  len = fwrite( &counter, sizeof( counter ), 1, fp );
949  if ( len != 1 ) {
950  LOGIOERROR( "Couldn't write counter to", tmpfilename );
951  LogPrintf( LOG_CRITICAL, "fwrite() returned %d, length was %d\n", len, 1 );
952  if ( fclose( fp ) ) {
953  LOGIOERROR( "In addition: couldn't close", tmpfilename );
954  }
955  return ( -1 );
956  }
957 
958  /* write checksum */
959  len = fwrite( &checksum, sizeof( checksum ), 1, fp );
960  if ( len != 1 ) {
961  LOGIOERROR( "Couldn't write checksum to", tmpfilename );
962  LogPrintf( LOG_CRITICAL, "fwrite() returned %d, length was %d\n", len, 1 );
963  if ( fclose( fp ) ) {
964  LOGIOERROR( "In addition: couldn't close", tmpfilename );
965  }
966  return ( -1 );
967  }
968 
969  if ( do_sync && ( sync_fail_counter < SYNC_FAIL_LIMIT ) ) {
970  /* make sure the data ends up on disk */
971  if ( fsync( fileno( fp ) ) ) {
972  LOGIOERROR( "Couldn't sync", tmpfilename );
973  sync_fail_counter++;
974  if ( sync_fail_counter >= SYNC_FAIL_LIMIT ) {
975  LogPrintf( LOG_NORMAL, "WARNING: syncing disabled\n" );
976  }
977  } else {
978  sync_fail_counter = 0;
979  }
980  }
981 
982  /* close tempfile */
983  if ( fclose( fp ) ) {
984  LOGIOERROR( "Couldn't close", tmpfilename );
985  return ( -1 );
986  }
987 
988  /* rename to filename */
989  if ( rename( tmpfilename, filename ) ) {
990  LOGIOERROR( "Couldn't rename\n", tmpfilename );
991  return ( -1 );
992  }
993 
994  /* all went well */
995  return ( 0 );
996 }
997 
998 
999 int read_cc_checkpoint( const char *filename, toplist_t *tl, UINT4 *counter )
1000 {
1001  FILE *fp;
1002  UINT4 len;
1003  UINT4 checksum;
1004 
1005  /* counter should be 0 if we couldn't read a checkpoint */
1006  *counter = 0;
1007 
1008  /* try to open file */
1009  fp = fopen( filename, "rb" );
1010  if ( !fp ) {
1011  if ( errno == ENOENT ) {
1012  LogPrintf( LOG_NORMAL, "INFO: No checkpoint %s found - starting from scratch\n", filename );
1013  clear_toplist( tl );
1014  return ( 1 );
1015  } else {
1016  LOGIOERROR( "Checkpoint found but couldn't open", filename );
1017  clear_toplist( tl );
1018  return ( -1 );
1019  }
1020  }
1021 
1022  /* read number of elements */
1023  len = fread( &( tl->elems ), sizeof( tl->elems ), 1, fp );
1024  if ( len != 1 ) {
1025  LOGIOERROR( "Couldn't read elems from", filename );
1026  LogPrintf( LOG_CRITICAL, "fread() returned %d, length was %d\n", len, 1 );
1027  if ( fclose( fp ) ) {
1028  LOGIOERROR( "In addition: couldn't close", filename );
1029  }
1030  return ( -1 );
1031  }
1032  /* sanity check */
1033  if ( tl->elems > tl->length ) {
1035  "Number of elements read larger than length of toplist: %zu > %zu\n",
1036  tl->elems, tl->length );
1037  if ( fclose( fp ) ) {
1038  LOGIOERROR( "In addition: couldn't close", filename );
1039  }
1040  return ( -2 );
1041  }
1042 
1043  /* read data */
1044  len = fread( tl->data, tl->size, tl->elems, fp );
1045  if ( len != tl->elems ) {
1046  LOGIOERROR( "Couldn't read data from", filename );
1047  LogPrintf( LOG_CRITICAL, "fread() returned %d, length was %zu\n", len, tl->elems );
1048  if ( fclose( fp ) ) {
1049  LOGIOERROR( "In addition: couldn't close", filename );
1050  }
1051  clear_toplist( tl );
1052  return ( -1 );
1053  }
1054 
1055  /* read counter */
1056  len = fread( counter, sizeof( *counter ), 1, fp );
1057  if ( len != 1 ) {
1058  LOGIOERROR( "Couldn't read counter from", filename );
1059  LogPrintf( LOG_CRITICAL, "fread() returned %d, length was %d\n", len, 1 );
1060  if ( fclose( fp ) ) {
1061  LOGIOERROR( "In addition: couldn't close", filename );
1062  }
1063  clear_toplist( tl );
1064  return ( -1 );
1065  }
1066 
1067  /* read checksum */
1068  len = fread( &checksum, sizeof( checksum ), 1, fp );
1069  if ( len != 1 ) {
1070  LOGIOERROR( "Couldn't read checksum to", filename );
1071  LogPrintf( LOG_CRITICAL, "fread() returned %d, length was %d\n", len, 1 );
1072  if ( fclose( fp ) ) {
1073  LOGIOERROR( "In addition: couldn't close", filename );
1074  }
1075  clear_toplist( tl );
1076  return ( -1 );
1077  }
1078 
1079  /* close file */
1080  if ( fclose( fp ) ) {
1081  LOGIOERROR( "Couldn't close", filename );
1082  clear_toplist( tl );
1083  return ( -1 );
1084  }
1085 
1086  /* verify checksum */
1087  for ( len = 0; len < sizeof( tl->elems ); len++ ) {
1088  checksum -= *( ( ( char * ) & ( tl->elems ) ) + len );
1089  }
1090  for ( len = 0; len < ( tl->elems * tl->size ); len++ ) {
1091  checksum -= *( ( ( char * )tl->data ) + len );
1092  }
1093  for ( len = 0; len < sizeof( *counter ); len++ ) {
1094  checksum -= *( ( ( char * )counter ) + len );
1095  }
1096  if ( checksum ) {
1097  LogPrintf( LOG_CRITICAL, "Checksum error: %d\n", checksum );
1098  clear_toplist( tl );
1099  return ( -2 );
1100  }
1101 
1102  /* restore Heap structure by sorting */
1103  for ( len = 0; len < tl->elems; len++ ) {
1104  tl->heap[len] = tl->data + len * tl->size;
1105  }
1107 
1108  /* all went well */
1109  LogPrintf( LOG_DEBUG, "Successfully read checkpoint\n" );
1110 
1111  return ( 0 );
1112 }
1113 
1114 
1115 int write_cc_output( const char *filename, toplist_t *tl )
1116 {
1117  /* reduce the precision of the calculated values before doing the sort to
1118  the precision we will write the result with. This should ensure a sorting
1119  order that looks right to the validator, too */
1121  sort_crossCorr_toplist( tl );
1122  return ( _atomic_write_crossCorr_toplist_to_file( tl, filename, NULL, 1 ) );
1123 }
void sort_crossCorrBinary_toplist(toplist_t *l)
static int crossCorr_toplist_qsort_function(const void *a, const void *b)
int write_crossCorr_toplist_item_to_fp(CrossCorrOutputEntry fline, FILE *fp, UINT4 *checksum)
File IO.
static void reduce_crossCorrline_precision(void *line)
static void reduce_crossCorrBinary_toplist_precision(toplist_t *l)
int final_write_crossCorr_toplist_to_file(toplist_t *l, const char *filename, UINT4 *checksum)
meant for the final writing of the toplist
static int crossCorrBinary_toplist_qsort_function(const void *a, const void *b)
static void reduce_crossCorr_toplist_precision(toplist_t *l)
int write_cc_checkpoint(const char *filename, toplist_t *tl, UINT4 counter, BOOLEAN do_sync)
writes a checkpoint:
int atomic_write_crossCorr_toplist_to_file(toplist_t *l, const char *filename, UINT4 *checksum)
writes the given toplitst to a temporary file, then renames the temporary file to filename.
void sort_crossCorr_toplist(toplist_t *l)
reads a (created!) toplist from an open filepointer sets the checksum if non-NULL reads maximum maxby...
#define TEMP_EXT
int atomic_write_crossCorrBinary_toplist_to_file(toplist_t *l, const char *filename, UINT4 *checksum)
int write_crossCorrBinary_toplist_item_to_fp(CrossCorrBinaryOutputEntry fline, FILE *fp, UINT4 *checksum)
int write_crossCorr_toplist_to_fp(toplist_t *tl, FILE *fp, UINT4 *checksum)
Writes the toplist to an (already open) filepointer Returns the number of written charactes sets the ...
static int _atomic_write_crossCorrBinary_toplist_to_file(toplist_t *l, const char *filename, UINT4 *checksum, int write_done)
int finite(double)
void free_crossCorr_toplist(toplist_t **l)
frees the space occupied by the toplist
static int print_crossCorrBinaryline_to_str(CrossCorrBinaryOutputEntry fline, char *buf, int buflen)
int final_write_crossCorrBinary_toplist_to_file(toplist_t *l, const char *filename, UINT4 *checksum)
int create_crossCorr_toplist(toplist_t **tl, UINT8 length)
creates a toplist with length elements, returns -1 on error (usually out of memory),...
int create_crossCorrBinary_toplist(toplist_t **tl, UINT8 length)
static int crossCorrBinary_smaller(const void *a, const void *b)
static void reduce_crossCorrBinaryline_precision(void *line)
static int _atomic_write_crossCorr_toplist_to_file(toplist_t *l, const char *filename, UINT4 *checksum, int write_done)
int write_cc_output(const char *filename, toplist_t *tl)
write the final output file:
int insert_into_crossCorrBinary_toplist(toplist_t *tl, CrossCorrBinaryOutputEntry elem)
static int crossCorr_smaller(const void *a, const void *b)
#define TMP_EXT
static int print_crossCorrline_to_str(CrossCorrOutputEntry fline, char *buf, int buflen)
int read_cc_checkpoint(const char *filename, toplist_t *tl, UINT4 *counter)
tries to read a checkpoint
int insert_into_crossCorr_toplist(toplist_t *tl, CrossCorrOutputEntry elem)
Inserts an element in to the toplist either if there is space left or the element is larger than the ...
#define SYNC_FAIL_LIMIT
#define LOGIOERROR(mess, filename)
int write_crossCorrBinary_toplist_to_fp(toplist_t *tl, FILE *fp, UINT4 *checksum)
int create_toplist(toplist_t **list, size_t length, size_t size, int(*smaller)(const void *, const void *))
Definition: HeapToplist.c:101
void free_toplist(toplist_t **list)
Definition: HeapToplist.c:139
void qsort_toplist(toplist_t *list, int(*compare)(const void *, const void *))
Definition: HeapToplist.c:241
void qsort_toplist_r(toplist_t *list, int(*compare)(const void *, const void *))
Definition: HeapToplist.c:249
int insert_into_toplist(toplist_t *list, void *element)
Definition: HeapToplist.c:151
void go_through_toplist(toplist_t *list, void(*handle)(void *))
Definition: HeapToplist.c:177
void clear_toplist(toplist_t *list)
Definition: HeapToplist.c:132
#define LALCalloc(m, n)
#define c
#define fprintf
int s
int l
unsigned char BOOLEAN
uint64_t UINT8
#define XLAL_LAST_ELEM(x)
int64_t INT8
uint32_t UINT4
int32_t INT4
#define LAL_REAL8_FORMAT
void LogPrintf(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
LOG_CRITICAL
LOG_DEBUG
LOG_NORMAL
static const INT4 r
static const INT4 a
Type to hold the fields that will be kept in a "toplist" – for a directed binary search.
REAL8 ecc
eccentricity
REAL8 argp
argument of periapse
REAL8 estSens
average template E[rho]/h0^2)^2
REAL8 period
bperiod
REAL8 evSquared
E[rho]/h0^2)^2.
REAL8 tp
time of periapse passage
REAL8 rho
Crosscorr statistic.
REAL8 freq
Frequency.
REAL8 asini
projected semi-major axis
Type to hold the fields that will be kept in a "toplist"
REAL8 Q1
Q1.
REAL8 BrakingIndex
braking index
REAL8 Freq
Frequency.
REAL8 Rho
Crosscorr statistic.
REAL8 Q2
Q2.
REAL8 Delta
skyposition: latitude
REAL8 Alpha
Skyposition: longitude in equatorial coords, radians.
char ** heap
Definition: HeapToplist.h:40
size_t length
Definition: HeapToplist.h:36
size_t elems
Definition: HeapToplist.h:37
size_t size
Definition: HeapToplist.h:38
char * data
Definition: HeapToplist.h:39