Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
RngMedBiasTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Badri Krishnan, Jolien Creighton
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/*-----------------------------------------------------------------------
21 *
22 * File Name: RngMedBiasTest.c
23 * Authors: Krishnan, B., Itoh, Y.,
24 *
25 *
26 * History: Created by Krishnan Mar 2, 2004
27 * Modified...
28 *
29 *-----------------------------------------------------------------------
30 */
31
32#include <lal/RngMedBias.h>
33
34/* Error codes and messages */
35
36#define RNGMEDBIASTESTC_ENORM 0
37#define RNGMEDBIASTESTC_ESUB 1
38#define RNGMEDBIASTESTC_EARG 2
39#define RNGMEDBIASTESTC_EBAD 3
40#define RNGMEDBIASTESTC_EFILE 4
41
42#define RNGMEDBIASTESTC_MSGENORM "Normal exit"
43#define RNGMEDBIASTESTC_MSGESUB "Subroutine failed"
44#define RNGMEDBIASTESTC_MSGEARG "Error parsing arguments"
45#define RNGMEDBIASTESTC_MSGEBAD "Bad argument values"
46#define RNGMEDBIASTESTC_MSGEFILE "Could not create output file"
47
48
49/* Default parameters. */
50
51/* Usage format string. */
52
53#define USAGE "Usage: %s [-d debuglevel] [-b block size] \n"
54
55
56/*********************************************************************/
57/* Macros for printing errors & testing subroutines (from Creighton) */
58/*********************************************************************/
59
60#define ERROR( code, msg, statement ) \
61do { \
62 if ( lalDebugLevel & LALERROR ) \
63 LALPrintError( "Error[0] %d: program %s, file %s, line %d, %s\n" \
64 " %s %s\n", (code), *argv, __FILE__, \
65 __LINE__, "$Id$", statement ? statement : \
66 "", (msg) ); \
67} while (0)
68
69#define INFO( statement ) \
70do { \
71 if ( lalDebugLevel & LALINFO ) \
72 LALPrintError( "Info[0]: program %s, file %s, line %d, %s\n" \
73 " %s\n", *argv, __FILE__, __LINE__, \
74 "$Id$", (statement) ); \
75} while (0)
76
77#define SUB( func, statusptr ) \
78do { \
79 if ( (func), (statusptr)->statusCode ) { \
80 ERROR( RNGMEDBIASTESTC_ESUB, RNGMEDBIASTESTC_MSGESUB, \
81 "Function call \"" #func "\" failed:" ); \
82 return RNGMEDBIASTESTC_ESUB; \
83 } \
84} while (0)
85/******************************************************************/
86
87/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
88/* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv------------------------------------ */
89int main(int argc, char *argv[]){
90 static LALStatus status; /* LALStatus pointer */
91 INT4 arg, blkSize; /* Argument counter */
92 REAL8 bias;
93
94 /* default values */
95 blkSize=7;
96 /********************************************************/
97 /* Parse argument list. i stores the current position. */
98 /********************************************************/
99 arg = 1;
100 while ( arg < argc ) {
101 /* Parse debuglevel option. */
102 if ( !strcmp( argv[arg], "-d" ) ) {
103 if ( argc > arg + 1 ) {
104 arg++;
105 } else {
107 LALPrintError( USAGE, *argv );
109 }
110 }
111 else if ( !strcmp( argv[arg], "-b" ) ) {
112 if ( argc > arg + 1 ) {
113 arg++;
114 blkSize = atof(argv[arg++]);
115 } else {
117 LALPrintError( USAGE, *argv );
119 }
120 }
121 /* Unrecognized option. */
122 else {
124 LALPrintError( USAGE, *argv );
126 }
127 } /* End of argument parsing loop. */
128 /******************************************************************/
129
130
131
132 SUB( LALRngMedBias( &status, &bias, blkSize), &status);
133
134 printf("The correction factor for block size %d is: %1.15lf\n", blkSize, bias);
135
138}
139
140/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
int main(int argc, char *argv[])
#define SUB(func, statusptr)
#define USAGE
#define RNGMEDBIASTESTC_MSGENORM
#define ERROR(code, msg, statement)
#define INFO(statement)
#define RNGMEDBIASTESTC_ENORM
#define RNGMEDBIASTESTC_EARG
#define RNGMEDBIASTESTC_MSGEARG
double REAL8
Double precision real floating-point number (8 bytes).
int32_t INT4
Four-byte signed integer.
int LALPrintError(const char *fmt,...)
Definition: LALError.c:46
void LALRngMedBias(LALStatus *status, REAL8 *biasFactor, INT4 blkSize)
Definition: RngMedBias.c:87
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947