202#define TWODMESHTESTC_ENORM 0
203#define TWODMESHTESTC_ESUB 1
204#define TWODMESHTESTC_EARG 2
205#define TWODMESHTESTC_EBAD 3
206#define TWODMESHTESTC_EMEM 4
207#define TWODMESHTESTC_EFILE 5
208#define TWODMESHTESTC_EMETRIC 6
210#define TWODMESHTESTC_MSGENORM "Normal exit"
211#define TWODMESHTESTC_MSGESUB "Subroutine failed"
212#define TWODMESHTESTC_MSGEARG "Error parsing arguments"
213#define TWODMESHTESTC_MSGEBAD "Bad argument value"
214#define TWODMESHTESTC_MSGEMEM "Memory allocation error"
215#define TWODMESHTESTC_MSGEFILE "Could not open file"
216#define TWODMESHTESTC_MSGEMETRIC "Axis length is zero or negative within specified region"
221#include <lal/LALStdio.h>
222#include <lal/FileIO.h>
223#include <lal/LALStdlib.h>
224#include <lal/LALConstants.h>
225#include <lal/StreamInput.h>
226#include <lal/TwoDMesh.h>
236#define A_DEFAULT (0.1)
237#define B_DEFAULT (0.05)
238#define C_DEFAULT (1.0)
245#define MISMATCH (1.0)
248#define USAGE "Usage: %s [-o outfile] [-p psfile flags] [-d debug]\n" \
249"\t[-m mismatch nmax cmax] [-b x1 y1 x2 y2 ] [-e a b c]\n" \
250"\t[-x dadx dbdx dcdx] [-y dady dbdy dcdy]\n"
253#define ERROR( code, msg, statement ) \
254if ( lalDebugLevel & LALERROR ) \
256 XLALPrintError( "Error[0] %d: program %s, file %s, line %d, %s\n" \
257 " %s %s\n", (code), *argv, __FILE__, \
258 __LINE__, "$Id$", statement ? statement : \
263#define INFO( statement ) \
264if ( lalDebugLevel & LALINFO ) \
266 XLALPrintError( "Info[0]: program %s, file %s, line %d, %s\n" \
267 " %s\n", *argv, __FILE__, __LINE__, \
268 "$Id$", (statement) ); \
272#define SUB( func, statusptr ) \
273if ( (func), (statusptr)->statusCode ) \
275 ERROR( TWODMESHTESTC_ESUB, TWODMESHTESTC_MSGESUB, \
276 "Function call \"" #func "\" failed:" ); \
277 return TWODMESHTESTC_ESUB; \
292main(
int argc,
char **argv )
296 REAL4 rangeParams[4];
297 REAL4 metricParams[9];
307 REAL4 x_1 = X1, y_1 = Y1, x_2 = X2, y_2 = Y2;
308 REAL4 a = A_DEFAULT, b = B_DEFAULT,
c = C_DEFAULT;
309 REAL4 dadx = DADX, dbdx = DBDX, dcdx = DCDX;
310 REAL4 dady = DADY, dbdy = DBDY, dcdy = DCDY;
319 while ( arg < argc ) {
321 if ( !strcmp( argv[arg],
"-o" ) ) {
322 if ( argc > arg + 1 ) {
332 else if ( !strcmp( argv[arg],
"-p" ) ) {
333 if ( argc > arg + 2 ) {
335 psfile = argv[arg++];
336 flags = atoi( argv[arg++] );
344 else if ( !strcmp( argv[arg],
"-d" ) ) {
345 if ( argc > arg + 1 ) {
354 else if ( !strcmp( argv[arg],
"-m" ) ) {
355 if ( argc > arg + 2 ) {
357 nmax = atoi( argv[arg++] );
358 cmax = atoi( argv[arg++] );
367 else if ( !strcmp( argv[arg],
"-b" ) ) {
368 if ( argc > arg + 4 ) {
370 x_1 = atof( argv[arg++] );
371 y_1 = atof( argv[arg++] );
372 x_2 = atof( argv[arg++] );
373 y_2 = atof( argv[arg++] );
381 else if ( !strcmp( argv[arg],
"-e" ) ) {
382 if ( argc > arg + 3 ) {
384 a = atof( argv[arg++] );
385 b = atof( argv[arg++] );
386 c = atof( argv[arg++] );
394 else if ( !strcmp( argv[arg],
"-x" ) ) {
395 if ( argc > arg + 3 ) {
397 dadx = atof( argv[arg++] );
398 dbdx = atof( argv[arg++] );
399 dcdx = atof( argv[arg++] );
407 else if ( !strcmp( argv[arg],
"-y" ) ) {
408 if ( argc > arg + 3 ) {
410 dady = atof( argv[arg++] );
411 dbdy = atof( argv[arg++] );
412 dcdy = atof( argv[arg++] );
420 else if ( argv[arg][0] ==
'-' ) {
432 REAL4 axisMin, axisTemp;
435 if ( ( x_1 == 0.0 ) && ( x_2 == 0.0 ) ) {
441 rangeParams[0] = x_1;
442 rangeParams[1] = y_1;
443 rangeParams[2] = x_2;
444 rangeParams[3] = y_2;
446 rangeParams[0] = x_2;
447 rangeParams[1] = y_2;
448 rangeParams[2] = x_1;
449 rangeParams[3] = y_1;
451 params.getRange = LALRangeTest;
452 params.rangeParams = (
void * )( rangeParams );
453 if ( x_1 * x_2 <= 0.0 ) {
473 axisTemp =
a + dadx * x_1 + dady * y_1;
474 if ( axisTemp < axisMin ) {
477 axisTemp =
a + dadx * x_2 + dady * y_2;
478 if ( axisTemp < axisMin ) {
481 axisTemp =
a + dadx * ( x_1 + x_2 ) + dady * ( y_1 + y_2 );
482 if ( axisTemp < axisMin ) {
485 if ( axisMin <= 0.0 ) {
491 if ( axisTemp < axisMin ) {
494 axisTemp = b + dbdx * x_1 + dbdy * y_1;
495 if ( axisTemp < axisMin ) {
498 axisTemp = b + dbdx * x_2 + dbdy * y_2;
499 if ( axisTemp < axisMin ) {
502 axisTemp = b + dbdx * ( x_1 + x_2 ) + dbdy * ( y_1 + y_2 );
503 if ( axisTemp < axisMin ) {
506 if ( axisMin <= 0.0 ) {
516 metricParams[3] = dadx;
517 metricParams[4] = dbdx;
518 metricParams[5] = dcdx;
519 metricParams[6] = dady;
520 metricParams[7] = dbdy;
521 metricParams[8] = dcdy;
522 params.getMetric = LALMetricTest;
523 params.metricParams = (
void * )( metricParams );
533 params.widthRetryFac = 0.0;
550 for ( here = mesh; here; here = here->
next )
552 here->
dy[0], here->
dy[1] );
557 if ( psfile && flags ) {
558 FILE *
fp = fopen( psfile,
"w" );
559 INT2 plotPoints = flags & 1;
561 BOOLEAN plotEllipses = flags & 4;
575 REAL4 xSum = x_1 + x_2, xDiff = x_2 - x_1;
576 REAL4 ySum = y_1 + y_2, yDiff = y_2 - y_1;
579 if ( xSum * xSum + ySum * ySum >= xDiff * xDiff + yDiff * yDiff ) {
585 while ( theta2 < -180.0 ) {
588 while ( theta2 > 180.0 ) {
591 if ( theta2 > 90.0 ) {
593 }
else if ( ( -90.0 < theta2 ) && ( theta2 < 0.0 ) ) {
597 while ( theta2 < -180.0 ) {
600 while ( theta2 > 180.0 ) {
603 if ( theta2 > 90.0 ) {
605 }
else if ( ( -90.0 < theta2 ) && ( theta2 < 0.0 ) ) {
613 plotParams.
bBox[0] = 36.0;
614 plotParams.
bBox[1] = 36.0;
615 plotParams.
bBox[2] = 576.0;
616 plotParams.
bBox[3] = 756.0;
655 if ( xy[0] == 0.0 ) {
656 ya = xy[3] * (
x / xy[2] );
658 }
else if ( xy[2] == 0.0 ) {
659 ya = xy[1] * (
x / xy[0] );
665 else if ( ( xy[0] > 0.0 ) || ( xy[2] < 0.0 ) ) {
666 if ( fabs(
x ) < fabs( xy[0] ) ) {
667 ya = xy[1] * (
x / xy[0] );
669 ya = xy[1] + xy[3] * ( (
x - xy[0] ) / xy[2] );
671 if ( fabs(
x ) < fabs( xy[2] ) ) {
672 yb = xy[3] * (
x / xy[2] );
674 yb = xy[3] + xy[1] * ( (
x - xy[2] ) / xy[0] );
682 ya = xy[1] * (
x / xy[0] );
684 ya = xy[3] * (
x / xy[2] );
686 if (
x - xy[0] - xy[2] < 0.0 ) {
687 yb = xy[1] + xy[3] * ( (
x - xy[0] ) / xy[2] );
689 yb = xy[3] + xy[1] * ( (
x - xy[2] ) / xy[0] );
722 a = abc[0] + position[0] * abc[3] + position[1] * abc[6];
723 b = abc[1] + position[0] * abc[4] + position[1] * abc[7];
724 c = abc[2] + position[0] * abc[5] + position[1] * abc[8];
725 if (
a * b == 0.0 ) {
#define SUB(func, statusptr)
#define ERROR(code, msg, statement)
#define MISMATCH
Default for metric grid maximal mismatch value.
void LALCheckMemoryLeaks(void)
#define ABORT(statusptr, code, mesg)
#define ASSERT(assertion, statusptr, code, mesg)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define TWODMESHTESTC_MSGEARG
#define TWODMESHTESTC_MSGENORM
#define TWODMESHTESTC_EMETRIC
#define TWODMESHTESTC_EBAD
#define TWODMESHTESTC_ENORM
#define TWODMESHTESTC_EFILE
#define TWODMESHTESTC_MSGEMETRIC
#define TWODMESHTESTC_MSGEBAD
#define TWODMESHTESTC_EARG
#define TWODMESHTESTC_MSGEFILE
int main(int argc, char **argv)
#define TWODMESHH_MSGENUL
void LALCreateTwoDMesh(LALStatus *stat, TwoDMeshNode **mesh, TwoDMeshParamStruc *params)
void LALDestroyTwoDMesh(LALStatus *stat, TwoDMeshNode **mesh, UINT4 *nFree)
#define TWODMESHPLOTH_XSIZE
Horizontal size of plotting area (points = )
#define TWODMESHPLOTH_YSIZE
Vertical size of plotting area (points)
void LALPlotTwoDMesh(LALStatus *stat, FILE *stream, TwoDMeshNode *mesh, TwoDMeshPlotStruc *params)
Plots a hierarchical mesh of templates on an 2-dimensional parameter space.
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
This structure represents a single node in a linked list of mesh points, specified in the coordinate ...
struct tagTwoDMeshNode * next
The next mesh point in the linked list; NULL if this is the tail.
REAL4 dx
The half-width of the tile centred on the mesh point.
REAL4 dy[2]
The heights of the two right-hand corners of the tile, relative to the mesh point.
REAL4 y
The coordinates of the mesh point.
This structure stores the parameters required by the two-dimensional mesh placement functions.
This structure stores parameters specifying how to plot a PostScript diagram of the parameter mesh.
REAL4 theta
Angle from the horizontal direction of the plot counterclockwise to the -coordinate axis of the mesh...
REAL4 yScale
Plotting scale of the mesh coordinate axes, in points per unit or (a point is 1/72 of an inch)
UINT4 nLevels
The number of levels of recursive submeshes to plot.
INT2 * plotPoints
An array from [0] to [nLevels] indicating how to plot the mesh points at each recursive level: a valu...
BOOLEAN * plotTiles
An array from [0] to [nLevels] indicating whether to plot the tiles around each mesh point,...
BOOLEAN autoscale
If true, xScale and yScale will be adjusted so that the drawn figure will lie within the bBox.
REAL4 bBox[4]
Bounding box surrounding the figure in plot coordinates, measured in points.
REAL4 clipBox[4]
Four components , , , (in that order) specifying the corners of a box in the - coordinate syste...
BOOLEAN * plotEllipses
An array from [0] to [nLevels] indicating whether to plot the mismatch ellipses around each mesh poin...
TwoDMeshParamStruc * params
An array from [0] to [nLevels] of parameter structures used to generate the meshes at each recursive ...
UINT4 nBoundary
half the number of points to plot along the boundary of the parameter region; at least 4 points are r...