Loading [MathJax]/extensions/TeX/AMSmath.js
LAL 7.7.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALRunningMedian.h
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Bernd Machenschalk, Patrick Brady, Reinhard Prix
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 _LALRUNNINGMEDIAN_H
21#define _LALRUNNINGMEDIAN_H
22
23#include <lal/LALDatatypes.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29
30/**
31 * \defgroup LALRunningMedian_h Header LALRunningMedian.h
32 * \ingroup lal_utilities
33 * \author Somya D. Mohanty, B. Machenschalk
34 *
35 * \brief Provides routines to efficiently calculate the running median
36 *
37 * ### Synopsis ###
38 *
39 * \code
40 * #include <lal/LALRunningMedian.h>
41 * \endcode
42 *
43 * This header covers routines to efficiently calculate the
44 * running median of REAL4 and REAL8 sequences
45 *
46 * The routine <tt>LALDRunningMedian()</tt> calculates the running medians of a
47 * REAL8Sequence. The routine <tt>LALSRunningMedian()</tt> does the same for a REAL4Sequence.
48 * \c input ist a REAL4/REAL8Sequence containing the input array, \c blocksize
49 * is the length of the block the medians are calculated of.
50 * With n being the lenght of the input array and b being the blocksize,
51 * the medians array must be a REAL4/REAL8 sequence of length (n-b+1).
52 * <tt>LALDRunningMedian2()</tt> and <tt>LALSRunningMedian2()</tt> are a
53 * different implentation of the same algorithm. It should behave exactly like
54 * <tt>LALDRunningMedian()</tt>, but has proven to be a
55 * little faster and more stable. Check if it works for you.
56 *
57 * ### Algorithm ###
58 *
59 * For a detailed description of the algorithm see the
60 * LIGO document T-030168-00-D, Somya D. Mohanty:
61 * Efficient Algorithm for computing a Running Median
62 *
63 */
64/** @{ */
65
66/** \name Error Codes */
67/** @{ */
68#define LALRUNNINGMEDIANH_EMALOC1 1 /**< Could not allocate indexblock */
69#define LALRUNNINGMEDIANH_EMALOC2 2 /**< Could not allocate checks */
70#define LALRUNNINGMEDIANH_EMALOC3 3 /**< Could not allocate checks4shift */
71#define LALRUNNINGMEDIANH_EMALOC4 4 /**< Could not allocate nodeaddresses */
72#define LALRUNNINGMEDIANH_EMALOC5 5 /**< Could not aloocate first node */
73#define LALRUNNINGMEDIANH_EMALOC6 6 /**< Could not allocate node */
74#define LALRUNNINGMEDIANH_ECV 7 /**< Could not create output vector (LALCreateVector() failed) */
75#define LALRUNNINGMEDIANH_ENULL 8 /**< Invalid input: NULL pointer. */
76#define LALRUNNINGMEDIANH_EZERO 9 /**< Invalid input: block length must be >2 */
77#define LALRUNNINGMEDIANH_ELARGE 10 /**< Invalid input: block length larger than imput length */
78#define LALRUNNINGMEDIANH_EIMED 11 /**< Invalid input: wrong size of median array */
79/** @} */
80
81/** \cond DONT_DOXYGEN */
82#define LALRUNNINGMEDIANH_MSGEMALOC1 "Could not allocate indexblock"
83#define LALRUNNINGMEDIANH_MSGEMALOC2 "Could not allocate checks"
84#define LALRUNNINGMEDIANH_MSGEMALOC3 "Could not allocate checks4shift"
85#define LALRUNNINGMEDIANH_MSGEMALOC4 "Could not allocate nodeaddresses"
86#define LALRUNNINGMEDIANH_MSGEMALOC5 "Could not aloocate first node"
87#define LALRUNNINGMEDIANH_MSGEMALOC6 "Could not allocate node"
88#define LALRUNNINGMEDIANH_MSGECV "Could not create output vector (LALCreateVector failed)"
89#define LALRUNNINGMEDIANH_MSGENULL "Invalid input: NULL pointer."
90#define LALRUNNINGMEDIANH_MSGEZERO "Invalid input: block length must be >2"
91#define LALRUNNINGMEDIANH_MSGELARGE "Invalid input: block length larger than imput length"
92#define LALRUNNINGMEDIANH_MSGEIMED "Invalid input: wrong size of median array"
93/** \endcond */
94
95/* Structures. */
96
97/**
98 * This is the parameter structure for the LALRunningMedian functions.
99 * Currently the only parameter supported is the blocksize, the number
100 * of elements a single median is calculated from. The current
101 * implementation requires the blocksize to be < 2.
102 */
103typedef struct tagLALRunningMedianPar
104{
105 UINT4 blocksize; /**< the number of elements a single median is calculated from */
106}
108
109
110/* Function prototypes. */
111
112/** See LALRunningMedian_h for documentation */
113void
115 REAL8Sequence *medians,
116 const REAL8Sequence *input,
117 LALRunningMedianPar param);
118
119/** See LALRunningMedian_h for documentation */
120void
122 REAL4Sequence *medians,
123 const REAL4Sequence *input,
124 LALRunningMedianPar param);
125
126/** See LALRunningMedian_h for documentation */
127void
129 REAL8Sequence *medians,
130 const REAL8Sequence *input,
131 LALRunningMedianPar param);
132
133/** See LALRunningMedian_h for documentation */
134void
136 REAL4Sequence *medians,
137 const REAL4Sequence *input,
138 LALRunningMedianPar param);
139
140/** @} */
141
142#ifdef __cplusplus
143}
144#endif
145
146#endif /* _LALRUNNINGMEDIAN_H */
uint32_t UINT4
Four-byte unsigned integer.
void LALSRunningMedian(LALStatus *status, REAL4Sequence *medians, const REAL4Sequence *input, LALRunningMedianPar param)
See LALRunningMedian_h for documentation.
void LALDRunningMedian(LALStatus *status, REAL8Sequence *medians, const REAL8Sequence *input, LALRunningMedianPar param)
See LALRunningMedian_h for documentation.
void LALDRunningMedian2(LALStatus *status, REAL8Sequence *medians, const REAL8Sequence *input, LALRunningMedianPar param)
See LALRunningMedian_h for documentation.
void LALSRunningMedian2(LALStatus *status, REAL4Sequence *medians, const REAL4Sequence *input, LALRunningMedianPar param)
See LALRunningMedian_h for documentation.
This is the parameter structure for the LALRunningMedian functions.
UINT4 blocksize
the number of elements a single median is calculated from
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
Vector of type REAL4, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:145
Vector of type REAL8, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:154