LALInspiral 5.0.3.1-eeff03c
GetErrorMatrixFromSnglInspiral.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Craig Robinson
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/*----------------------------------------------------------------------------
21 *
22 * File Name: GetErrorMatrixFromSnglInspiral.c
23 *
24 * Author: Craig Robinson
25 *
26 *---------------------------------------------------------------------------*/
27
28#include <math.h>
29#include <lal/LALConstants.h>
30#include <lal/LALStdlib.h>
31#include <lal/LALError.h>
32#include <lal/LALGSL.h>
33#include <lal/LIGOMetadataTables.h>
34#include <lal/CoincInspiralEllipsoid.h>
35
36#include <gsl/gsl_matrix.h>
37#include <gsl/gsl_vector.h>
38#include <gsl/gsl_linalg.h>
39
40/**
41 * \author Craig Robinson
42 * \file
43 * \ingroup CoincInspiralEllipsoid_h
44 *
45 * \brief Blah.
46 *
47 * ### Description ###
48 *
49 * <tt>XLALGetErrorMatrixFromSnglInspiral()</tt> takes in a
50 * \c SnglInspiralTable, and a value for the e-thinca parameter. It returns
51 * a \c gsl_matrix containing the the metric scaled appropriately for the
52 * given e-thinca parameter.
53 *
54 * <tt>XLALGetPositionFromSnglInspiral()</tt> takes in a
55 * \c SnglInspiralTable, and returns the position vector associated with
56 * the trigger in \f$(t_C, \tau_0, \tau_3)\f$ space.
57 *
58 * <tt>XLALSetTimeInPositionVector()</tt> sets the time co-ordinate in the given
59 * position vector to \c time. It returns zero upon successful completion.
60 *
61 */
62
63
64/* Function for getting the error matrix from the metric in
65 * (tc, tau0, tau3) space.
66 */
67
69 REAL8 eMatch
70 )
71
72{
73 gsl_matrix *shape = NULL;
74
75 int xlalStatus;
76
77 if (!event)
78 {
80 }
81
82 /* Allocate memory for the various matrices */
83 XLAL_CALLGSL( shape = gsl_matrix_alloc( 3, 3 ) );
84
85 if ( !shape )
87
88 /* Fill in the elements of the shape matrix */
89 xlalStatus = XLALSetErrorMatrixFromSnglInspiral( shape, event, eMatch );
90 if (xlalStatus != XLAL_SUCCESS )
91 {
92 gsl_matrix_free( shape );
94 }
95
96 return shape;
97}
98
99
100
101
104 REAL8 eMatch
105 )
106
107{
108 gsl_matrix *fisher = NULL;
109 gsl_permutation *p = NULL;
110
111 REAL8 freqRatio0 = 0.0;
112 REAL8 freqRatio3 = 0.0;
113 REAL8 fLow = 0.0;
114 REAL8 mtotal = 0.0;
115
116 int signum;
117 int gslStatus;
118
119 if ( !event )
121
122 if ( !shape )
124
125 if ( shape->size1 != 3 || shape->size1 != shape->size2 )
127
128 if ( !event->Gamma[0] )
129 {
130 XLALPrintError( "Metric components are not set.\n" );
132 }
133
134 if ( eMatch < 0 )
136
137 XLAL_CALLGSL( fisher = gsl_matrix_alloc( 3, 3 ) );
138 XLAL_CALLGSL( p = gsl_permutation_alloc( 3 ) );
139
140 if ( !fisher || !p )
141 {
142 if ( fisher ) gsl_matrix_free( fisher );
143 if ( p ) gsl_permutation_free( p );
145 }
146
147 mtotal = (event->mtotal)*LAL_MTSUN_SI;
148 fLow = 5.0 / (256.0 * event->eta * pow(mtotal, 5.0/3.0) * event->tau0 );
149 fLow = pow(fLow, 3.0/8.0) / LAL_PI;
150 freqRatio0 = pow(fLow, 8.0/3.0);
151 freqRatio3 = pow(fLow, 5.0/3.0);
152
153 /* Fill in the elements of the fisher matrix */
154 gsl_matrix_set( fisher, 0, 0, event->Gamma[0] );
155 gsl_matrix_set( fisher, 0, 1, event->Gamma[1]/freqRatio0 );
156 gsl_matrix_set( fisher, 1, 0, event->Gamma[1]/freqRatio0 );
157 gsl_matrix_set( fisher, 0, 2, event->Gamma[2]/freqRatio3 );
158 gsl_matrix_set( fisher, 2, 0, event->Gamma[2]/freqRatio3 );
159 gsl_matrix_set( fisher, 1, 1, event->Gamma[3]/(freqRatio0*freqRatio0) );
160 gsl_matrix_set( fisher, 1, 2, event->Gamma[4]/(freqRatio0*freqRatio3) );
161 gsl_matrix_set( fisher, 2, 1, event->Gamma[4]/(freqRatio0*freqRatio3) );
162 gsl_matrix_set( fisher, 2, 2, event->Gamma[5]/(freqRatio3*freqRatio3) );
163
164 XLAL_CALLGSL( gslStatus = gsl_matrix_scale( fisher, 1.0 / eMatch ) );
165 if ( gslStatus != GSL_SUCCESS )
166 {
167 gsl_matrix_free( fisher );
168 gsl_permutation_free( p );
170 }
171
172 /* Now invert to get the matrix we need */
173 XLAL_CALLGSL( gslStatus = gsl_linalg_LU_decomp( fisher, p, &signum ) );
174 if ( gslStatus == GSL_SUCCESS )
175 {
176 XLAL_CALLGSL( gslStatus = gsl_linalg_LU_invert( fisher, p, shape ) );
177 }
178
179 gsl_matrix_free( fisher );
180 gsl_permutation_free( p );
181
182 if ( gslStatus != GSL_SUCCESS )
184
185 return XLAL_SUCCESS;
186}
187
188
189/* Returns the position vector in (tc, tau0, tau3) space */
190
192
193{
194 gsl_vector *position = NULL;
195 REAL8 endTime;
196
197 REAL8 freqRatio0 = 0.0;
198 REAL8 freqRatio3 = 0.0;
199 REAL8 fLow = 0.0;
200 REAL8 mtotal = 0.0;
201
202 if ( !table )
204
205 XLAL_CALLGSL( position = gsl_vector_alloc( 3 ) );
206 if ( !position )
208
209 endTime = (REAL8) table->end.gpsSeconds +
210 (REAL8) table->end.gpsNanoSeconds * 1.0e-9;
211
212 mtotal = (table->mtotal)*LAL_MTSUN_SI;
213 fLow = 5.0 / (256.0 * table->eta * pow(mtotal, 5.0/3.0) * table->tau0 );
214 fLow = pow(fLow, 3.0/8.0) / LAL_PI;
215 freqRatio0 = pow(fLow, 8.0/3.0);
216 freqRatio3 = pow(fLow, 5.0/3.0);
217
218 gsl_vector_set( position, 0, endTime );
219 gsl_vector_set( position, 1, freqRatio0*table->tau0 );
220 gsl_vector_set( position, 2, freqRatio3*table->tau3 );
221
222 return position;
223}
224
225
226/* Sets the time in the position vector to the given value */
227
228int XLALSetTimeInPositionVector( gsl_vector *position,
229 REAL8 timeShift)
230
231{
232 if ( !position )
234
235 gsl_vector_set( position, 0, timeShift );
236
237 return XLAL_SUCCESS;
238}
#define XLAL_CALLGSL(statement)
int XLALSetErrorMatrixFromSnglInspiral(gsl_matrix *shape, SnglInspiralTable *event, REAL8 eMatch)
int XLALSetTimeInPositionVector(gsl_vector *position, REAL8 timeShift)
gsl_matrix * XLALGetErrorMatrixFromSnglInspiral(SnglInspiralTable *event, REAL8 eMatch)
gsl_vector * XLALGetPositionFromSnglInspiral(SnglInspiralTable *table)
#define LAL_PI
#define LAL_MTSUN_SI
double REAL8
#define XLAL_ERROR_NULL(...)
#define XLAL_ERROR(...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
XLAL_EBADLEN
XLAL_ENOMEM
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EFUNC
XLAL_EINVAL
p
Definition: _thinca.c:157