LALPulsar  6.1.0.1-fe68b98
LatticeTiling.c File Reference

Prototypes

static void LT_ZeroStrictUpperTriangle (gsl_matrix *A)
 Zero out the strictly upper triangular part of the matrix A. More...
 
static void LT_ReverseOrderRowsCols (gsl_matrix *A)
 Reverse the order of both the rows and columns of the matrix A. More...
 
static void LT_CallBoundFunc (const LatticeTiling *tiling, const size_t dim, const gsl_matrix *phys_point_cache, const gsl_vector *phys_point, double *phys_lower, double *phys_upper)
 Call the parameter-space bound function of a given dimension. More...
 
static void LT_SetPhysPoint (const LatticeTiling *tiling, gsl_matrix *phys_point_cache, gsl_vector *phys_point, const size_t dim, const double phys_point_dim)
 Set value of physical point in a given dimension, and update cache. More...
 
static void LT_FindBoundExtrema (const LatticeTiling *tiling, const size_t i, const size_t dim, gsl_matrix *phys_point_cache, gsl_vector *phys_point, double *phys_lower_minimum, double *phys_upper_maximum)
 Find the extrema of the parameter-space bounds, by sampling the bounds around the current point. More...
 
static int LT_StatsCallback (const bool first_call, const LatticeTiling *tiling, const LatticeTilingIterator *itr, const gsl_vector *point, const size_t changed_i, const void *param UNUSED, void *out)
 Callback function for computing lattice tiling statistics. More...
 
static int LT_InitFITSRecordTable (FITSFile *file)
 Initialise FITS table for saving and restoring a lattice tiling iterator. More...
 
static void LT_FreeIndexTrie (LT_IndexTrie *trie)
 Free memory pointed to by an index trie. More...
 
static void LT_PollIndexTrie (const LatticeTiling *tiling, const LT_IndexTrie *trie, const size_t ti, const gsl_vector *point_int, INT4 *poll_nearest, double *poll_min_distance, INT4 *nearest)
 Find the nearest point within the parameter-space bounds of the lattice tiling, by polling the neighbours of an 'original' nearest point found by LT_FindNearestPoints(). More...
 
static void LT_PrintIndexTrie (const LatticeTiling *tiling, const LT_IndexTrie *trie, const size_t ti, FILE *file, INT4 int_lower[])
 Print one level of a lattice tiling index trie. More...
 
static int LT_FindNearestPoints (const LatticeTilingLocator *loc, const gsl_matrix *points, gsl_matrix *nearest_points, UINT8VectorSequence *nearest_indexes, INT4VectorSequence *nearest_lefts, INT4VectorSequence *nearest_rights)
 Locate the nearest points in a lattice tiling to a given set of points. More...
 
LatticeTiling * XLALCreateLatticeTiling (const size_t ndim)
 Create a new lattice tiling. More...
 
void XLALDestroyLatticeTiling (LatticeTiling *tiling)
 Destroy a lattice tiling. More...
 
int XLALSetLatticeTilingBound (LatticeTiling *tiling, const size_t dim, const LatticeTilingBound func, const size_t data_len, const void *data_lower, const void *data_upper)
 Set a parameter-space bound on a dimension of the lattice tiling. More...
 
int XLALSetLatticeTilingBoundName (LatticeTiling *tiling, const size_t dim, const char *fmt,...)
 
int XLALSetLatticeTilingBoundCacheFunction (LatticeTiling *tiling, const size_t dim, const LatticeTilingBoundCache func)
 Set bound cache function for a lattice tiling parameter-space dimension. More...
 
static double ConstantBound (const void *data, const size_t dim UNUSED, const gsl_matrix *cache UNUSED, const gsl_vector *point UNUSED)
 
int XLALSetLatticeTilingConstantBound (LatticeTiling *tiling, const size_t dim, const double bound1, const double bound2)
 Set a constant lattice tiling parameter-space bound, given by the minimum and maximum of the two supplied bounds, on a dimension of the lattice tiling. More...
 
int XLALSetLatticeTilingPadding (LatticeTiling *tiling, const size_t dim, const double lower_bbox_pad, const double upper_bbox_pad, const int lower_intp_pad, const int upper_intp_pad, const int find_bound_extrema)
 Control the padding of lattice tiling parameter-space bounds in the given dimension. More...
 
int XLALSetLatticeTilingOrigin (LatticeTiling *tiling, const size_t dim, const double origin)
 Set the physical parameter-space origin of the lattice tiling in the given dimension. More...
 
int XLALSetLatticeTilingRandomOriginOffsets (LatticeTiling *tiling, RandomParams *rng)
 Offset the physical parameter-space origin of the lattice tiling by a random fraction of the lattice step size in tiled dimensions. More...
 
int XLALSetTiledLatticeDimensionsFromTiling (LatticeTiling *tiling, const LatticeTiling *ref_tiling)
 Set the tiled (i.e. More...
 
int XLALSetTilingLatticeAndMetric (LatticeTiling *tiling, const TilingLattice lattice, const gsl_matrix *metric, const double max_mismatch)
 Set the tiling lattice, parameter-space metric, and maximum prescribed mismatch. More...
 
size_t XLALTotalLatticeTilingDimensions (const LatticeTiling *tiling)
 Return the total number of dimensions of the lattice tiling. More...
 
size_t XLALTiledLatticeTilingDimensions (const LatticeTiling *tiling)
 Return the number of tiled dimensions of the lattice tiling. More...
 
size_t XLALLatticeTilingTiledDimension (const LatticeTiling *tiling, const size_t tiled_dim)
 Return the dimension of the tiled lattice tiling dimension indexed by 'tiled_dim'. More...
 
int XLALIsTiledLatticeTilingDimension (const LatticeTiling *tiling, const size_t dim)
 Return >0 if a lattice tiling dimension is tiled (i.e. More...
 
const charXLALLatticeTilingBoundName (const LatticeTiling *tiling, const size_t dim)
 Get the name of a lattice tiling parameter-space dimension. More...
 
int XLALLatticeTilingDimensionByName (const LatticeTiling *tiling, const char *bound_name)
 Return the index of the lattice tiling dimension which has the given name. More...
 
REAL8 XLALLatticeTilingStepSize (const LatticeTiling *tiling, const size_t dim)
 Return the step size of the lattice tiling in a given dimension, or 0 for non-tiled dimensions. More...
 
REAL8 XLALLatticeTilingBoundingBox (const LatticeTiling *tiling, const size_t dim)
 Return the bounding box extent of the lattice tiling in a given dimension, or 0 for non-tiled dimensions. More...
 
const void * XLALRegisterLatticeTilingCallback (LatticeTiling *tiling, const LatticeTilingCallback func, const size_t param_len, const void *param, const size_t out_len)
 Register a callback function which can be used to compute properties of a lattice tiling. More...
 
int XLALPerformLatticeTilingCallbacks (const LatticeTiling *tiling)
 Perform all registered lattice tiling callbacks. More...
 
const LatticeTilingStatsXLALLatticeTilingStatistics (const LatticeTiling *tiling, const size_t dim)
 Return statistics related to the number/value of lattice tiling points in a dimension. More...
 
int XLALRandomLatticeTilingPoints (const LatticeTiling *tiling, const double scale, RandomParams *rng, gsl_matrix *random_points)
 Generate random points within the parameter space of the lattice tiling. More...
 
int XLALGetLatticeTilingBound (const LatticeTiling *tiling, const size_t dim, const gsl_vector *point, const bool padding, double *lower, double *upper)
 Get a parameter-space bound on a dimension of the lattice tiling. More...
 
LatticeTilingIterator * XLALCreateLatticeTilingIterator (const LatticeTiling *tiling, const size_t itr_ndim)
 Create a new lattice tiling iterator. More...
 
void XLALDestroyLatticeTilingIterator (LatticeTilingIterator *itr)
 Destroy a lattice tiling iterator. More...
 
int XLALSetLatticeTilingAlternatingIterator (LatticeTilingIterator *itr, const bool alternating)
 Set whether the lattice tiling iterator should alternate its iteration direction (i.e. More...
 
int XLALResetLatticeTilingIterator (LatticeTilingIterator *itr)
 Reset an iterator to the beginning of a lattice tiling. More...
 
int XLALNextLatticeTilingPoint (LatticeTilingIterator *itr, gsl_vector *point)
 Advance lattice tiling iterator, and optionally return the next point in point. More...
 
int XLALNextLatticeTilingPoints (LatticeTilingIterator *itr, gsl_matrix **points)
 Advance lattice tiling iterator, and optionally return the next set of points in points. More...
 
UINT8 XLALTotalLatticeTilingPoints (const LatticeTilingIterator *itr)
 Return the total number of points covered by the lattice tiling iterator. More...
 
UINT8 XLALCurrentLatticeTilingIndex (const LatticeTilingIterator *itr)
 Return the index of the current point in the lattice tiling iterator. More...
 
int XLALCurrentLatticeTilingBlock (const LatticeTilingIterator *itr, const size_t dim, INT4 *left, INT4 *right)
 Return indexes of the left-most and right-most points in the current block of points in the given dimension, relative to the current point. More...
 
int XLALSaveLatticeTilingIterator (const LatticeTilingIterator *itr, FITSFile *file, const char *name)
 Save the state of a lattice tiling iterator to a FITS file. More...
 
int XLALRestoreLatticeTilingIterator (LatticeTilingIterator *itr, FITSFile *file, const char *name)
 Restore the state of a lattice tiling iterator from a FITS file. More...
 
LatticeTilingLocator * XLALCreateLatticeTilingLocator (const LatticeTiling *tiling)
 Create a new lattice tiling locator. More...
 
void XLALDestroyLatticeTilingLocator (LatticeTilingLocator *loc)
 Destroy a lattice tiling locator. More...
 
int XLALNearestLatticeTilingPoint (const LatticeTilingLocator *loc, const gsl_vector *point, gsl_vector *nearest_point, UINT8Vector *nearest_index)
 Locate the nearest point in a lattice tiling to a given point. More...
 
int XLALNearestLatticeTilingPoints (const LatticeTilingLocator *loc, const gsl_matrix *points, gsl_matrix **nearest_points, UINT8VectorSequence **nearest_indexes)
 Locate the nearest points in a lattice tiling to a given set of points. More...
 
int XLALNearestLatticeTilingBlock (const LatticeTilingLocator *loc, const gsl_vector *point, const size_t dim, gsl_vector *nearest_point, UINT8 *nearest_index, INT4 *nearest_left, INT4 *nearest_right)
 Locate the nearest block in a lattice tiling to a given point. More...
 
int XLALPrintLatticeTilingIndexTrie (const LatticeTilingLocator *loc, FILE *file)
 Print the internal index trie of a lattice tiling locator to the given file pointer. More...
 

Go to the source code of this file.

Data Structures

struct  LT_Bound
 Lattice tiling parameter-space bound for one dimension. More...
 
struct  LT_Callback
 Lattice tiling callback function and associated data. More...
 
struct  LT_FITSRecord
 FITS record for for saving and restoring a lattice tiling iterator. More...
 
struct  LT_IndexTrie
 Lattice tiling index trie for one dimension. More...
 
struct  LatticeTiling
 Describes a lattice tiling parameter-space bounds and metric. More...
 
struct  LatticeTilingIterator
 Iterates over all points in a lattice tiling. More...
 
struct  LatticeTilingLocator
 Locates the nearest point in a lattice tiling. More...
 

Macros

#define LT_DATA_MAX_SIZE   65536
 
#define LT_CACHE_MAX_SIZE   6
 
#define STRICT_BOUND_PADDING(b)    ( ( (b)->lower_bbox_pad == 0 ) && ( (b)->upper_bbox_pad == 0 ) && ( (b)->lower_intp_pad == 0 ) && ( (b)->upper_intp_pad == 0 ) )
 

Variables

const UserChoices TilingLatticeChoices
 Static array of all :tagTilingLattice choices, for use by the UserInput module parsing routines. More...
 
int LatticeTilingProgressLogLevel = LOG_DEBUG
 Log level at which to print progress messages when counting templates and performing callbacks. More...
 

Macro Definition Documentation

◆ LT_DATA_MAX_SIZE

#define LT_DATA_MAX_SIZE   65536

Definition at line 41 of file LatticeTiling.c.

◆ LT_CACHE_MAX_SIZE

#define LT_CACHE_MAX_SIZE   6

Definition at line 44 of file LatticeTiling.c.

◆ STRICT_BOUND_PADDING

#define STRICT_BOUND_PADDING (   b)     ( ( (b)->lower_bbox_pad == 0 ) && ( (b)->upper_bbox_pad == 0 ) && ( (b)->lower_intp_pad == 0 ) && ( (b)->upper_intp_pad == 0 ) )

Definition at line 47 of file LatticeTiling.c.

Function Documentation

◆ LT_ZeroStrictUpperTriangle()

static void LT_ZeroStrictUpperTriangle ( gsl_matrix *  A)
static

Zero out the strictly upper triangular part of the matrix A.

Definition at line 157 of file LatticeTiling.c.

◆ LT_ReverseOrderRowsCols()

static void LT_ReverseOrderRowsCols ( gsl_matrix *  A)
static

Reverse the order of both the rows and columns of the matrix A.

Definition at line 169 of file LatticeTiling.c.

◆ LT_CallBoundFunc()

static void LT_CallBoundFunc ( const LatticeTiling *  tiling,
const size_t  dim,
const gsl_matrix *  phys_point_cache,
const gsl_vector *  phys_point,
double *  phys_lower,
double *  phys_upper 
)
inlinestatic

Call the parameter-space bound function of a given dimension.

Parameters
[in]tilingLattice tiling
[in]dimDimension on which bound applies
[in]phys_point_cacheCached values for computing physical point bounds
[in]phys_pointPhysical point at which to find bounds
[out]phys_lowerLower parameter-space bound
[out]phys_upperUpper parameter-space bound

Definition at line 182 of file LatticeTiling.c.

◆ LT_SetPhysPoint()

static void LT_SetPhysPoint ( const LatticeTiling *  tiling,
gsl_matrix *  phys_point_cache,
gsl_vector *  phys_point,
const size_t  dim,
const double  phys_point_dim 
)
inlinestatic

Set value of physical point in a given dimension, and update cache.

Parameters
[in]tilingLattice tiling
[out]phys_point_cacheCached values for computing physical point bounds
[out]phys_pointPhysical point
[in]dimDimension on which to set point
[in]phys_point_dimValue of physical point in this dimension

Definition at line 228 of file LatticeTiling.c.

◆ LT_FindBoundExtrema()

static void LT_FindBoundExtrema ( const LatticeTiling *  tiling,
const size_t  i,
const size_t  dim,
gsl_matrix *  phys_point_cache,
gsl_vector *  phys_point,
double *  phys_lower_minimum,
double *  phys_upper_maximum 
)
static

Find the extrema of the parameter-space bounds, by sampling the bounds around the current point.

Parameters
[in]tilingLattice tiling
[in]iCurrent dimension in LT_FindBoundExtrema() iteration
[in]dimDimension on which bound applies
[in]phys_point_cacheCached values for computing physical point bounds
[in]phys_pointPhysical point at which to find bounds
[out]phys_lower_minimumMinimum lower parameter-space bound
[out]phys_upper_maximumMaximum upper parameter-space bound

Definition at line 263 of file LatticeTiling.c.

◆ LT_StatsCallback()

static int LT_StatsCallback ( const bool  first_call,
const LatticeTiling *  tiling,
const LatticeTilingIterator *  itr,
const gsl_vector *  point,
const size_t  changed_i,
const void *param  UNUSED,
void *  out 
)
static

Callback function for computing lattice tiling statistics.

Definition at line 312 of file LatticeTiling.c.

◆ LT_InitFITSRecordTable()

static int LT_InitFITSRecordTable ( FITSFile file)
static

Initialise FITS table for saving and restoring a lattice tiling iterator.

Definition at line 366 of file LatticeTiling.c.

◆ LT_FreeIndexTrie()

static void LT_FreeIndexTrie ( LT_IndexTrie *  trie)
static

Free memory pointed to by an index trie.

The trie itself should be freed by the caller.

Parameters
[in]triePointer to array of index tries

Definition at line 381 of file LatticeTiling.c.

◆ LT_PollIndexTrie()

static void LT_PollIndexTrie ( const LatticeTiling *  tiling,
const LT_IndexTrie *  trie,
const size_t  ti,
const gsl_vector *  point_int,
INT4 poll_nearest,
double *  poll_min_distance,
INT4 nearest 
)
static

Find the nearest point within the parameter-space bounds of the lattice tiling, by polling the neighbours of an 'original' nearest point found by LT_FindNearestPoints().

Parameters
[in]tilingLattice tiling
[in]trieLattice tiling index trie
[in]tiCurrent depth of the trie
[in]point_intOriginal point in generating integers
[in]poll_nearestNeighbouring point currently being polled
[in]poll_min_distanceMinimum distance to neighbouring point found so far
[in]nearestNew nearest point found by polling

Definition at line 398 of file LatticeTiling.c.

◆ LT_PrintIndexTrie()

static void LT_PrintIndexTrie ( const LatticeTiling *  tiling,
const LT_IndexTrie *  trie,
const size_t  ti,
FILE *  file,
INT4  int_lower[] 
)
static

Print one level of a lattice tiling index trie.

Parameters
[in]tilingLattice tiling
[in]trieLattice tiling index trie
[in]tiCurrent depth of the trie
[in]fileFile pointer to print trie to
[in]int_lowerCurrent integer lower bound

Definition at line 457 of file LatticeTiling.c.

◆ LT_FindNearestPoints()

static int LT_FindNearestPoints ( const LatticeTilingLocator *  loc,
const gsl_matrix *  points,
gsl_matrix *  nearest_points,
UINT8VectorSequence nearest_indexes,
INT4VectorSequence nearest_lefts,
INT4VectorSequence nearest_rights 
)
static

Locate the nearest points in a lattice tiling to a given set of points.

Return the nearest points in 'nearest_points', and optionally: unique sequential indexes to the nearest points in 'nearest_indexes', and indexes of the left/right-most points in the blocks of the nearest points relative to the nearest points in 'nearest_left' and 'nearest_right' respectively.

Parameters
[in]locLattice tiling locator
[in]pointsColumns are set of points for which to find nearest points
[out]nearest_pointsColumns are the corresponding nearest points
[out]nearest_indexesVectors are unique sequential indexes of the nearest points
[out]nearest_leftsVectors are indexes of left-most points of blocks relative to nearest points
[out]nearest_rightsVectors are indexes of right-most points of blocks relative to nearest points

Definition at line 520 of file LatticeTiling.c.

◆ XLALSetLatticeTilingBoundName()

int XLALSetLatticeTilingBoundName ( LatticeTiling *  tiling,
const size_t  dim,
const char fmt,
  ... 
)

Definition at line 907 of file LatticeTiling.c.

◆ ConstantBound()

static double ConstantBound ( const void *  data,
const size_t dim  UNUSED,
const gsl_matrix *cache  UNUSED,
const gsl_vector *point  UNUSED 
)
static

Definition at line 959 of file LatticeTiling.c.