87#define DETINVERSETESTC_ENORM 0
88#define DETINVERSETESTC_ESUB 1
89#define DETINVERSETESTC_EARG 2
90#define DETINVERSETESTC_EMEM 3
91#define DETINVERSETESTC_EFILE 4
92#define DETINVERSETESTC_EFMT 5
99#define DETINVERSETESTC_MSGENORM "Normal exit"
100#define DETINVERSETESTC_MSGESUB "Subroutine failed"
101#define DETINVERSETESTC_MSGEARG "Error parsing arguments"
102#define DETINVERSETESTC_MSGEMEM "Out of memory"
103#define DETINVERSETESTC_MSGEFILE "Could not open file"
104#define DETINVERSETESTC_MSGEFMT "Bad input file format"
110#include <lal/LALStdio.h>
111#include <lal/LALStdlib.h>
112#include <lal/AVFactories.h>
113#include <lal/StreamInput.h>
114#include <lal/Random.h>
115#include <lal/MatrixUtils.h>
121#define USAGE "Usage: %s [-n size | -i infile] [-o outfile]\n" \
122"\t[-v] [-t] [-s] [-d debuglevel]\n"
125#define ERROR( code, msg, statement ) \
127if ( lalDebugLevel & LALERROR ) \
129 LALPrintError( "Error[0] %d: program %s, file %s, line %d, %s\n" \
130 " %s %s\n", (code), *argv, __FILE__, \
131 __LINE__, "$Id$", statement ? \
132 statement : "", (msg) ); \
136#define INFO( statement ) \
138if ( lalDebugLevel & LALINFO ) \
140 LALPrintError( "Info[0]: program %s, file %s, line %d, %s\n" \
141 " %s\n", *argv, __FILE__, __LINE__, \
142 "$Id$", (statement) ); \
146#define WARNING( statement ) \
148if ( lalDebugLevel & LALWARNING ) \
150 LALPrintError( "Warning[0]: program %s, file %s, line %d, %s\n" \
151 " %s\n", *argv, __FILE__, __LINE__, \
152 "$Id$", (statement) ); \
156#define SUB( func, statusptr ) \
158if ( (func), (statusptr)->statusCode ) \
160 ERROR( DETINVERSETESTC_ESUB, DETINVERSETESTC_MSGESUB, \
161 "Function call \"" #func "\" failed:" ); \
162 return DETINVERSETESTC_ESUB; \
167main(
int argc,
char **argv )
173 CHAR *outfile = NULL;
185 clock_t start = 0, stop = 0;
194 while ( arg < argc ) {
197 if ( !strcmp( argv[arg],
"-n" ) ) {
198 if ( argc > arg + 1 ) {
200 n = atoi( argv[arg++] );
209 else if ( !strcmp( argv[arg],
"-i" ) ) {
210 if ( argc > arg + 1 ) {
212 infile = argv[arg++];
221 else if ( !strcmp( argv[arg],
"-o" ) ) {
222 if ( argc > arg + 1 ) {
224 outfile = argv[arg++];
233 else if ( !strcmp( argv[arg],
"-v" ) ) {
237 else if ( !strcmp( argv[arg],
"-s" ) ) {
241 else if ( !strcmp( argv[arg],
"-t" ) ) {
247 else if ( !strcmp( argv[arg],
"-d" ) ) {
248 if ( argc > arg + 1 ) {
272 dimLength.
data = dims;
278 if ( !strcmp( infile,
"stdin" ) )
280 else if ( !(
fp = fopen( infile,
"r" ) ) ) {
292 }
while ( ( n = vec->
length ) == 0 );
293 dimLength.
data[0] = dimLength.
data[1] = n;
295 for ( j = 0; j < n; j++ )
300 for ( i = 1; i < n; i++ ) {
306 for ( j = 0; j < n; j++ )
307 sMatrix->
data[i*n+j] = vec->
data[j];
319 }
while ( ( n = vec->
length ) == 0 );
320 dimLength.
data[0] = dimLength.
data[1] = n;
322 for ( j = 0; j < n; j++ )
327 for ( i = 1; i < n; i++ ) {
333 for ( j = 0; j < n; j++ )
334 dMatrix->
data[i*n+j] = vec->
data[j];
344 dimLength.
data[0] = dimLength.
data[1] = n;
349 for ( i = 0; i < n; i++ ) {
350 for ( j = 0; j < n; j++ ) {
359 for ( i = 0; i < n; i++ ) {
360 for ( j = 0; j < n; j++ ) {
373 if ( !strcmp( outfile,
"stdout" ) )
375 else if ( !strcmp( outfile,
"stderr" ) )
377 else if ( !(
fp = fopen( outfile,
"r" ) ) ) {
384 for ( i = 0; i < n; i++ ) {
386 for ( j = 1; j < n; j++ )
394 for ( i = 0; i < n; i++ ) {
396 for ( j = 1; j < n; j++ )
433 fprintf( stderr,
"Elapsed time: %.2f s\n",
434 (
double)( stop - start )/CLOCKS_PER_SEC );
451 for ( i = 0; i < n; i++ ) {
453 for ( j = 1; j < n; j++ )
458 for ( i = 0; i < n; i++ ) {
460 for ( j = 1; j < n; j++ )
468 if (
fp != stdout &&
fp != stderr )
485 INFO( DETINVERSETESTC_MSGENORM );
#define DETINVERSETESTC_EARG
Error parsing arguments.
#define DETINVERSETESTC_EFMT
Bad input file format.
#define DETINVERSETESTC_ENORM
Normal exit.
#define DETINVERSETESTC_EFILE
Could not open file.
void LALCheckMemoryLeaks(void)
#define SUB(func, statusptr)
#define ERROR(code, msg, statement)
int main(int argc, char *argv[])
void LALSCreateArray(LALStatus *, REAL4Array **, UINT4Vector *)
void LALDCreateArray(LALStatus *, REAL8Array **, UINT4Vector *)
void LALSDestroyArray(LALStatus *, REAL4Array **)
void LALDDestroyArray(LALStatus *, REAL8Array **)
void LALDMatrixInverse(LALStatus *stat, REAL8 *det, REAL8Array *matrix, REAL8Array *inverse)
void LALDMatrixDeterminant(LALStatus *stat, REAL8 *det, REAL8Array *matrix)
void LALSMatrixInverse(LALStatus *stat, REAL4 *det, REAL4Array *matrix, REAL4Array *inverse)
unsigned char BOOLEAN
Boolean logical type, see Headers LAL(Atomic)Datatypes.h for more details.
double REAL8
Double precision real floating-point number (8 bytes).
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint32_t UINT4
Four-byte unsigned integer.
float REAL4
Single precision real floating-point number (4 bytes).
int LALPrintError(const char *fmt,...)
RandomParams * XLALCreateRandomParams(INT4 seed)
REAL4 XLALUniformDeviate(RandomParams *params)
void XLALDestroyRandomParams(RandomParams *params)
void LALDDestroyVector(LALStatus *, REAL8Vector **)
void LALSDestroyVector(LALStatus *, REAL4Vector **)
LAL status structure, see The LALStatus structure for more details.
Multidimentional array of REAL4, see DATATYPE-Array types for more details.
REAL4 * data
Pointer to the data array.
Vector of type REAL4, see DATATYPE-Vector types for more details.
REAL4 * data
Pointer to the data array.
UINT4 length
Number of elements in array.
Multidimentional array of REAL8, see DATATYPE-Array types for more details.
REAL8 * data
Pointer to the data array.
Vector of type REAL8, see DATATYPE-Vector types for more details.
REAL8 * data
Pointer to the data array.
UINT4 length
Number of elements in array.
This structure contains the parameters necessary for generating the current sequence of random number...
Vector of type UINT4, see DATATYPE-Vector types for more details.
UINT4 length
Number of elements in array.
UINT4 * data
Pointer to the data array.