00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _LIGO_FFTYPE_H
00040 #define _LIGO_FFTYPE_H
00041
00042 #include "PConfig.h"
00043 #include <complex>
00044 #ifdef HAVE_INT_TYPES
00045 #include <inttypes.h>
00046 #endif
00047
00058
00059 namespace framefast {
00060
00061 const int kDefaultFrameVersion = 6;
00062
00063 #ifdef HAVE_INT_TYPES
00065 typedef int8_t int_1s_t;
00067 typedef uint8_t int_1u_t;
00069 typedef int16_t int_2s_t;
00071 typedef uint16_t int_2u_t;
00073 typedef int32_t int_4s_t;
00075 typedef uint32_t int_4u_t;
00077 typedef int64_t int_8s_t;
00079 typedef uint64_t int_8u_t;
00080 #else // take a guess
00081
00082 typedef char int_1s_t;
00083
00084 typedef unsigned char int_1u_t;
00085
00086 typedef short int_2s_t;
00087
00088 typedef unsigned short int_2u_t;
00089
00090 typedef int int_4s_t;
00091
00092 typedef unsigned int int_4u_t;
00093
00094 typedef long long int_8s_t;
00095
00096 typedef unsigned long long int_8u_t;
00097 #endif
00098
00100 typedef float real_4_t;
00102 typedef double real_8_t;
00104 typedef std::complex<float> complex_8_t;
00106 typedef std::complex<double> complex_16_t;
00107
00112 enum frametype {
00114 NONE = 0,
00116 FF = 1,
00118 STF = 2,
00120 MTF = 3
00121 };
00122
00124
00125
00135
00136 #ifndef __CINT__
00138 inline void swap (int_8u_t* ww);
00140 inline void swap (int_8s_t* ww);
00141 #endif
00143 inline void swap (int_4u_t* w);
00145 inline void swap (int_4s_t* ww);
00147 inline void swap (int_2u_t* w);
00149 inline void swap (int_2s_t* ww);
00151 inline void swap (int_1s_t* ww);
00153 inline void swap (int_1u_t* ww);
00155 inline void swap (real_8_t* ww);
00157 inline void swap (real_4_t* w);
00159 inline void swap (complex_8_t* ww);
00161 inline void swap (complex_16_t* ww);
00163 inline bool littleendian ();
00164
00165 }
00167
00168
00169
00171
00172
00173
00175 namespace framefast {
00176 #define byteswap2(a,b) ((char *)&(a))[0] = ((char *)&(b))[1]; ((char *)&(a))[1] = ((char *)&(b))[0];
00177 #define byteswap4(a,b) ((char *)&(a))[0] = ((char *)&(b))[3]; ((char *)&(a))[1] = ((char *)&(b))[2];((char *)&(a))[2] = ((char *)&(b))[1];((char *)&(a))[3] = ((char *)&(b))[0];
00178 #define byteswap8(a,b) ((char *)&(a))[0] = ((char *)&(b))[7]; ((char *)&(a))[1] = ((char *)&(b))[6];((char *)&(a))[2] = ((char *)&(b))[5];((char *)&(a))[3] = ((char *)&(b))[4];((char *)&(a))[4] = ((char *)&(b))[3]; ((char *)&(a))[5] = ((char *)&(b))[2]; ((char *)&(a))[6] = ((char *)&(b))[1]; ((char *)&(a))[7] = ((char *)&(b))[0];
00179
00180 #ifndef __CINT__
00181 inline void swap (int_8u_t* ww)
00182 {
00183 int_8u_t tmp;
00184 byteswap8(tmp, *ww);
00185 *ww = tmp;
00186 }
00187
00188
00189 inline void swap (int_8s_t* ww)
00190 {
00191 swap ((int_8u_t*)ww);
00192 }
00193 #endif
00194
00195
00196 inline void swap (int_4u_t* w)
00197 {
00198 int_4u_t tmp;
00199 byteswap4(tmp, *w);
00200 *w = tmp;
00201 }
00202
00203
00204 inline void swap (int_4s_t* ww)
00205 {
00206 swap ((int_4u_t*)ww);
00207 }
00208
00209
00210 inline void swap (int_2u_t* w)
00211 {
00212 int_2u_t tmp;
00213 byteswap2(tmp, *w);
00214 *w = tmp;
00215 }
00216
00217
00218 inline void swap (int_2s_t* ww)
00219 {
00220 swap ((int_2u_t*)ww);
00221 }
00222
00223
00224 inline void swap (int_1s_t* ww)
00225 {
00226 }
00227
00228
00229 inline void swap (int_1u_t* ww)
00230 {
00231 }
00232
00233
00234 inline void swap (real_8_t* ww)
00235 {
00236 real_8_t tmp;
00237 byteswap8(tmp, *ww);
00238 *ww = tmp;
00239 }
00240
00241
00242 inline void swap (real_4_t* w)
00243 {
00244 real_4_t tmp;
00245 byteswap4(tmp, *w);
00246 *w = tmp;
00247 }
00248
00249
00250 inline void swap (complex_8_t* ww)
00251 {
00252 struct complex {
00253 real_4_t re;
00254 real_4_t im;
00255 };
00256 swap (&((complex*)ww)->re);
00257 swap (&((complex*)ww)->im);
00258 }
00259
00260
00261 inline void swap (complex_16_t* ww)
00262 {
00263 struct complex {
00264 real_8_t re;
00265 real_8_t im;
00266 } ;
00267 swap (&((complex*)ww)->re);
00268 swap (&((complex*)ww)->im);
00269 }
00270
00271 inline bool littleendian () {
00272 int_4u_t test = 0; *(int_1u_t*) &test = 1;
00273 return (test == 1);
00274 }
00275
00276 #undef byteswap2
00277 #undef byteswap4
00278 #undef byteswap8
00279 }
00280
00281 #endif // _LIGO_FFTYPE_H