LALPulsar  6.1.0.1-89842e6
ComputeFstat_internal.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2013--2015 Karl Wette
3 // Copyright (C) 2015 Reinhard Prix
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with with program; see the file COPYING. If not, write to the
17 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 // MA 02110-1301 USA
19 //
20 
21 #include "config.h"
22 
23 #include <lal/ComputeFstat.h>
24 
25 // ================================================================================================= //
26 // //
27 // This file should **ONLY** contain definitions that **MUST** be shared between F-statistic methods //
28 // //
29 // ================================================================================================= //
30 
31 // ---------- Shared constants/defines ---------- //
32 
33 // ---------- Shared macro definitions ---------- //
34 
35 #define SQ(x) ( (x) * (x) )
36 
37 #define MYMAX(x,y) ( (x) > (y) ? (x) : (y) )
38 #define MYMIN(x,y) ( (x) < (y) ? (x) : (y) )
39 
40 #ifdef __GNUC__
41 #define likely(x) __builtin_expect(!!(x), 1)
42 #define unlikely(x) __builtin_expect(!!(x), 0)
43 #else
44 #define likely(x) (x)
45 #define unlikely(x) (x)
46 #endif
47 
48 // ---------- Shared global variables ---------- //
49 
50 // ---------- Shared struct definitions ---------- //
51 
52 // Common input data for F-statistic methods
53 typedef struct {
54  LIGOTimeGPS midTime; // Mid-time of SFT data
55  REAL8 dFreq; // Requested spacing of \f$ \mathcal{F} \f$ -statistic frequency bins.
56  MultiLALDetector detectors; // List of detectors
57  MultiLIGOTimeGPSVector *multiTimestamps; // Multi-detector list of SFT timestamps
58  MultiNoiseWeights *multiNoiseWeights; // Multi-detector noise weights: stored unnormalized (divide by Sinv_Tsft to get normalized version)
59  MultiDetectorStateSeries *multiDetectorStates; // Multi-detector state series
60  const EphemerisData *ephemerides; // Ephemerides for the time-span of the SFTs
61  SSBprecision SSBprec; // Barycentric transformation precision
62  void *workspace; // F-statistic method workspace
63  BOOLEAN isTimeslice; // Flag if this is a timeslice of another FstatInput struct
64  REAL8 allowedMismatchFromSFTLength; // optional override for XLALFstatCheckSFTLengthMismatch()
65 } FstatCommon;
66 
67 // Pointers to function pointers which perform method-specific operations
68 typedef struct {
69  int ( *compute_func )( // F-statistic method computation function
70  FstatResults *, const FstatCommon *, void *
71  );
72  void ( *method_data_destroy_func )( void * ); // F-statistic method data destructor function
73  void ( *workspace_destroy_func )( void * ); // Workspace destructor function
75 
76 // ---------- Shared internal functions ---------- //
77 
78 static inline REAL4
80 {
81  REAL4 Fa_re = creal( Fa );
82  REAL4 Fa_im = cimag( Fa );
83  REAL4 Fb_re = creal( Fb );
84  REAL4 Fb_im = cimag( Fb );
85 
86  REAL4 twoF = 4; // default fallback = E[2F] in noise when Dinv == 0 due to ill-conditionness of M_munu
87  if ( likely( Dinv > 0 ) ) {
88  twoF = 2.0f * Dinv * ( B * ( SQ( Fa_re ) + SQ( Fa_im ) )
89  + A * ( SQ( Fb_re ) + SQ( Fb_im ) )
90  - 2.0 * C * ( Fa_re * Fb_re + Fa_im * Fb_im )
91  - 2.0 * E * ( - Fa_re * Fb_im + Fa_im * Fb_re ) // nonzero only in RAA case where Ed!=0
92  );
93  }
94 
95  return twoF;
96 
97 } // compute_fstat_from_fa_fb()
#define likely(x)
static REAL4 compute_fstat_from_fa_fb(COMPLEX8 Fa, COMPLEX8 Fb, REAL4 A, REAL4 B, REAL4 C, REAL4 E, REAL4 Dinv)
#define SQ(x)
UINT2 A
Definition: SFTnaming.c:46
UINT2 B
Definition: SFTnaming.c:47
unsigned char BOOLEAN
double REAL8
float complex COMPLEX8
float REAL4
SSBprecision
The precision in calculating the barycentric transformation.
Definition: SSBtimes.h:45
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
MultiDetectorStateSeries * multiDetectorStates
const EphemerisData * ephemerides
SSBprecision SSBprec
REAL8 allowedMismatchFromSFTLength
MultiLALDetector detectors
MultiLIGOTimeGPSVector * multiTimestamps
LIGOTimeGPS midTime
MultiNoiseWeights * multiNoiseWeights
XLALComputeFstat() computed results structure.
Definition: ComputeFstat.h:201
Multi-IFO time-series of DetectorStates.
array of detectors definitions 'LALDetector'
A collection of (multi-IFO) LIGOTimeGPSVector time-stamps vectors.
Definition: SFTfileIO.h:198
One noise-weight (number) per SFT (therefore indexed over IFOs and SFTs.
Definition: PSDutils.h:71