diff --git a/Appl/CEP/CS1/CS1_BGLProc/src/PPF.cc b/Appl/CEP/CS1/CS1_BGLProc/src/PPF.cc index 4851bd28118dc434587e0b10908f31f62225cd0e..665d9519f5c33610027a9b408da8954ba765fca0 100644 --- a/Appl/CEP/CS1/CS1_BGLProc/src/PPF.cc +++ b/Appl/CEP/CS1/CS1_BGLProc/src/PPF.cc @@ -62,7 +62,8 @@ PPF::PPF(unsigned nrStations, unsigned nrSamplesPerIntegration, double channelBa #if !defined PPF_C_IMPLEMENTATION #if NR_BITS_PER_SAMPLE == 4 static const float map[] = { - 0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1, + 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, + -7.5, -6.5, -5.5, -4.5, -3.5, -2.5, -1.5, -0.5, }; for (unsigned i = 0; i < 16; i ++) diff --git a/Appl/CEP/CS1/CS1_BGLProc/test/tBGL_Processing.cc b/Appl/CEP/CS1/CS1_BGLProc/test/tBGL_Processing.cc index d86e62629f274112827f8c0bf7b122164bc42dd0..d17e9cff0491411b3569a34d31c139c229dc4182 100644 --- a/Appl/CEP/CS1/CS1_BGLProc/test/tBGL_Processing.cc +++ b/Appl/CEP/CS1/CS1_BGLProc/test/tBGL_Processing.cc @@ -53,7 +53,7 @@ inline TransposedData::SampleType toComplex(double phi) sincos(phi, &s, &c); #if NR_BITS_PER_SAMPLE == 4 - return makei4complex((int) rint(7 * c), (int) rint(7 * s)); + return makei4complex(8 * c, 8 * s); #elif NR_BITS_PER_SAMPLE == 8 return makei8complex((int) rint(127 * c), (int) rint(127 * s)); #elif NR_BITS_PER_SAMPLE == 16 diff --git a/LCS/Common/include/Common/i4complex.h b/LCS/Common/include/Common/i4complex.h index 956c531feb80b1e89da5feedf7a241aa9f39482f..1748138cbb8eeffedb25f8d04c13aa1c192d43e3 100644 --- a/LCS/Common/include/Common/i4complex.h +++ b/LCS/Common/include/Common/i4complex.h @@ -32,20 +32,20 @@ namespace LOFAR { public: i4complex() {} - i4complex(int real, int imag) { - value = (real & 0xF) | ((imag & 0xF) << 4); + i4complex(double real, double imag) { + value = ((int) rint(real - .5) & 0xF) | (((int) rint(imag - .5) & 0xF) << 4); } - int real() const { - return (signed char) (value << 4) >> 4; // extend sign + double real() const { + return ((signed char) (value << 4) >> 4) + .5; // extend sign } - int imag() const { - return value >> 4; + double imag() const { + return (value >> 4) + .5; } i4complex conj() const { - return i4complex(value ^ 0x80); + return i4complex(value ^ 0xF0); } private: @@ -58,13 +58,13 @@ namespace LOFAR { }; } - inline TYPES::i4complex makei4complex(int real, int imag) + inline TYPES::i4complex makei4complex(double real, double imag) { return TYPES::i4complex(real, imag); } - inline int real(TYPES::i4complex v) + inline double real(TYPES::i4complex v) { return v.real(); } - inline int imag(TYPES::i4complex v) + inline double imag(TYPES::i4complex v) { return v.imag(); } inline TYPES::i4complex conj(TYPES::i4complex x) diff --git a/LCS/Common/include/Common/lofar_complex.h b/LCS/Common/include/Common/lofar_complex.h index 287a6dd380a392529c7ad7bbbcd211eb9fb55313..bc27321758989819a73404d2adfd6cff3484f990 100644 --- a/LCS/Common/include/Common/lofar_complex.h +++ b/LCS/Common/include/Common/lofar_complex.h @@ -71,27 +71,27 @@ namespace LOFAR } inline static i4complex makei4complex(i8complex &z) { - return makei4complex(real(z), imag(z)); + return makei4complex(real(z) - .5, imag(z) - .5); } inline static i4complex makei4complex(i16complex &z) { - return makei4complex(real(z), imag(z)); + return makei4complex(real(z) - .5, imag(z) - .5); } inline static i4complex makei4complex(u16complex &z) { - return makei4complex(real(z), imag(z)); + return makei4complex(real(z) - .5, imag(z) - .5); } inline static i4complex makei4complex(fcomplex &z) { - return makei4complex((int) real(z), (int) imag(z)); + return makei4complex(real(z), imag(z)); } inline static i4complex makei4complex(dcomplex &z) { - return makei4complex((int) real(z), (int) imag(z)); + return makei4complex(real(z), imag(z)); } inline static i8complex makei8complex(i4complex &z) { - return makei8complex(real(z), imag(z)); + return makei8complex((int) real(z), (int) imag(z)); } inline static i8complex makei8complex(i8complex &z) { @@ -115,7 +115,7 @@ namespace LOFAR } inline static i16complex makei16complex(i4complex &z) { - return makei16complex(real(z), imag(z)); + return makei16complex((int) real(z), (int) imag(z)); } inline static i16complex makei16complex(i8complex &z) { @@ -139,7 +139,7 @@ namespace LOFAR } inline static u16complex makeu16complex(i4complex &z) { - return makeu16complex(real(z), imag(z)); + return makeu16complex((int) real(z), (int) imag(z)); } inline static u16complex makeu16complex(i8complex &z) { @@ -163,7 +163,7 @@ namespace LOFAR } inline static fcomplex makefcomplex(i4complex &z) { - return makefcomplex((float) real(z), (float) imag(z)); + return makefcomplex(real(z), imag(z)); } inline static fcomplex makefcomplex(i8complex &z) { @@ -187,7 +187,7 @@ namespace LOFAR } inline static dcomplex makedcomplex(i4complex &z) { - return makedcomplex((double) real(z), (double) imag(z)); + return makedcomplex(real(z), imag(z)); } inline static dcomplex makedcomplex(i8complex &z) {