LAL  7.5.0.1-8083555
CreateZPGFilter.c
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2007 Jolien Creighton, 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 #include <lal/LALStdlib.h>
21 #include <lal/AVFactories.h>
22 #include <lal/ZPGFilter.h>
23 
24 /**
25  * \addtogroup CreateZPGFilter_c
26  * \author Creighton, T. D.
27  *
28  * \brief Creates ZPG filter objects.
29  *
30  * ### Description ###
31  *
32  * These functions create an object <tt>**output</tt>, of type
33  * \c COMPLEX8ZPGFilter or \c COMPLEX16ZPGFilter, having
34  * \c numZeros zeros and \c numPoles poles. The values of those
35  * zeros and poles are not set by these routines (in general they will
36  * start out as garbage). The handle passed into the functions must be a
37  * valid handle (ie \c output\f$\neq\f$\c NULL), but must not
38  * point to an existing object (ie <tt>*output</tt>=\c NULL).
39  *
40  */
41 /** @{ */
42 
43 /** \see See \ref CreateZPGFilter_c for documentation */
45 {
47  if ( numZeros < 0 || numPoles < 0 )
49  output = LALCalloc( 1, sizeof(*output) );
50  if ( ! output )
52 
53  /* Allocate the data fields. If the number of poles or zeros is 0,
54  the corresponding field(s) should remain null. */
55  if ( numZeros > 0 )
56  if ( ! ( output->zeros = XLALCreateCOMPLEX8Vector( numZeros ) ) )
57  {
60  }
61  if ( numPoles > 0 )
62  if ( ! ( output->poles = XLALCreateCOMPLEX8Vector( numPoles ) ) )
63  {
66  }
67 
68  return output;
69 }
70 
71 /** \see See \ref CreateZPGFilter_c for documentation */
73 {
75  if ( numZeros < 0 || numPoles < 0 )
77  output = LALCalloc( 1, sizeof(*output) );
78  if ( ! output )
80 
81  /* Allocate the data fields. If the number of poles or zeros is 0,
82  the corresponding field(s) should remain null. */
83  if ( numZeros > 0 )
84  if ( ! ( output->zeros = XLALCreateCOMPLEX16Vector( numZeros ) ) )
85  {
88  }
89  if ( numPoles > 0 )
90  if ( ! ( output->poles = XLALCreateCOMPLEX16Vector( numPoles ) ) )
91  {
94  }
95 
96  return output;
97 }
98 
99 /** \see See \ref CreateZPGFilter_c for documentation */
100 void
103  INT4 numZeros,
104  INT4 numPoles )
105 {
106  INITSTATUS(stat);
107 
108  /* Make sure that the output handle exists, but points to a null
109  pointer. */
112 
113  /* Make sure that numZeros and numPoles are non-negative. */
114  ASSERT(numZeros>=0,stat,ZPGFILTERH_EBAD,ZPGFILTERH_MSGEBAD);
115  ASSERT(numPoles>=0,stat,ZPGFILTERH_EBAD,ZPGFILTERH_MSGEBAD);
116 
117  /* Create the output structure. */
118  *output = XLALCreateCOMPLEX8ZPGFilter( numZeros, numPoles );
119  if ( ! *output )
120  {
122  }
123 
124  /* Normal exit */
125  RETURN(stat);
126 }
127 
128 
129 /** \see See \ref CreateZPGFilter_c for documentation */
130 void
133  INT4 numZeros,
134  INT4 numPoles )
135 {
136  INITSTATUS(stat);
137 
138  /* Make sure that the output handle exists, but points to a null
139  pointer. */
142 
143  /* Make sure that numZeros and numPoles are non-negative. */
144  ASSERT(numZeros>=0,stat,ZPGFILTERH_EBAD,ZPGFILTERH_MSGEBAD);
145  ASSERT(numPoles>=0,stat,ZPGFILTERH_EBAD,ZPGFILTERH_MSGEBAD);
146 
147  /* Create the output structure. */
148  *output = XLALCreateCOMPLEX16ZPGFilter( numZeros, numPoles );
149  if ( ! *output )
150  {
152  }
153 
154  /* Normal exit */
155  RETURN(stat);
156 }
157 /** @} */
#define LALCalloc(m, n)
Definition: LALMalloc.h:94
#define ABORT(statusptr, code, mesg)
#define ASSERT(assertion, statusptr, code, mesg)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define ZPGFILTERH_MSGEMEM
Definition: ZPGFilter.h:112
#define ZPGFILTERH_MSGEBAD
Definition: ZPGFilter.h:113
#define ZPGFILTERH_MSGENUL
Definition: ZPGFilter.h:110
#define ZPGFILTERH_MSGEOUT
Definition: ZPGFilter.h:111
COMPLEX16ZPGFilter * XLALCreateCOMPLEX16ZPGFilter(INT4 numZeros, INT4 numPoles)
COMPLEX8ZPGFilter * XLALCreateCOMPLEX8ZPGFilter(INT4 numZeros, INT4 numPoles)
void LALCreateCOMPLEX8ZPGFilter(LALStatus *stat, COMPLEX8ZPGFilter **output, INT4 numZeros, INT4 numPoles)
void LALCreateCOMPLEX16ZPGFilter(LALStatus *stat, COMPLEX16ZPGFilter **output, INT4 numZeros, INT4 numPoles)
void XLALDestroyCOMPLEX8ZPGFilter(COMPLEX8ZPGFilter *filter)
void XLALDestroyCOMPLEX16ZPGFilter(COMPLEX16ZPGFilter *filter)
int32_t INT4
Four-byte signed integer.
COMPLEX16Vector * XLALCreateCOMPLEX16Vector(UINT4 length)
COMPLEX8Vector * XLALCreateCOMPLEX8Vector(UINT4 length)
#define XLAL_ERROR_NULL(...)
Macro to invoke a failure from a XLAL routine returning a pointer.
Definition: XLALError.h:713
@ XLAL_ENOMEM
Memory allocation error.
Definition: XLALError.h:407
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
Definition: XLALError.h:462
@ XLAL_EINVAL
Invalid argument.
Definition: XLALError.h:409
#define ZPGFILTERH_EBAD
Bad filter parameters.
Definition: ZPGFilter.h:106
#define ZPGFILTERH_EOUT
Output handle points to a non-null pointer.
Definition: ZPGFilter.h:104
#define ZPGFILTERH_EMEM
Memory allocation error.
Definition: ZPGFilter.h:105
#define ZPGFILTERH_ENUL
Unexpected null pointer in arguments.
Definition: ZPGFilter.h:103
See DATATYPE-ZPGFilter types for details.
Definition: LALDatatypes.h:930
See DATATYPE-ZPGFilter types for details.
Definition: LALDatatypes.h:921
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
void output(int gps_sec, int output_type)
Definition: tconvert.c:440