Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
TwoDMesh.h
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Jolien Creighton, Reinhard Prix, Teviet 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#ifndef _TWODMESH_H
21#define _TWODMESH_H
22
23#include <lal/LALStdlib.h>
24
25#if defined(__cplusplus)
26extern "C" {
27#elif 0
28} /* so that editors will match preceding brace */
29#endif
30
31/**
32 * \author Creighton, T. D.
33 * \defgroup TwoDMesh_h Header TwoDMesh.h
34 * \ingroup lalpulsar_templbank
35 * \brief Provides routines to place search meshes for two-dimensional parameter spaces with varying metric.
36 *
37 * ### Synopsis ###
38 *
39 * \code
40 * #include <lal/TwoDMesh.h>
41 * \endcode
42 *
43 * This header covers routines that lay out a mesh of points on
44 * an 2-dimensional parameter space \f$ \{(x,y)\} \f$ , placed such that no
45 * point in the space lies further than some maximum proper distance
46 * \f$ m_\mathrm{thresh} \f$ from a mesh point.
47 *
48 * The intended purpose of these routines is to place a set of ``target''
49 * search points over a parameter space, in order to detect signals with
50 * unknown parameters. The formalism for defining a proper distance
51 * metric on the parameter space is defined in
52 * FlatMesh.h. However, whereas the routines under
53 * FlatMesh.h require the metric \f$ \mathsf{g}_{ab} \f$ to be constant
54 * over the parameter space, the routines under this header only treat
55 * \f$ \mathsf{g}_{ab} \f$ as constant over distances \f$ \lesssim m_\mathrm{thresh} \f$ .
56 *
57 * \anchor pulsar_tiling
58 * \image html pulsar_tiling.png "Mesh placement using parallelogram tiling. (a) The left and right sides of a tile are required to be vertical; the top and bottom sides can tilt to maximize the tile area. (b) Tiles can be stacked in fixed-width columns\, even as the elliptical contours change. (c) Extra overlapping tiles are sometimes required at the corners of columns."
59 *
60 * Since the metric is treated as constant over distances \f$ \lesssim
61 * m_\mathrm{thresh} \f$ , this distance defines an elliptical contour around
62 * any mesh point. We define a ``tile'' as a parallelogram inscribed
63 * within the ellipse, with its left and right sides aligned with the \f$ y \f$
64 * axis. This is shown in \ref pulsar_tiling "this figure" (a), above. A ``column''
65 * is a set of tiles of constant horizontal width stacked one on top of
66 * the other, as shown in \ref pulsar_tiling "this figure" (b). As the metric
67 * changes over space, the vertical height and tilt of the tiles in a
68 * column may change, so long as their width remains fixed; we note that
69 * if the tilt changes, the tiles will overlap slightly to ensure
70 * complete coverage. Finally, the boundary of the parameter space may
71 * extend outside the ``corners'' of the column, crossing the end of a
72 * tile between its centre and its edge, as shown in
73 * \ref pulsar_tiling "this figure" (c). These triangular corners can be covered
74 * with one or more extra overlapping tiles of reduced width.
75 *
76 * In a parameter space with constant metric, the tile area is maximized
77 * (and the number of covering tiles minimized) when the column width is
78 * \f$ \sqrt{2} \f$ times smaller than the projected horizontal width of the
79 * ellipses. When the ellipses vary, it is generally best to determine
80 * the column width from the \e narrowest ellipse in a column, to
81 * avoid singular effects when tile widths approach the ellipse widths
82 * and become infinitesimally high.
83 *
84 * For the column-placement algorithm to work effectively, we require
85 * that the parameter space be representable as a range
86 * \f$ y\in[y_1(x),y_2(x)] \f$ between two single-valued functions defined on a
87 * domain \f$ x\in[x_\mathrm{min},x_\mathrm{max}] \f$ . If a desired search
88 * region is too complicated to express this way (e.g.\ it has
89 * disconnected regions, or ``branches'' where a vertical line intersects
90 * the boundary more than twice), then one should divide the region up
91 * into subregions with well-behaved boundary functions and tile these
92 * subregions separately.
93 *
94 * This header and its associated modules are placed in the \c pulsar
95 * package because they were originally intended for use in searches over
96 * sky position, but they can be used generically for any two-dimensional
97 * parameter space search where the metric is not too poorly behaved.
98 */
99/** @{ */
100
101/** \name Error Codes */
102/** @{ */
103#define TWODMESHH_ENUL 1
104#define TWODMESHH_EOUT 2
105#define TWODMESHH_EMEM 3
106#define TWODMESHH_EMETRIC 4
107#define TWODMESHH_EWIDTH 5
108#define TWODMESHH_EDIM 6
109#define TWODMESHH_EINT 7
110
111#define TWODMESHH_MSGENUL "Unexpected null pointer in arguments"
112#define TWODMESHH_MSGEOUT "Output handle points to a non-null pointer"
113#define TWODMESHH_MSGEMEM "Memory allocation error"
114#define TWODMESHH_MSGEMETRIC "Non-positive metric"
115#define TWODMESHH_MSGEWIDTH "Column width too small"
116#define TWODMESHH_MSGEDIM "Incorrect dimensions"
117#define TWODMESHH_MSGEINT "Non-positive interval"
118/** @} */
119
120/**
121 * This structure represents a single node in a linked list of
122 * mesh points, specified in the coordinate system used to place it
123 */
124typedef struct tagTwoDMeshNode {
125 REAL4 x, y; /**< The coordinates of the mesh point */
126 REAL4 dx; /**< The half-width of the tile centred on the mesh point */
127 REAL4 dy[2]; /**< The heights of the two right-hand corners of the tile, relative to the mesh point */
128 struct tagTwoDMeshNode *next; /**< The next mesh point in the linked list; \c NULL if this is the tail */
129 struct tagTwoDMeshNode *subMesh; /**< The head of a linked list of fine mesh points within the rectangular
130 * area spanned by this mesh point list; \c NULL if there is no (further)
131 * refined mesh for this location
132 */
133 UINT4 nSub; /**< The number of fine mesh points in the above list. It is an error for \c subNum to be nonzero
134 * and \c subMesh to be \c NULL
135 */
137
138/**
139 * This structure stores the parameters required by the
140 * two-dimensional mesh placement functions.
141 */
142typedef struct tagTwoDMeshParamStruc {
143 REAL4 domain[2]; /**< The domain \f$ [x_\mathrm{min},x_\mathrm{max}] \f$ spanned by the desired parameter region */
144 void ( *getRange )( LALStatus *, REAL4 [2], REAL4, void * ); /**< A function that returns in its second argument the range
145 * \f$ [y_1(x),y_2(x)] \f$ spanned by the parameter region for a specified \f$ x \f$ ,
146 * which is passed in as the third argument; the fourth argument can be
147 * used to pass function-specific parameters.
148 */
149 void *rangeParams; /**< The parameters to be passed as the fourth argument of <tt>*getRange()</tt>, above. */
150 void ( *getMetric )( LALStatus *, REAL4 [3], REAL4 [2], void * ); /**< A function that returns in its second argument the
151 * components \f$ g_{xx} \f$ , \f$ g_{yy} \f$ , and \f$ g_{xy} \f$ (in that order) of the
152 * metric evaluated at a point \f$ (x,y) \f$ , which is passed in as the third
153 * argument; the fourth argument can be used to pass function-specific parameters
154 */
155 void *metricParams; /**< The parameters to be passed as the fourth argument of <tt>*getMetric()</tt>, above */
156 REAL4 mThresh; /**< The maximum mismatch \f$ m_\mathrm{thresh} \f$ desired between any point in the region and the nearest mesh point;
157 * note that the maximum mismatch is equal to 1 minus the minimum match.
158 */
159 REAL4 widthMaxFac; /**< The minimum ratio of mismatch ellipse width (projected onto the horizontal axis) to column width
160 * that must be maintained throughout the column: if an ellipse falls
161 * below this ratio due to shrinkage or rotation, as in \ref pulsar_tiling "this figure" (b), the
162 * code will try a narrower column; if set to \f$ \leq1 \f$ , the default value
163 * \c TWODMESHINTERNALC_WMAXFAC= \f$ \sqrt[4]{2} \f$ will be used.
164 */
165 REAL4 widthRetryFac; /**< If the column is determined to be too wide (e.g.\ due to the value of \c widthMaxFac, above), the
166 * column width will be reduced by the factor \c widthRetryFac; if set to \f$ \leq1 \f$ , the default value
167 * \c TWODMESHINTERNALC_WRETRYFAC= \f$ \sqrt{2} \f$ will be used.
168 */
169 UINT4 maxColumns; /**< The maximum number of columns the mesh placement routine will try before giving up. If zero, this number is ignored. */
170 UINT4 nIn; /**< The maximum number of mesh points allowed, after which the placement routine will quit. If zero, this number is ignored. */
171 UINT4 nOut; /**< The number of mesh points added by the placement routine; if an error occurs, this will store the number of mesh points completed before the error */
173
174
175/**
176 * This structure stores additional parameters required when
177 * laying down a single column of a two-dimensional mesh. The area to be
178 * covered is specified by intersecting the area between two lines with
179 * the parameter space. If part of a column has already been covered,
180 * one can further restrict the area by specifying a pair of ``clipping
181 * points'' on each vertical line; the area to be covered is then
182 * restricted to lie above the line joining the bottom two corners and
183 * below the line joining the top two corners
184 */
185typedef struct tagTwoDColumnParamStruc {
186 REAL4 domain[2]; /**< The region in \f$ x \f$ spanned by the column; We require that <tt>domain[1]</tt> \f$ > \f$ <tt>domain[0]</tt> */
187 REAL4 leftRange[2]; /**< The values \f$ y_1(x) \f$ , \f$ y_2(x) \f$ (in that order) of the boundary functions at \f$ x= \f$ <tt>domain[0]</tt> */
188 REAL4 rightRange[2]; /**< The values of \f$ y_1(x) \f$ , \f$ y_2(x) \f$ (in that order) of the boundary functions at \f$ x= \f$ <tt>domain[1]</tt> */
189 REAL4 leftClip[2]; /**< The \f$ y \f$ values of the bottom and top corners (in that order) of the clipping boundary at \f$ x= \f$ <tt>domain[0]</tt>. */
190 REAL4 rightClip[2]; /**< The \f$ y \f$ values of the bottom and top corners (in that order) of the clipping boundary at \f$ x= \f$ <tt>domain[1]</tt> */
191 BOOLEAN tooWide; /**< This is set to 1 if the column-placement routine determines that the region is too wide to be covered with a single column of tiles. */
193
194
195/* Function prototypes. */
196void
198 TwoDMeshNode **mesh,
200
201void
203 TwoDMeshNode **mesh,
204 UINT4 *nFree );
205
206void
208 TwoDMeshNode *coarseMesh,
209 TwoDMeshNode *fineMesh );
210
211
212
213
214void
216 TwoDMeshNode **tail,
218
219void
221 TwoDMeshNode **tail,
222 TwoDColumnParamStruc *columnParams,
224
225void
227 TwoDMeshNode **new_,
228 TwoDMeshNode *old );
229
230/** @} */
231
232#if 0
233{
234 /* so that editors will match succeeding brace */
235#elif defined(__cplusplus)
236}
237#endif
238
239#endif /* _TWODMESH_H */
void getMetric(LALStatus *, meshREAL g[3], meshREAL skypos[2], void *params)
Definition: DopplerScan.c:414
void getRange(LALStatus *, meshREAL y[2], meshREAL x, void *params)
unsigned char BOOLEAN
uint32_t UINT4
float REAL4
void LALTwoDMesh(LALStatus *status, TwoDMeshNode **tail, TwoDMeshParamStruc *params)
void LALTwoDColumn(LALStatus *status, TwoDMeshNode **tail, TwoDColumnParamStruc *columnParams, TwoDMeshParamStruc *params)
void LALCreateTwoDMesh(LALStatus *status, TwoDMeshNode **mesh, TwoDMeshParamStruc *params)
Definition: TwoDMesh.c:106
void LALTwoDNodeCopy(LALStatus *status, TwoDMeshNode **new_, TwoDMeshNode *old)
void LALRefineTwoDMesh(LALStatus *status, TwoDMeshNode *coarseMesh, TwoDMeshNode *fineMesh)
Definition: TwoDMesh.c:195
void LALDestroyTwoDMesh(LALStatus *status, TwoDMeshNode **mesh, UINT4 *nFree)
Definition: TwoDMesh.c:159
list y
This structure stores additional parameters required when laying down a single column of a two-dimens...
Definition: TwoDMesh.h:185
BOOLEAN tooWide
This is set to 1 if the column-placement routine determines that the region is too wide to be covered...
Definition: TwoDMesh.h:191
This structure represents a single node in a linked list of mesh points, specified in the coordinate ...
Definition: TwoDMesh.h:124
struct tagTwoDMeshNode * next
The next mesh point in the linked list; NULL if this is the tail.
Definition: TwoDMesh.h:128
REAL4 dx
The half-width of the tile centred on the mesh point.
Definition: TwoDMesh.h:126
struct tagTwoDMeshNode * subMesh
The head of a linked list of fine mesh points within the rectangular area spanned by this mesh point ...
Definition: TwoDMesh.h:129
UINT4 nSub
The number of fine mesh points in the above list.
Definition: TwoDMesh.h:133
This structure stores the parameters required by the two-dimensional mesh placement functions.
Definition: TwoDMesh.h:142
REAL4 widthRetryFac
If the column is determined to be too wide (e.g. due to the value of widthMaxFac, above),...
Definition: TwoDMesh.h:165
REAL4 widthMaxFac
The minimum ratio of mismatch ellipse width (projected onto the horizontal axis) to column width that...
Definition: TwoDMesh.h:159
UINT4 nIn
The maximum number of mesh points allowed, after which the placement routine will quit.
Definition: TwoDMesh.h:170
void * metricParams
The parameters to be passed as the fourth argument of *getMetric(), above.
Definition: TwoDMesh.h:155
UINT4 maxColumns
The maximum number of columns the mesh placement routine will try before giving up.
Definition: TwoDMesh.h:169
REAL4 mThresh
The maximum mismatch desired between any point in the region and the nearest mesh point; note that t...
Definition: TwoDMesh.h:156
UINT4 nOut
The number of mesh points added by the placement routine; if an error occurs, this will store the num...
Definition: TwoDMesh.h:171
void * rangeParams
The parameters to be passed as the fourth argument of *getRange(), above.
Definition: TwoDMesh.h:149