|
@@
-1,953
+1,959
|
|
1
|
// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
|
|
1
|
// In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) => R2 FSW
|
|
2
|
// version 1.0: 31/07/2013
|
|
2
|
// version 1.0: 31/07/2013
|
|
3
|
// version 1.1: 02/04/2014
|
|
3
|
// version 1.1: 02/04/2014
|
|
4
|
// version 1.2: 30/04/2014
|
|
4
|
// version 1.2: 30/04/2014
|
|
5
|
// version 1.3: 02/05/2014
|
|
5
|
// version 1.3: 02/05/2014
|
|
6
|
// version 1.4: 16/05/2014
|
|
6
|
// version 1.4: 16/05/2014
|
|
7
|
// version 1.5: 20/05/2014
|
|
7
|
// version 1.5: 20/05/2014
|
|
8
|
// version 1.6: 19/12/2014
|
|
8
|
// version 1.6: 19/12/2014
|
|
9
|
// version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
|
|
9
|
// version 1.7: 15/01/2015 (modifs de Paul + correction erreurs qui se compensaient (LSB <=> MSB + indices [0,2] <=> [1,3])
|
|
10
|
// version 1.8: 02/02/2015 (gestion des divisions par zéro)
|
|
10
|
// version 1.8: 02/02/2015 (gestion des divisions par zéro)
|
|
11
|
// In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
|
|
11
|
// In the frame of RPW LFR Sofware ICD Issue3 Rev6 (27/01/2015) => R3 FSW
|
|
12
|
// version 2.0: 19/06/2015
|
|
12
|
// version 2.0: 19/06/2015
|
|
|
|
|
13
|
// version 2.1: 22/06/2015 (modifs de Paul)
|
|
|
|
|
14
|
|
|
13
|
|
|
15
|
|
|
14
|
#ifndef BASIC_PARAMETERS_H_INCLUDED
|
|
16
|
#ifndef BASIC_PARAMETERS_H_INCLUDED
|
|
15
|
#define BASIC_PARAMETERS_H_INCLUDED
|
|
17
|
#define BASIC_PARAMETERS_H_INCLUDED
|
|
16
|
|
|
18
|
|
|
17
|
#include <math.h>
|
|
19
|
#include <math.h>
|
|
18
|
#include <stdio.h>
|
|
20
|
#include <stdio.h>
|
|
19
|
#include <stdint.h>
|
|
21
|
#include <stdint.h>
|
|
20
|
|
|
22
|
|
|
21
|
#include "basic_parameters_params.h"
|
|
23
|
#include "basic_parameters_params.h"
|
|
22
|
|
|
24
|
|
|
23
|
static inline void BP1_set(float * compressed_spec_mat, float * k_coeff_intercalib, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp1);
|
|
25
|
static inline void BP1_set(float * compressed_spec_mat, float * k_coeff_intercalib, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp1);
|
|
24
|
static inline void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp2);
|
|
26
|
static inline void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp2);
|
|
25
|
|
|
27
|
|
|
|
|
|
28
|
void init_k_coefficients_f0( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
|
|
|
|
|
29
|
void init_k_coefficients_f1( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
|
|
|
|
|
30
|
void init_k_coefficients_f2( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
|
|
|
|
|
31
|
|
|
26
|
void init_k_coefficients( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
|
|
32
|
void init_k_coefficients( float *k_coeff_intercalib, unsigned char nb_binscompressed_matrix );
|
|
27
|
|
|
33
|
|
|
28
|
//***********************************
|
|
34
|
//***********************************
|
|
29
|
// STATIC INLINE FUNCTION DEFINITIONS
|
|
35
|
// STATIC INLINE FUNCTION DEFINITIONS
|
|
30
|
|
|
36
|
|
|
31
|
void BP1_set( float * compressed_spec_mat, float * k_coeff_intercalib, uint8_t nb_bins_compressed_spec_mat, uint8_t * lfr_bp1 ){
|
|
37
|
void BP1_set( float * compressed_spec_mat, float * k_coeff_intercalib, uint8_t nb_bins_compressed_spec_mat, uint8_t * lfr_bp1 ){
|
|
32
|
float PSDB; // 32-bit floating point
|
|
38
|
float PSDB; // 32-bit floating point
|
|
33
|
float PSDE;
|
|
39
|
float PSDE;
|
|
34
|
float tmp;
|
|
40
|
float tmp;
|
|
35
|
float NVEC_V0;
|
|
41
|
float NVEC_V0;
|
|
36
|
float NVEC_V1;
|
|
42
|
float NVEC_V1;
|
|
37
|
float NVEC_V2;
|
|
43
|
float NVEC_V2;
|
|
38
|
float aux;
|
|
44
|
float aux;
|
|
39
|
float tr_SB_SB;
|
|
45
|
float tr_SB_SB;
|
|
40
|
float e_cross_b_re;
|
|
46
|
float e_cross_b_re;
|
|
41
|
float e_cross_b_im;
|
|
47
|
float e_cross_b_im;
|
|
42
|
float n_cross_e_scal_b_re;
|
|
48
|
float n_cross_e_scal_b_re;
|
|
43
|
float n_cross_e_scal_b_im;
|
|
49
|
float n_cross_e_scal_b_im;
|
|
44
|
float ny;
|
|
50
|
float ny;
|
|
45
|
float nz;
|
|
51
|
float nz;
|
|
46
|
float bx_bx_star;
|
|
52
|
float bx_bx_star;
|
|
47
|
float vphi;
|
|
53
|
float vphi;
|
|
48
|
float significand;
|
|
54
|
float significand;
|
|
49
|
int exponent; // 32-bit signed integer
|
|
55
|
int exponent; // 32-bit signed integer
|
|
50
|
float alpha_M;
|
|
56
|
float alpha_M;
|
|
51
|
|
|
57
|
|
|
52
|
uint8_t nbitexp; // 8-bit unsigned integer
|
|
58
|
uint8_t nbitexp; // 8-bit unsigned integer
|
|
53
|
uint8_t nbitsig;
|
|
59
|
uint8_t nbitsig;
|
|
54
|
uint8_t tmp_uint8;
|
|
60
|
uint8_t tmp_uint8;
|
|
55
|
uint8_t *pt_uint8; // pointer on unsigned 8-bit integer
|
|
61
|
uint8_t *pt_uint8; // pointer on unsigned 8-bit integer
|
|
56
|
int8_t expmin; // 8-bit signed integer
|
|
62
|
int8_t expmin; // 8-bit signed integer
|
|
57
|
int8_t expmax;
|
|
63
|
int8_t expmax;
|
|
58
|
uint16_t rangesig; // 16-bit unsigned integer
|
|
64
|
uint16_t rangesig; // 16-bit unsigned integer
|
|
59
|
uint16_t psd;
|
|
65
|
uint16_t psd;
|
|
60
|
uint16_t exp;
|
|
66
|
uint16_t exp;
|
|
61
|
uint16_t tmp_uint16;
|
|
67
|
uint16_t tmp_uint16;
|
|
62
|
uint16_t i;
|
|
68
|
uint16_t i;
|
|
63
|
|
|
69
|
|
|
64
|
alpha_M = 45 * (3.1415927/180);
|
|
70
|
alpha_M = 45 * (3.1415927/180);
|
|
65
|
|
|
71
|
|
|
66
|
#ifdef DEBUG_TCH
|
|
72
|
#ifdef DEBUG_TCH
|
|
67
|
printf("BP1 : \n");
|
|
73
|
printf("BP1 : \n");
|
|
68
|
printf("Number of bins: %d\n", nb_bins_compressed_spec_mat);
|
|
74
|
printf("Number of bins: %d\n", nb_bins_compressed_spec_mat);
|
|
69
|
#endif
|
|
75
|
#endif
|
|
70
|
|
|
76
|
|
|
71
|
// initialization for managing the exponents of the floating point data:
|
|
77
|
// initialization for managing the exponents of the floating point data:
|
|
72
|
nbitexp = 6; // number of bits for the exponent
|
|
78
|
nbitexp = 6; // number of bits for the exponent
|
|
73
|
expmax = 32+5; // maximum value of the exponent
|
|
79
|
expmax = 32+5; // maximum value of the exponent
|
|
74
|
expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value
|
|
80
|
expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value
|
|
75
|
// for floating point data to be recorded on 16-bit words:
|
|
81
|
// for floating point data to be recorded on 16-bit words:
|
|
76
|
nbitsig = 16 - nbitexp; // number of bits for the significand
|
|
82
|
nbitsig = 16 - nbitexp; // number of bits for the significand
|
|
77
|
rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
|
|
83
|
rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
|
|
78
|
|
|
84
|
|
|
79
|
#ifdef DEBUG_TCH
|
|
85
|
#ifdef DEBUG_TCH
|
|
80
|
printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin);
|
|
86
|
printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin);
|
|
81
|
printf("nbitsig : %d, rangesig : %d\n", nbitsig, rangesig);
|
|
87
|
printf("nbitsig : %d, rangesig : %d\n", nbitsig, rangesig);
|
|
82
|
#endif
|
|
88
|
#endif
|
|
83
|
|
|
89
|
|
|
84
|
for(i=0; i<nb_bins_compressed_spec_mat; i++){
|
|
90
|
for(i=0; i<nb_bins_compressed_spec_mat; i++){
|
|
85
|
//==============================================
|
|
91
|
//==============================================
|
|
86
|
// BP1 PSDB == PA_LFR_SC_BP1_PB_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
|
|
92
|
// BP1 PSDB == PA_LFR_SC_BP1_PB_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
|
|
87
|
PSDB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] // S11
|
|
93
|
PSDB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] // S11
|
|
88
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22
|
|
94
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22
|
|
89
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]; // S33
|
|
95
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]; // S33
|
|
90
|
|
|
96
|
|
|
91
|
significand = frexpf(PSDB, &exponent); // 0.5 <= significand < 1
|
|
97
|
significand = frexpf(PSDB, &exponent); // 0.5 <= significand < 1
|
|
92
|
// PSDB = significand * 2^exponent
|
|
98
|
// PSDB = significand * 2^exponent
|
|
93
|
|
|
99
|
|
|
94
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
100
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
95
|
exponent = expmin;
|
|
101
|
exponent = expmin;
|
|
96
|
significand = 0.5; // min value that can be recorded
|
|
102
|
significand = 0.5; // min value that can be recorded
|
|
97
|
}
|
|
103
|
}
|
|
98
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
104
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
99
|
exponent = expmax;
|
|
105
|
exponent = expmax;
|
|
100
|
significand = 1.0; // max value that can be recorded
|
|
106
|
significand = 1.0; // max value that can be recorded
|
|
101
|
}
|
|
107
|
}
|
|
102
|
if (significand == 0) { // in that case exponent == 0 too
|
|
108
|
if (significand == 0) { // in that case exponent == 0 too
|
|
103
|
exponent = expmin;
|
|
109
|
exponent = expmin;
|
|
104
|
significand = 0.5; // min value that can be recorded
|
|
110
|
significand = 0.5; // min value that can be recorded
|
|
105
|
}
|
|
111
|
}
|
|
106
|
|
|
112
|
|
|
107
|
psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
113
|
psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
108
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
114
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
109
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
115
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
110
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
116
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
111
|
tmp_uint16 = psd | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
117
|
tmp_uint16 = psd | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
112
|
// left place of the significand bits (nbitsig),
|
|
118
|
// left place of the significand bits (nbitsig),
|
|
113
|
// making the 16-bit word to be recorded
|
|
119
|
// making the 16-bit word to be recorded
|
|
114
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
120
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
115
|
#ifdef MSB_FIRST_TCH
|
|
121
|
#ifdef MSB_FIRST_TCH
|
|
116
|
lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
122
|
lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
117
|
lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
123
|
lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
118
|
#endif
|
|
124
|
#endif
|
|
119
|
#ifdef LSB_FIRST_TCH
|
|
125
|
#ifdef LSB_FIRST_TCH
|
|
120
|
lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
126
|
lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
121
|
lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
127
|
lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
122
|
#endif
|
|
128
|
#endif
|
|
123
|
#ifdef DEBUG_TCH
|
|
129
|
#ifdef DEBUG_TCH
|
|
124
|
printf("\nBin number: %d\n", i);
|
|
130
|
printf("\nBin number: %d\n", i);
|
|
125
|
printf("PSDB : %16.8e\n",PSDB);
|
|
131
|
printf("PSDB : %16.8e\n",PSDB);
|
|
126
|
printf("significand : %16.8e\n",significand);
|
|
132
|
printf("significand : %16.8e\n",significand);
|
|
127
|
printf("exponent : %d\n" ,exponent);
|
|
133
|
printf("exponent : %d\n" ,exponent);
|
|
128
|
printf("psd for PSDB significand : %d\n",psd);
|
|
134
|
printf("psd for PSDB significand : %d\n",psd);
|
|
129
|
printf("exp for PSDB exponent : %d\n",exp);
|
|
135
|
printf("exp for PSDB exponent : %d\n",exp);
|
|
130
|
printf("pt_uint8[1] for PSDB exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]);
|
|
136
|
printf("pt_uint8[1] for PSDB exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]);
|
|
131
|
printf("pt_uint8[0] for PSDB significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]);
|
|
137
|
printf("pt_uint8[0] for PSDB significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]);
|
|
132
|
printf("lfr_bp1[i*NB_BYTES_BP1+2] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+2], lfr_bp1[i*NB_BYTES_BP1+2]);
|
|
138
|
printf("lfr_bp1[i*NB_BYTES_BP1+2] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+2], lfr_bp1[i*NB_BYTES_BP1+2]);
|
|
133
|
printf("lfr_bp1[i*NB_BYTES_BP1+3] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+3], lfr_bp1[i*NB_BYTES_BP1+3]);
|
|
139
|
printf("lfr_bp1[i*NB_BYTES_BP1+3] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+3], lfr_bp1[i*NB_BYTES_BP1+3]);
|
|
134
|
#endif
|
|
140
|
#endif
|
|
135
|
//==============================================
|
|
141
|
//==============================================
|
|
136
|
// BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
|
|
142
|
// BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 16 bits = 6 bits (exponent) + 10 bits (significand)
|
|
137
|
PSDE = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K44_PE] // S44
|
|
143
|
PSDE = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K44_PE] // S44
|
|
138
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K55_PE] // S55
|
|
144
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K55_PE] // S55
|
|
139
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K45_PE_RE] // S45 Re
|
|
145
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K45_PE_RE] // S45 Re
|
|
140
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K45_PE_IM]; // S45 Im
|
|
146
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] * k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K45_PE_IM]; // S45 Im
|
|
141
|
|
|
147
|
|
|
142
|
significand = frexpf(PSDE, &exponent); // 0.5 <= significand < 1
|
|
148
|
significand = frexpf(PSDE, &exponent); // 0.5 <= significand < 1
|
|
143
|
// PSDE = significand * 2^exponent
|
|
149
|
// PSDE = significand * 2^exponent
|
|
144
|
|
|
150
|
|
|
145
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
151
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
146
|
exponent = expmin;
|
|
152
|
exponent = expmin;
|
|
147
|
significand = 0.5; // min value that can be recorded
|
|
153
|
significand = 0.5; // min value that can be recorded
|
|
148
|
}
|
|
154
|
}
|
|
149
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
155
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
150
|
exponent = expmax;
|
|
156
|
exponent = expmax;
|
|
151
|
significand = 1.0; // max value that can be recorded
|
|
157
|
significand = 1.0; // max value that can be recorded
|
|
152
|
}
|
|
158
|
}
|
|
153
|
if (significand == 0) {// in that case exponent == 0 too
|
|
159
|
if (significand == 0) {// in that case exponent == 0 too
|
|
154
|
exponent = expmin;
|
|
160
|
exponent = expmin;
|
|
155
|
significand = 0.5; // min value that can be recorded
|
|
161
|
significand = 0.5; // min value that can be recorded
|
|
156
|
}
|
|
162
|
}
|
|
157
|
|
|
163
|
|
|
158
|
psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
164
|
psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
159
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
165
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
160
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
166
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
161
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
167
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
162
|
tmp_uint16 = psd | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
168
|
tmp_uint16 = psd | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
163
|
// left place of the significand bits (nbitsig),
|
|
169
|
// left place of the significand bits (nbitsig),
|
|
164
|
// making the 16-bit word to be recorded
|
|
170
|
// making the 16-bit word to be recorded
|
|
165
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
171
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
166
|
#ifdef MSB_FIRST_TCH
|
|
172
|
#ifdef MSB_FIRST_TCH
|
|
167
|
lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
173
|
lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
168
|
lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
174
|
lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
169
|
#endif
|
|
175
|
#endif
|
|
170
|
#ifdef LSB_FIRST_TCH
|
|
176
|
#ifdef LSB_FIRST_TCH
|
|
171
|
lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
177
|
lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
172
|
lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
178
|
lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
173
|
#endif
|
|
179
|
#endif
|
|
174
|
#ifdef DEBUG_TCH
|
|
180
|
#ifdef DEBUG_TCH
|
|
175
|
printf("PSDE : %16.8e\n",PSDE);
|
|
181
|
printf("PSDE : %16.8e\n",PSDE);
|
|
176
|
printf("significand : %16.8e\n",significand);
|
|
182
|
printf("significand : %16.8e\n",significand);
|
|
177
|
printf("exponent : %d\n" ,exponent);
|
|
183
|
printf("exponent : %d\n" ,exponent);
|
|
178
|
printf("psd for PSDE significand : %d\n",psd);
|
|
184
|
printf("psd for PSDE significand : %d\n",psd);
|
|
179
|
printf("exp for PSDE exponent : %d\n",exp);
|
|
185
|
printf("exp for PSDE exponent : %d\n",exp);
|
|
180
|
printf("pt_uint8[1] for PSDE exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]);
|
|
186
|
printf("pt_uint8[1] for PSDE exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]);
|
|
181
|
printf("pt_uint8[0] for PSDE significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]);
|
|
187
|
printf("pt_uint8[0] for PSDE significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]);
|
|
182
|
printf("lfr_bp1[i*NB_BYTES_BP1+0] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+0], lfr_bp1[i*NB_BYTES_BP1+0]);
|
|
188
|
printf("lfr_bp1[i*NB_BYTES_BP1+0] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+0], lfr_bp1[i*NB_BYTES_BP1+0]);
|
|
183
|
printf("lfr_bp1[i*NB_BYTES_BP1+1] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+1], lfr_bp1[i*NB_BYTES_BP1+1]);
|
|
189
|
printf("lfr_bp1[i*NB_BYTES_BP1+1] : %.3d or %.2x\n",lfr_bp1[i*NB_BYTES_BP1+1], lfr_bp1[i*NB_BYTES_BP1+1]);
|
|
184
|
#endif
|
|
190
|
#endif
|
|
185
|
//==============================================================================
|
|
191
|
//==============================================================================
|
|
186
|
// BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
|
|
192
|
// BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
|
|
187
|
// == PA_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
|
|
193
|
// == PA_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
|
|
188
|
// == PA_LFR_SC_BP1_NVEC_V2_F0 == 1 sign bit
|
|
194
|
// == PA_LFR_SC_BP1_NVEC_V2_F0 == 1 sign bit
|
|
189
|
tmp = sqrt( compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] //Im S12
|
|
195
|
tmp = sqrt( compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] //Im S12
|
|
190
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] //Im S13
|
|
196
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] //Im S13
|
|
191
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] //Im S23
|
|
197
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] //Im S23
|
|
192
|
);
|
|
198
|
);
|
|
193
|
if (tmp != 0.) { // no division by 0.
|
|
199
|
if (tmp != 0.) { // no division by 0.
|
|
194
|
NVEC_V0 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]/ tmp; // S23 Im => n1
|
|
200
|
NVEC_V0 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]/ tmp; // S23 Im => n1
|
|
195
|
NVEC_V1 = -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / tmp; // S13 Im => n2
|
|
201
|
NVEC_V1 = -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / tmp; // S13 Im => n2
|
|
196
|
NVEC_V2 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / tmp; // S12 Im => n3
|
|
202
|
NVEC_V2 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / tmp; // S12 Im => n3
|
|
197
|
}
|
|
203
|
}
|
|
198
|
else
|
|
204
|
else
|
|
199
|
{
|
|
205
|
{
|
|
200
|
NVEC_V0 = 0.;
|
|
206
|
NVEC_V0 = 0.;
|
|
201
|
NVEC_V1 = 0.;
|
|
207
|
NVEC_V1 = 0.;
|
|
202
|
NVEC_V2 = 0.;
|
|
208
|
NVEC_V2 = 0.;
|
|
203
|
}
|
|
209
|
}
|
|
204
|
lfr_bp1[i*NB_BYTES_BP1+4] = (uint8_t) (NVEC_V0*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
210
|
lfr_bp1[i*NB_BYTES_BP1+4] = (uint8_t) (NVEC_V0*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
205
|
lfr_bp1[i*NB_BYTES_BP1+5] = (uint8_t) (NVEC_V1*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
211
|
lfr_bp1[i*NB_BYTES_BP1+5] = (uint8_t) (NVEC_V1*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
206
|
pt_uint8 = (uint8_t*) &NVEC_V2; // Affect an uint8_t pointer with the adress of NVEC_V2
|
|
212
|
pt_uint8 = (uint8_t*) &NVEC_V2; // Affect an uint8_t pointer with the adress of NVEC_V2
|
|
207
|
#ifdef LSB_FIRST_TCH
|
|
213
|
#ifdef LSB_FIRST_TCH
|
|
208
|
lfr_bp1[i*NB_BYTES_BP1+6] = pt_uint8[3] & 0x80; // Extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 4th octet:PC convention)
|
|
214
|
lfr_bp1[i*NB_BYTES_BP1+6] = pt_uint8[3] & 0x80; // Extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 4th octet:PC convention)
|
|
209
|
// Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
|
|
215
|
// Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
|
|
210
|
#endif
|
|
216
|
#endif
|
|
211
|
#ifdef MSB_FIRST_TCH
|
|
217
|
#ifdef MSB_FIRST_TCH
|
|
212
|
lfr_bp1[i*NB_BYTES_BP1+6] = pt_uint8[0] & 0x80; // Extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 1th octet:SPARC convention)
|
|
218
|
lfr_bp1[i*NB_BYTES_BP1+6] = pt_uint8[0] & 0x80; // Extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 1th octet:SPARC convention)
|
|
213
|
// Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
|
|
219
|
// Record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
|
|
214
|
#endif
|
|
220
|
#endif
|
|
215
|
#ifdef DEBUG_TCH
|
|
221
|
#ifdef DEBUG_TCH
|
|
216
|
printf("NVEC_V0 : %16.8e\n",NVEC_V0);
|
|
222
|
printf("NVEC_V0 : %16.8e\n",NVEC_V0);
|
|
217
|
printf("NVEC_V1 : %16.8e\n",NVEC_V1);
|
|
223
|
printf("NVEC_V1 : %16.8e\n",NVEC_V1);
|
|
218
|
printf("NVEC_V2 : %16.8e\n",NVEC_V2);
|
|
224
|
printf("NVEC_V2 : %16.8e\n",NVEC_V2);
|
|
219
|
printf("lfr_bp1[i*NB_BYTES_BP1+4] for NVEC_V0 : %u\n",lfr_bp1[i*NB_BYTES_BP1+4]);
|
|
225
|
printf("lfr_bp1[i*NB_BYTES_BP1+4] for NVEC_V0 : %u\n",lfr_bp1[i*NB_BYTES_BP1+4]);
|
|
220
|
printf("lfr_bp1[i*NB_BYTES_BP1+5] for NVEC_V1 : %u\n",lfr_bp1[i*NB_BYTES_BP1+5]);
|
|
226
|
printf("lfr_bp1[i*NB_BYTES_BP1+5] for NVEC_V1 : %u\n",lfr_bp1[i*NB_BYTES_BP1+5]);
|
|
221
|
printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
|
|
227
|
printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
|
|
222
|
#endif
|
|
228
|
#endif
|
|
223
|
//=======================================================
|
|
229
|
//=======================================================
|
|
224
|
// BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits
|
|
230
|
// BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits
|
|
225
|
if (PSDB != 0.) { // no division by 0.
|
|
231
|
if (PSDB != 0.) { // no division by 0.
|
|
226
|
aux = 2*tmp / PSDB; // Compute the ellipticity
|
|
232
|
aux = 2*tmp / PSDB; // Compute the ellipticity
|
|
227
|
}
|
|
233
|
}
|
|
228
|
else
|
|
234
|
else
|
|
229
|
{
|
|
235
|
{
|
|
230
|
aux = 0.;
|
|
236
|
aux = 0.;
|
|
231
|
}
|
|
237
|
}
|
|
232
|
tmp_uint8 = (uint8_t) (aux*15 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
|
|
238
|
tmp_uint8 = (uint8_t) (aux*15 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
|
|
233
|
// where just the first 4 bits are used (0, ..., 15)
|
|
239
|
// where just the first 4 bits are used (0, ..., 15)
|
|
234
|
lfr_bp1[i*NB_BYTES_BP1+6] = lfr_bp1[i*NB_BYTES_BP1+6] | (tmp_uint8 << 3); // Put these 4 bits next to the right place
|
|
240
|
lfr_bp1[i*NB_BYTES_BP1+6] = lfr_bp1[i*NB_BYTES_BP1+6] | (tmp_uint8 << 3); // Put these 4 bits next to the right place
|
|
235
|
// of the sign bit of NVEC_V2 (recorded
|
|
241
|
// of the sign bit of NVEC_V2 (recorded
|
|
236
|
// previously in lfr_bp1[i*NB_BYTES_BP1+6])
|
|
242
|
// previously in lfr_bp1[i*NB_BYTES_BP1+6])
|
|
237
|
#ifdef DEBUG_TCH
|
|
243
|
#ifdef DEBUG_TCH
|
|
238
|
printf("ellipticity : %16.8e\n",aux);
|
|
244
|
printf("ellipticity : %16.8e\n",aux);
|
|
239
|
printf("tmp_uint8 for ellipticity : %u\n",tmp_uint8);
|
|
245
|
printf("tmp_uint8 for ellipticity : %u\n",tmp_uint8);
|
|
240
|
printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
|
|
246
|
printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
|
|
241
|
#endif
|
|
247
|
#endif
|
|
242
|
//==============================================================
|
|
248
|
//==============================================================
|
|
243
|
// BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits
|
|
249
|
// BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits
|
|
244
|
tr_SB_SB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]
|
|
250
|
tr_SB_SB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]
|
|
245
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]
|
|
251
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]
|
|
246
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]
|
|
252
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]
|
|
247
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1]
|
|
253
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1]
|
|
248
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2]
|
|
254
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2]
|
|
249
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3]
|
|
255
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3]
|
|
250
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4]
|
|
256
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4]
|
|
251
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]
|
|
257
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]
|
|
252
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11];
|
|
258
|
+ 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11];
|
|
253
|
aux = PSDB*PSDB;
|
|
259
|
aux = PSDB*PSDB;
|
|
254
|
if (aux != 0.) { // no division by 0.
|
|
260
|
if (aux != 0.) { // no division by 0.
|
|
255
|
tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // Compute the degree of polarisation
|
|
261
|
tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // Compute the degree of polarisation
|
|
256
|
}
|
|
262
|
}
|
|
257
|
else
|
|
263
|
else
|
|
258
|
{
|
|
264
|
{
|
|
259
|
tmp = 0.;
|
|
265
|
tmp = 0.;
|
|
260
|
}
|
|
266
|
}
|
|
261
|
tmp_uint8 = (uint8_t) (tmp*7 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
|
|
267
|
tmp_uint8 = (uint8_t) (tmp*7 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
|
|
262
|
// where just the first 3 bits are used (0, ..., 7)
|
|
268
|
// where just the first 3 bits are used (0, ..., 7)
|
|
263
|
lfr_bp1[i*NB_BYTES_BP1+6] = lfr_bp1[i*NB_BYTES_BP1+6] | tmp_uint8; // Record these 3 bits at the 3 first bit positions
|
|
269
|
lfr_bp1[i*NB_BYTES_BP1+6] = lfr_bp1[i*NB_BYTES_BP1+6] | tmp_uint8; // Record these 3 bits at the 3 first bit positions
|
|
264
|
// (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
|
|
270
|
// (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
|
|
265
|
#ifdef DEBUG_TCH
|
|
271
|
#ifdef DEBUG_TCH
|
|
266
|
printf("DOP : %16.8e\n",tmp);
|
|
272
|
printf("DOP : %16.8e\n",tmp);
|
|
267
|
printf("tmp_uint8 for DOP : %u\n",tmp_uint8);
|
|
273
|
printf("tmp_uint8 for DOP : %u\n",tmp_uint8);
|
|
268
|
printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity + DOP : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
|
|
274
|
printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity + DOP : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
|
|
269
|
#endif
|
|
275
|
#endif
|
|
270
|
//=======================================================================================
|
|
276
|
//=======================================================================================
|
|
271
|
// BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 16 bits
|
|
277
|
// BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 16 bits
|
|
272
|
// = 1 sign bit + 1 argument bit (two sectors)
|
|
278
|
// = 1 sign bit + 1 argument bit (two sectors)
|
|
273
|
// + 6 bits (exponent) + 8 bits (significand)
|
|
279
|
// + 6 bits (exponent) + 8 bits (significand)
|
|
274
|
e_cross_b_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_RE] //S34 Re
|
|
280
|
e_cross_b_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_RE] //S34 Re
|
|
275
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_RE] //S35 Re
|
|
281
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_RE] //S35 Re
|
|
276
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_RE] //S14 Re
|
|
282
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_RE] //S14 Re
|
|
277
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_RE] //S15 Re
|
|
283
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_RE] //S15 Re
|
|
278
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_RE] //S24 Re
|
|
284
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_RE] //S24 Re
|
|
279
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_RE] //S25 Re
|
|
285
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_RE] //S25 Re
|
|
280
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_IM] //S34 Im
|
|
286
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_IM] //S34 Im
|
|
281
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_IM] //S35 Im
|
|
287
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_IM] //S35 Im
|
|
282
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_IM] //S14 Im
|
|
288
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_IM] //S14 Im
|
|
283
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_IM] //S15 Im
|
|
289
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_IM] //S15 Im
|
|
284
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_IM] //S24 Im
|
|
290
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_IM] //S24 Im
|
|
285
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_IM]; //S25 Im
|
|
291
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_IM]; //S25 Im
|
|
286
|
// Im(S_ji) = -Im(S_ij)
|
|
292
|
// Im(S_ji) = -Im(S_ij)
|
|
287
|
// k_ji = k_ij
|
|
293
|
// k_ji = k_ij
|
|
288
|
e_cross_b_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_IM] //S34 Re
|
|
294
|
e_cross_b_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_IM] //S34 Re
|
|
289
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_IM] //S35 Re
|
|
295
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_IM] //S35 Re
|
|
290
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_IM] //S14 Re
|
|
296
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_IM] //S14 Re
|
|
291
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_IM] //S15 Re
|
|
297
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_IM] //S15 Re
|
|
292
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_IM] //S24 Re
|
|
298
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_IM] //S24 Re
|
|
293
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_IM] //S25 Re
|
|
299
|
+ compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_IM] //S25 Re
|
|
294
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_RE] //S34 Im
|
|
300
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_SX_RE] //S34 Im
|
|
295
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_RE] //S35 Im
|
|
301
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_SX_RE] //S35 Im
|
|
296
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_RE] //S14 Im
|
|
302
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K14_SX_RE] //S14 Im
|
|
297
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_RE] //S15 Im
|
|
303
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] *k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K15_SX_RE] //S15 Im
|
|
298
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_RE] //S24 Im
|
|
304
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_SX_RE] //S24 Im
|
|
299
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_RE]; //S25 Im
|
|
305
|
- compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_SX_RE]; //S25 Im
|
|
300
|
#ifdef DEBUG_TCH
|
|
306
|
#ifdef DEBUG_TCH
|
|
301
|
printf("ReaSX : %16.8e\n",e_cross_b_re);
|
|
307
|
printf("ReaSX : %16.8e\n",e_cross_b_re);
|
|
302
|
#endif
|
|
308
|
#endif
|
|
303
|
pt_uint8 = (uint8_t*) &e_cross_b_re; // Affect an uint8_t pointer with the adress of e_cross_b_re
|
|
309
|
pt_uint8 = (uint8_t*) &e_cross_b_re; // Affect an uint8_t pointer with the adress of e_cross_b_re
|
|
304
|
#ifdef LSB_FIRST_TCH
|
|
310
|
#ifdef LSB_FIRST_TCH
|
|
305
|
lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
|
|
311
|
lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
|
|
306
|
// Record it at the 8th bit position (from the right to the left)
|
|
312
|
// Record it at the 8th bit position (from the right to the left)
|
|
307
|
// of lfr_bp1[i*NB_BYTES_BP1+7]
|
|
313
|
// of lfr_bp1[i*NB_BYTES_BP1+7]
|
|
308
|
pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
|
|
314
|
pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
|
|
309
|
#endif
|
|
315
|
#endif
|
|
310
|
#ifdef MSB_FIRST_TCH
|
|
316
|
#ifdef MSB_FIRST_TCH
|
|
311
|
lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention)
|
|
317
|
lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention)
|
|
312
|
// Record it at the 8th bit position (from the right to the left)
|
|
318
|
// Record it at the 8th bit position (from the right to the left)
|
|
313
|
// of lfr_bp1[i*NB_BYTES_BP1+7]
|
|
319
|
// of lfr_bp1[i*NB_BYTES_BP1+7]
|
|
314
|
pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
|
|
320
|
pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
|
|
315
|
#endif
|
|
321
|
#endif
|
|
316
|
significand = frexpf(e_cross_b_re, &exponent); // 0.5 <= significand < 1
|
|
322
|
significand = frexpf(e_cross_b_re, &exponent); // 0.5 <= significand < 1
|
|
317
|
// ReaSX = significand * 2^exponent
|
|
323
|
// ReaSX = significand * 2^exponent
|
|
318
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
324
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
319
|
exponent = expmin;
|
|
325
|
exponent = expmin;
|
|
320
|
significand = 0.5; // min value that can be recorded
|
|
326
|
significand = 0.5; // min value that can be recorded
|
|
321
|
}
|
|
327
|
}
|
|
322
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
328
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
323
|
exponent = expmax;
|
|
329
|
exponent = expmax;
|
|
324
|
significand = 1.0; // max value that can be recorded
|
|
330
|
significand = 1.0; // max value that can be recorded
|
|
325
|
}
|
|
331
|
}
|
|
326
|
if (significand == 0) { // in that case exponent == 0 too
|
|
332
|
if (significand == 0) { // in that case exponent == 0 too
|
|
327
|
exponent = expmin;
|
|
333
|
exponent = expmin;
|
|
328
|
significand = 0.5; // min value that can be recorded
|
|
334
|
significand = 0.5; // min value that can be recorded
|
|
329
|
}
|
|
335
|
}
|
|
330
|
|
|
336
|
|
|
331
|
lfr_bp1[i*NB_BYTES_BP1+8] = (uint8_t) ((significand*2-1)*255 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
|
|
337
|
lfr_bp1[i*NB_BYTES_BP1+8] = (uint8_t) ((significand*2-1)*255 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
|
|
332
|
// where all bits are used (0, ..., 255)
|
|
338
|
// where all bits are used (0, ..., 255)
|
|
333
|
tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
|
|
339
|
tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
|
|
334
|
// just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
340
|
// just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
335
|
#ifdef DEBUG_TCH
|
|
341
|
#ifdef DEBUG_TCH
|
|
336
|
printf("|ReaSX| : %16.8e\n",e_cross_b_re);
|
|
342
|
printf("|ReaSX| : %16.8e\n",e_cross_b_re);
|
|
337
|
printf("significand : %16.8e\n",significand);
|
|
343
|
printf("significand : %16.8e\n",significand);
|
|
338
|
printf("exponent : %d\n" ,exponent);
|
|
344
|
printf("exponent : %d\n" ,exponent);
|
|
339
|
printf("tmp_uint8 for ReaSX exponent : %d\n",tmp_uint8);
|
|
345
|
printf("tmp_uint8 for ReaSX exponent : %d\n",tmp_uint8);
|
|
340
|
#endif
|
|
346
|
#endif
|
|
341
|
lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | tmp_uint8; // Record these nbitexp bits in the nbitexp first bits
|
|
347
|
lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | tmp_uint8; // Record these nbitexp bits in the nbitexp first bits
|
|
342
|
// (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+7]
|
|
348
|
// (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+7]
|
|
343
|
#ifdef DEBUG_TCH
|
|
349
|
#ifdef DEBUG_TCH
|
|
344
|
printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX sign + RealSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
|
|
350
|
printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX sign + RealSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
|
|
345
|
printf("lfr_bp1[i*NB_BYTES_BP1+8] for ReaSX significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]);
|
|
351
|
printf("lfr_bp1[i*NB_BYTES_BP1+8] for ReaSX significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]);
|
|
346
|
printf("ImaSX : %16.8e\n",e_cross_b_im);
|
|
352
|
printf("ImaSX : %16.8e\n",e_cross_b_im);
|
|
347
|
#endif
|
|
353
|
#endif
|
|
348
|
pt_uint8 = (uint8_t*) &e_cross_b_im; // Affect an uint8_t pointer with the adress of e_cross_b_im
|
|
354
|
pt_uint8 = (uint8_t*) &e_cross_b_im; // Affect an uint8_t pointer with the adress of e_cross_b_im
|
|
349
|
#ifdef LSB_FIRST_TCH
|
|
355
|
#ifdef LSB_FIRST_TCH
|
|
350
|
pt_uint8[3] = pt_uint8[3] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| (32-bit float, sign bit in the 4th octet:PC convention)
|
|
356
|
pt_uint8[3] = pt_uint8[3] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| (32-bit float, sign bit in the 4th octet:PC convention)
|
|
351
|
#endif
|
|
357
|
#endif
|
|
352
|
#ifdef MSB_FIRST_TCH
|
|
358
|
#ifdef MSB_FIRST_TCH
|
|
353
|
pt_uint8[0] = pt_uint8[0] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| (32-bit float, sign bit in the 1th octet:SPARC convention)
|
|
359
|
pt_uint8[0] = pt_uint8[0] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX| (32-bit float, sign bit in the 1th octet:SPARC convention)
|
|
354
|
#endif
|
|
360
|
#endif
|
|
355
|
tmp_uint8 = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect
|
|
361
|
tmp_uint8 = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect
|
|
356
|
// an unsigned 8-bit char with 01000000; otherwise with null.
|
|
362
|
// an unsigned 8-bit char with 01000000; otherwise with null.
|
|
357
|
lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right
|
|
363
|
lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right
|
|
358
|
// to the left) of lfr_bp1[i*NB_BYTES_BP1+7], by simple logical addition.
|
|
364
|
// to the left) of lfr_bp1[i*NB_BYTES_BP1+7], by simple logical addition.
|
|
359
|
#ifdef DEBUG_TCH
|
|
365
|
#ifdef DEBUG_TCH
|
|
360
|
printf("|ImaSX| : %16.8e\n",e_cross_b_im);
|
|
366
|
printf("|ImaSX| : %16.8e\n",e_cross_b_im);
|
|
361
|
printf("ArgSX sign : %u\n",tmp_uint8);
|
|
367
|
printf("ArgSX sign : %u\n",tmp_uint8);
|
|
362
|
printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX & ArgSX signs + ReaSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
|
|
368
|
printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX & ArgSX signs + ReaSX exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
|
|
363
|
#endif
|
|
369
|
#endif
|
|
364
|
//======================================================================
|
|
370
|
//======================================================================
|
|
365
|
// BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 16 bits
|
|
371
|
// BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 16 bits
|
|
366
|
// = 1 sign bit + 1 argument bit (two sectors)
|
|
372
|
// = 1 sign bit + 1 argument bit (two sectors)
|
|
367
|
// + 6 bits (exponent) + 8 bits (significand)
|
|
373
|
// + 6 bits (exponent) + 8 bits (significand)
|
|
368
|
ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2;
|
|
374
|
ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2;
|
|
369
|
nz = NVEC_V0;
|
|
375
|
nz = NVEC_V0;
|
|
370
|
bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22 Re
|
|
376
|
bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22 Re
|
|
371
|
+ sin(alpha_M)*sin(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] // S33 Re
|
|
377
|
+ sin(alpha_M)*sin(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] // S33 Re
|
|
372
|
- 2*sin(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]; // S23 Re
|
|
378
|
- 2*sin(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]; // S23 Re
|
|
373
|
|
|
379
|
|
|
374
|
n_cross_e_scal_b_re = ny * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_RE] //S24 Re
|
|
380
|
n_cross_e_scal_b_re = ny * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_RE] //S24 Re
|
|
375
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_RE] //S25 Re
|
|
381
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_RE] //S25 Re
|
|
376
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_RE] //S34 Re
|
|
382
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_RE] //S34 Re
|
|
377
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_RE] //S35 Re
|
|
383
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_RE] //S35 Re
|
|
378
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_IM] //S24 Im
|
|
384
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_IM] //S24 Im
|
|
379
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_IM] //S25 Im
|
|
385
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_IM] //S25 Im
|
|
380
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_IM] //S34 Im
|
|
386
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_IM] //S34 Im
|
|
381
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_IM]) //S35 Im
|
|
387
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_IM]) //S35 Im
|
|
382
|
+ nz * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] //S24 Re
|
|
388
|
+ nz * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] //S24 Re
|
|
383
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] //S25 Re
|
|
389
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] //S25 Re
|
|
384
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] //S34 Re
|
|
390
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] //S34 Re
|
|
385
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_RE] //S35 Re
|
|
391
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_RE] //S35 Re
|
|
386
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] //S24 Im
|
|
392
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] //S24 Im
|
|
387
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] //S25 Im
|
|
393
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] //S25 Im
|
|
388
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] //S34 Im
|
|
394
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] //S34 Im
|
|
389
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_IM]);//S35 Im
|
|
395
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_IM]);//S35 Im
|
|
390
|
// Im(S_ji) = -Im(S_ij)
|
|
396
|
// Im(S_ji) = -Im(S_ij)
|
|
391
|
// k_ji = k_ij
|
|
397
|
// k_ji = k_ij
|
|
392
|
n_cross_e_scal_b_im = ny * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_IM] //S24 Re
|
|
398
|
n_cross_e_scal_b_im = ny * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_IM] //S24 Re
|
|
393
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_IM] //S25 Re
|
|
399
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_IM] //S25 Re
|
|
394
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_IM] //S34 Re
|
|
400
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_IM] //S34 Re
|
|
395
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_IM] //S35 Re
|
|
401
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_IM] //S35 Re
|
|
396
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_RE] //S24 Im
|
|
402
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NY_RE] //S24 Im
|
|
397
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_RE] //S25 Im
|
|
403
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NY_RE] //S25 Im
|
|
398
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_RE] //S34 Im
|
|
404
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NY_RE] //S34 Im
|
|
399
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_RE]) //S35 Im
|
|
405
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NY_RE]) //S35 Im
|
|
400
|
+ nz * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] //S24 Re
|
|
406
|
+ nz * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_IM] //S24 Re
|
|
401
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] //S25 Re
|
|
407
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_IM] //S25 Re
|
|
402
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] //S34 Re
|
|
408
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_IM] //S34 Re
|
|
403
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_IM] //S35 Re
|
|
409
|
+compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_IM] //S35 Re
|
|
404
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] //S24 Im
|
|
410
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K24_NZ_RE] //S24 Im
|
|
405
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] //S25 Im
|
|
411
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K25_NZ_RE] //S25 Im
|
|
406
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] //S34 Im
|
|
412
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K34_NZ_RE] //S34 Im
|
|
407
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_RE]);//S35 Im
|
|
413
|
-compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_coeff_intercalib[i*NB_K_COEFF_PER_BIN+K35_NZ_RE]);//S35 Im
|
|
408
|
#ifdef DEBUG_TCH
|
|
414
|
#ifdef DEBUG_TCH
|
|
409
|
printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re);
|
|
415
|
printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re);
|
|
410
|
printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im);
|
|
416
|
printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im);
|
|
411
|
#endif
|
|
417
|
#endif
|
|
412
|
// vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re)
|
|
418
|
// vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re)
|
|
413
|
pt_uint8 = (uint8_t*) &n_cross_e_scal_b_re; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_re
|
|
419
|
pt_uint8 = (uint8_t*) &n_cross_e_scal_b_re; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_re
|
|
414
|
#ifdef LSB_FIRST_TCH
|
|
420
|
#ifdef LSB_FIRST_TCH
|
|
415
|
lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
|
|
421
|
lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
|
|
416
|
// Record it at the 8th bit position (from the right to the left)
|
|
422
|
// Record it at the 8th bit position (from the right to the left)
|
|
417
|
// of lfr_bp1[i*NB_BYTES_BP1+9]
|
|
423
|
// of lfr_bp1[i*NB_BYTES_BP1+9]
|
|
418
|
pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re|
|
|
424
|
pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re|
|
|
419
|
#endif
|
|
425
|
#endif
|
|
420
|
#ifdef MSB_FIRST_TCH
|
|
426
|
#ifdef MSB_FIRST_TCH
|
|
421
|
lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention)
|
|
427
|
lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 1th octet:SPARC convention)
|
|
422
|
// Record it at the 8th bit position (from the right to the left)
|
|
428
|
// Record it at the 8th bit position (from the right to the left)
|
|
423
|
// of lfr_bp1[i*NB_BYTES_BP1+9]
|
|
429
|
// of lfr_bp1[i*NB_BYTES_BP1+9]
|
|
424
|
pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re|
|
|
430
|
pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re|
|
|
425
|
#endif
|
|
431
|
#endif
|
|
426
|
if (bx_bx_star != 0.) { // no division by 0.
|
|
432
|
if (bx_bx_star != 0.) { // no division by 0.
|
|
427
|
vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI|
|
|
433
|
vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI|
|
|
428
|
}
|
|
434
|
}
|
|
429
|
else
|
|
435
|
else
|
|
430
|
{
|
|
436
|
{
|
|
431
|
vphi = 1.e+20; // Put a huge value
|
|
437
|
vphi = 1.e+20; // Put a huge value
|
|
432
|
}
|
|
438
|
}
|
|
433
|
significand = frexpf(vphi, &exponent); // 0.5 <= significand < 1
|
|
439
|
significand = frexpf(vphi, &exponent); // 0.5 <= significand < 1
|
|
434
|
// vphi = significand * 2^exponent
|
|
440
|
// vphi = significand * 2^exponent
|
|
435
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
441
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
436
|
exponent = expmin;
|
|
442
|
exponent = expmin;
|
|
437
|
significand = 0.5; // min value that can be recorded
|
|
443
|
significand = 0.5; // min value that can be recorded
|
|
438
|
}
|
|
444
|
}
|
|
439
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
445
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
440
|
exponent = expmax;
|
|
446
|
exponent = expmax;
|
|
441
|
significand = 1.0; // max value that can be recorded
|
|
447
|
significand = 1.0; // max value that can be recorded
|
|
442
|
}
|
|
448
|
}
|
|
443
|
if (significand == 0) {// in that case exponent == 0 too
|
|
449
|
if (significand == 0) {// in that case exponent == 0 too
|
|
444
|
exponent = expmin;
|
|
450
|
exponent = expmin;
|
|
445
|
significand = 0.5; // min value that can be recorded
|
|
451
|
significand = 0.5; // min value that can be recorded
|
|
446
|
}
|
|
452
|
}
|
|
447
|
|
|
453
|
|
|
448
|
lfr_bp1[i*NB_BYTES_BP1+10] = (uint8_t) ((significand*2-1)*255 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
|
|
454
|
lfr_bp1[i*NB_BYTES_BP1+10] = (uint8_t) ((significand*2-1)*255 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
|
|
449
|
// where all the bits are used (0, ..., 255)
|
|
455
|
// where all the bits are used (0, ..., 255)
|
|
450
|
tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
|
|
456
|
tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
|
|
451
|
// just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
457
|
// just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
452
|
#ifdef DEBUG_TCH
|
|
458
|
#ifdef DEBUG_TCH
|
|
453
|
printf("|VPHI| : %16.8e\n",vphi);
|
|
459
|
printf("|VPHI| : %16.8e\n",vphi);
|
|
454
|
printf("significand : %16.8e\n",significand);
|
|
460
|
printf("significand : %16.8e\n",significand);
|
|
455
|
printf("exponent : %d\n" ,exponent);
|
|
461
|
printf("exponent : %d\n" ,exponent);
|
|
456
|
printf("tmp_uint8 for VPHI exponent : %d\n",tmp_uint8);
|
|
462
|
printf("tmp_uint8 for VPHI exponent : %d\n",tmp_uint8);
|
|
457
|
#endif
|
|
463
|
#endif
|
|
458
|
lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | tmp_uint8; // Record these nbitexp bits in the nbitexp first bits
|
|
464
|
lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | tmp_uint8; // Record these nbitexp bits in the nbitexp first bits
|
|
459
|
// (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+9]
|
|
465
|
// (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+9]
|
|
460
|
#ifdef DEBUG_TCH
|
|
466
|
#ifdef DEBUG_TCH
|
|
461
|
printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI sign + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]);
|
|
467
|
printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI sign + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]);
|
|
462
|
printf("lfr_bp1[i*NB_BYTES_BP1+10] for VPHI significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+10]);
|
|
468
|
printf("lfr_bp1[i*NB_BYTES_BP1+10] for VPHI significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+10]);
|
|
463
|
#endif
|
|
469
|
#endif
|
|
464
|
pt_uint8 = (uint8_t*) &n_cross_e_scal_b_im; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_im
|
|
470
|
pt_uint8 = (uint8_t*) &n_cross_e_scal_b_im; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_im
|
|
465
|
#ifdef LSB_FIRST_TCH
|
|
471
|
#ifdef LSB_FIRST_TCH
|
|
466
|
pt_uint8[3] = pt_uint8[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaNEBX| (32-bit float, sign bit in the 4th octet:PC convention)
|
|
472
|
pt_uint8[3] = pt_uint8[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaNEBX| (32-bit float, sign bit in the 4th octet:PC convention)
|
|
467
|
#endif
|
|
473
|
#endif
|
|
468
|
#ifdef MSB_FIRST_TCH
|
|
474
|
#ifdef MSB_FIRST_TCH
|
|
469
|
pt_uint8[0] = pt_uint8[0] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaNEBX| (32-bit float, sign bit in the 1th octet:SPARC convention)
|
|
475
|
pt_uint8[0] = pt_uint8[0] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaNEBX| (32-bit float, sign bit in the 1th octet:SPARC convention)
|
|
470
|
#endif
|
|
476
|
#endif
|
|
471
|
tmp_uint8 = (n_cross_e_scal_b_im > n_cross_e_scal_b_re) ? 0x40 : 0x00; // Determine the sector argument of NEBX. If |Im| > |Re| affect
|
|
477
|
tmp_uint8 = (n_cross_e_scal_b_im > n_cross_e_scal_b_re) ? 0x40 : 0x00; // Determine the sector argument of NEBX. If |Im| > |Re| affect
|
|
472
|
// an unsigned 8-bit char with 01000000; otherwise with null.
|
|
478
|
// an unsigned 8-bit char with 01000000; otherwise with null.
|
|
473
|
lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right
|
|
479
|
lfr_bp1[i*NB_BYTES_BP1+9] = lfr_bp1[i*NB_BYTES_BP1+9] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right
|
|
474
|
// to the left) of lfr_bp1[i*NB_BYTES_BP1+9], by simple logical addition.
|
|
480
|
// to the left) of lfr_bp1[i*NB_BYTES_BP1+9], by simple logical addition.
|
|
475
|
#ifdef DEBUG_TCH
|
|
481
|
#ifdef DEBUG_TCH
|
|
476
|
printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im);
|
|
482
|
printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im);
|
|
477
|
printf("|n_cross_e_scal_b_im|/bx_bx_star : %16.8e\n",n_cross_e_scal_b_im/bx_bx_star);
|
|
483
|
printf("|n_cross_e_scal_b_im|/bx_bx_star : %16.8e\n",n_cross_e_scal_b_im/bx_bx_star);
|
|
478
|
printf("ArgNEBX sign : %u\n",tmp_uint8);
|
|
484
|
printf("ArgNEBX sign : %u\n",tmp_uint8);
|
|
479
|
printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI & ArgNEBX signs + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]);
|
|
485
|
printf("lfr_bp1[i*NB_BYTES_BP1+9] for VPHI & ArgNEBX signs + VPHI exponent : %u\n",lfr_bp1[i*NB_BYTES_BP1+9]);
|
|
480
|
#endif
|
|
486
|
#endif
|
|
481
|
}
|
|
487
|
}
|
|
482
|
}
|
|
488
|
}
|
|
483
|
|
|
489
|
|
|
484
|
void BP2_set( float * compressed_spec_mat, uint8_t nb_bins_compressed_spec_mat, uint8_t * lfr_bp2 )
|
|
490
|
void BP2_set( float * compressed_spec_mat, uint8_t nb_bins_compressed_spec_mat, uint8_t * lfr_bp2 )
|
|
485
|
{
|
|
491
|
{
|
|
486
|
float cross_re; // 32-bit floating point
|
|
492
|
float cross_re; // 32-bit floating point
|
|
487
|
float cross_im;
|
|
493
|
float cross_im;
|
|
488
|
float aux;
|
|
494
|
float aux;
|
|
489
|
float significand;
|
|
495
|
float significand;
|
|
490
|
int exponent; // 32-bit signed integer
|
|
496
|
int exponent; // 32-bit signed integer
|
|
491
|
uint8_t nbitexp; // 8-bit unsigned integer
|
|
497
|
uint8_t nbitexp; // 8-bit unsigned integer
|
|
492
|
uint8_t nbitsig;
|
|
498
|
uint8_t nbitsig;
|
|
493
|
uint8_t *pt_uint8; // pointer on unsigned 8-bit integer
|
|
499
|
uint8_t *pt_uint8; // pointer on unsigned 8-bit integer
|
|
494
|
int8_t expmin; // 8-bit signed integer
|
|
500
|
int8_t expmin; // 8-bit signed integer
|
|
495
|
int8_t expmax;
|
|
501
|
int8_t expmax;
|
|
496
|
uint16_t rangesig; // 16-bit unsigned integer
|
|
502
|
uint16_t rangesig; // 16-bit unsigned integer
|
|
497
|
uint16_t autocor;
|
|
503
|
uint16_t autocor;
|
|
498
|
uint16_t exp;
|
|
504
|
uint16_t exp;
|
|
499
|
uint16_t tmp_uint16;
|
|
505
|
uint16_t tmp_uint16;
|
|
500
|
uint16_t i;
|
|
506
|
uint16_t i;
|
|
501
|
|
|
507
|
|
|
502
|
#ifdef DEBUG_TCH
|
|
508
|
#ifdef DEBUG_TCH
|
|
503
|
printf("BP2 : \n");
|
|
509
|
printf("BP2 : \n");
|
|
504
|
printf("Number of bins: %d\n", nb_bins_compressed_spec_mat);
|
|
510
|
printf("Number of bins: %d\n", nb_bins_compressed_spec_mat);
|
|
505
|
#endif
|
|
511
|
#endif
|
|
506
|
|
|
512
|
|
|
507
|
// For floating point data to be recorded on 16-bit words :
|
|
513
|
// For floating point data to be recorded on 16-bit words :
|
|
508
|
nbitexp = 6; // number of bits for the exponent
|
|
514
|
nbitexp = 6; // number of bits for the exponent
|
|
509
|
nbitsig = 16 - nbitexp; // number of bits for the significand
|
|
515
|
nbitsig = 16 - nbitexp; // number of bits for the significand
|
|
510
|
rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
|
|
516
|
rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
|
|
511
|
expmax = 32 + 5;
|
|
517
|
expmax = 32 + 5;
|
|
512
|
expmin = expmax - (1 << nbitexp) + 1;
|
|
518
|
expmin = expmax - (1 << nbitexp) + 1;
|
|
513
|
|
|
519
|
|
|
514
|
#ifdef DEBUG_TCH
|
|
520
|
#ifdef DEBUG_TCH
|
|
515
|
|
|
521
|
|
|
516
|
printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin);
|
|
522
|
printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin);
|
|
517
|
printf("nbitsig : %d, rangesig : %d\n", nbitsig, rangesig);
|
|
523
|
printf("nbitsig : %d, rangesig : %d\n", nbitsig, rangesig);
|
|
518
|
#endif
|
|
524
|
#endif
|
|
519
|
|
|
525
|
|
|
520
|
for(i = 0; i<nb_bins_compressed_spec_mat; i++){
|
|
526
|
for(i = 0; i<nb_bins_compressed_spec_mat; i++){
|
|
521
|
//==============================================
|
|
527
|
//==============================================
|
|
522
|
// BP2 normalized cross correlations == PA_LFR_SC_BP2_CROSS_F0 == 10 * (8+8) bits
|
|
528
|
// BP2 normalized cross correlations == PA_LFR_SC_BP2_CROSS_F0 == 10 * (8+8) bits
|
|
523
|
// == PA_LFR_SC_BP2_CROSS_RE_0_F0 == 8 bits
|
|
529
|
// == PA_LFR_SC_BP2_CROSS_RE_0_F0 == 8 bits
|
|
524
|
// == PA_LFR_SC_BP2_CROSS_IM_0_F0 == 8 bits
|
|
530
|
// == PA_LFR_SC_BP2_CROSS_IM_0_F0 == 8 bits
|
|
525
|
// == PA_LFR_SC_BP2_CROSS_RE_1_F0 == 8 bits
|
|
531
|
// == PA_LFR_SC_BP2_CROSS_RE_1_F0 == 8 bits
|
|
526
|
// == PA_LFR_SC_BP2_CROSS_IM_1_F0 == 8 bits
|
|
532
|
// == PA_LFR_SC_BP2_CROSS_IM_1_F0 == 8 bits
|
|
527
|
// == PA_LFR_SC_BP2_CROSS_RE_2_F0 == 8 bits
|
|
533
|
// == PA_LFR_SC_BP2_CROSS_RE_2_F0 == 8 bits
|
|
528
|
// == PA_LFR_SC_BP2_CROSS_IM_2_F0 == 8 bits
|
|
534
|
// == PA_LFR_SC_BP2_CROSS_IM_2_F0 == 8 bits
|
|
529
|
// == PA_LFR_SC_BP2_CROSS_RE_3_F0 == 8 bits
|
|
535
|
// == PA_LFR_SC_BP2_CROSS_RE_3_F0 == 8 bits
|
|
530
|
// == PA_LFR_SC_BP2_CROSS_IM_3_F0 == 8 bits
|
|
536
|
// == PA_LFR_SC_BP2_CROSS_IM_3_F0 == 8 bits
|
|
531
|
// == PA_LFR_SC_BP2_CROSS_RE_4_F0 == 8 bits
|
|
537
|
// == PA_LFR_SC_BP2_CROSS_RE_4_F0 == 8 bits
|
|
532
|
// == PA_LFR_SC_BP2_CROSS_IM_4_F0 == 8 bits
|
|
538
|
// == PA_LFR_SC_BP2_CROSS_IM_4_F0 == 8 bits
|
|
533
|
// == PA_LFR_SC_BP2_CROSS_RE_5_F0 == 8 bits
|
|
539
|
// == PA_LFR_SC_BP2_CROSS_RE_5_F0 == 8 bits
|
|
534
|
// == PA_LFR_SC_BP2_CROSS_IM_5_F0 == 8 bits
|
|
540
|
// == PA_LFR_SC_BP2_CROSS_IM_5_F0 == 8 bits
|
|
535
|
// == PA_LFR_SC_BP2_CROSS_RE_6_F0 == 8 bits
|
|
541
|
// == PA_LFR_SC_BP2_CROSS_RE_6_F0 == 8 bits
|
|
536
|
// == PA_LFR_SC_BP2_CROSS_IM_6_F0 == 8 bits
|
|
542
|
// == PA_LFR_SC_BP2_CROSS_IM_6_F0 == 8 bits
|
|
537
|
// == PA_LFR_SC_BP2_CROSS_RE_7_F0 == 8 bits
|
|
543
|
// == PA_LFR_SC_BP2_CROSS_RE_7_F0 == 8 bits
|
|
538
|
// == PA_LFR_SC_BP2_CROSS_IM_7_F0 == 8 bits
|
|
544
|
// == PA_LFR_SC_BP2_CROSS_IM_7_F0 == 8 bits
|
|
539
|
// == PA_LFR_SC_BP2_CROSS_RE_8_F0 == 8 bits
|
|
545
|
// == PA_LFR_SC_BP2_CROSS_RE_8_F0 == 8 bits
|
|
540
|
// == PA_LFR_SC_BP2_CROSS_IM_8_F0 == 8 bits
|
|
546
|
// == PA_LFR_SC_BP2_CROSS_IM_8_F0 == 8 bits
|
|
541
|
// == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits
|
|
547
|
// == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits
|
|
542
|
// == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits
|
|
548
|
// == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits
|
|
543
|
// S12
|
|
549
|
// S12
|
|
544
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
|
|
550
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
|
|
545
|
if (aux != 0.) { // no division by 0.
|
|
551
|
if (aux != 0.) { // no division by 0.
|
|
546
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] / aux;
|
|
552
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] / aux;
|
|
547
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / aux;
|
|
553
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / aux;
|
|
548
|
}
|
|
554
|
}
|
|
549
|
else
|
|
555
|
else
|
|
550
|
{
|
|
556
|
{
|
|
551
|
cross_re = 0.;
|
|
557
|
cross_re = 0.;
|
|
552
|
cross_im = 0.;
|
|
558
|
cross_im = 0.;
|
|
553
|
}
|
|
559
|
}
|
|
554
|
lfr_bp2[i*NB_BYTES_BP2+10] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
560
|
lfr_bp2[i*NB_BYTES_BP2+10] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
555
|
lfr_bp2[i*NB_BYTES_BP2+20] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
561
|
lfr_bp2[i*NB_BYTES_BP2+20] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
556
|
#ifdef DEBUG_TCH
|
|
562
|
#ifdef DEBUG_TCH
|
|
557
|
printf("\nBin number: %d\n", i);
|
|
563
|
printf("\nBin number: %d\n", i);
|
|
558
|
printf("lfr_bp2[i*NB_BYTES_BP2+10] for cross12_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+10]);
|
|
564
|
printf("lfr_bp2[i*NB_BYTES_BP2+10] for cross12_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+10]);
|
|
559
|
printf("lfr_bp2[i*NB_BYTES_BP2+20] for cross12_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+20]);
|
|
565
|
printf("lfr_bp2[i*NB_BYTES_BP2+20] for cross12_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+20]);
|
|
560
|
#endif
|
|
566
|
#endif
|
|
561
|
// S13
|
|
567
|
// S13
|
|
562
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
|
|
568
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
|
|
563
|
if (aux != 0.) { // no division by 0.
|
|
569
|
if (aux != 0.) { // no division by 0.
|
|
564
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] / aux;
|
|
570
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] / aux;
|
|
565
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / aux;
|
|
571
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / aux;
|
|
566
|
}
|
|
572
|
}
|
|
567
|
else
|
|
573
|
else
|
|
568
|
{
|
|
574
|
{
|
|
569
|
cross_re = 0.;
|
|
575
|
cross_re = 0.;
|
|
570
|
cross_im = 0.;
|
|
576
|
cross_im = 0.;
|
|
571
|
}
|
|
577
|
}
|
|
572
|
lfr_bp2[i*NB_BYTES_BP2+11] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
578
|
lfr_bp2[i*NB_BYTES_BP2+11] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
573
|
lfr_bp2[i*NB_BYTES_BP2+21] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
579
|
lfr_bp2[i*NB_BYTES_BP2+21] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
574
|
#ifdef DEBUG_TCH
|
|
580
|
#ifdef DEBUG_TCH
|
|
575
|
printf("lfr_bp2[i*NB_BYTES_BP2+11] for cross13_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+11]);
|
|
581
|
printf("lfr_bp2[i*NB_BYTES_BP2+11] for cross13_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+11]);
|
|
576
|
printf("lfr_bp2[i*NB_BYTES_BP2+21] for cross13_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+21]);
|
|
582
|
printf("lfr_bp2[i*NB_BYTES_BP2+21] for cross13_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+21]);
|
|
577
|
#endif
|
|
583
|
#endif
|
|
578
|
// S14
|
|
584
|
// S14
|
|
579
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
|
|
585
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
|
|
580
|
if (aux != 0.) { // no division by 0.
|
|
586
|
if (aux != 0.) { // no division by 0.
|
|
581
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] / aux;
|
|
587
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] / aux;
|
|
582
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] / aux;
|
|
588
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] / aux;
|
|
583
|
}
|
|
589
|
}
|
|
584
|
else
|
|
590
|
else
|
|
585
|
{
|
|
591
|
{
|
|
586
|
cross_re = 0.;
|
|
592
|
cross_re = 0.;
|
|
587
|
cross_im = 0.;
|
|
593
|
cross_im = 0.;
|
|
588
|
}
|
|
594
|
}
|
|
589
|
lfr_bp2[i*NB_BYTES_BP2+12] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
595
|
lfr_bp2[i*NB_BYTES_BP2+12] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
590
|
lfr_bp2[i*NB_BYTES_BP2+22] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
596
|
lfr_bp2[i*NB_BYTES_BP2+22] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
591
|
#ifdef DEBUG_TCH
|
|
597
|
#ifdef DEBUG_TCH
|
|
592
|
printf("lfr_bp2[i*NB_BYTES_BP2+12] for cross14_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+12]);
|
|
598
|
printf("lfr_bp2[i*NB_BYTES_BP2+12] for cross14_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+12]);
|
|
593
|
printf("lfr_bp2[i*NB_BYTES_BP2+22] for cross14_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+22]);
|
|
599
|
printf("lfr_bp2[i*NB_BYTES_BP2+22] for cross14_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+22]);
|
|
594
|
#endif
|
|
600
|
#endif
|
|
595
|
// S15
|
|
601
|
// S15
|
|
596
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
|
|
602
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
|
|
597
|
if (aux != 0.) { // no division by 0.
|
|
603
|
if (aux != 0.) { // no division by 0.
|
|
598
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] / aux;
|
|
604
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] / aux;
|
|
599
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] / aux;
|
|
605
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] / aux;
|
|
600
|
}
|
|
606
|
}
|
|
601
|
else
|
|
607
|
else
|
|
602
|
{
|
|
608
|
{
|
|
603
|
cross_re = 0.;
|
|
609
|
cross_re = 0.;
|
|
604
|
cross_im = 0.;
|
|
610
|
cross_im = 0.;
|
|
605
|
}
|
|
611
|
}
|
|
606
|
lfr_bp2[i*NB_BYTES_BP2+13] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
612
|
lfr_bp2[i*NB_BYTES_BP2+13] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
607
|
lfr_bp2[i*NB_BYTES_BP2+23] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
613
|
lfr_bp2[i*NB_BYTES_BP2+23] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
608
|
#ifdef DEBUG_TCH
|
|
614
|
#ifdef DEBUG_TCH
|
|
609
|
printf("lfr_bp2[i*NB_BYTES_BP2+13] for cross15_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+13]);
|
|
615
|
printf("lfr_bp2[i*NB_BYTES_BP2+13] for cross15_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+13]);
|
|
610
|
printf("lfr_bp2[i*NB_BYTES_BP2+23] for cross15_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+23]);
|
|
616
|
printf("lfr_bp2[i*NB_BYTES_BP2+23] for cross15_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+23]);
|
|
611
|
#endif
|
|
617
|
#endif
|
|
612
|
// S23
|
|
618
|
// S23
|
|
613
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
|
|
619
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
|
|
614
|
if (aux != 0.) { // no division by 0.
|
|
620
|
if (aux != 0.) { // no division by 0.
|
|
615
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10] / aux;
|
|
621
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10] / aux;
|
|
616
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] / aux;
|
|
622
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] / aux;
|
|
617
|
}
|
|
623
|
}
|
|
618
|
else
|
|
624
|
else
|
|
619
|
{
|
|
625
|
{
|
|
620
|
cross_re = 0.;
|
|
626
|
cross_re = 0.;
|
|
621
|
cross_im = 0.;
|
|
627
|
cross_im = 0.;
|
|
622
|
}
|
|
628
|
}
|
|
623
|
lfr_bp2[i*NB_BYTES_BP2+14] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
629
|
lfr_bp2[i*NB_BYTES_BP2+14] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
624
|
lfr_bp2[i*NB_BYTES_BP2+24] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
630
|
lfr_bp2[i*NB_BYTES_BP2+24] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
625
|
#ifdef DEBUG_TCH
|
|
631
|
#ifdef DEBUG_TCH
|
|
626
|
printf("lfr_bp2[i*NB_BYTES_BP2+14] for cross23_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+14]);
|
|
632
|
printf("lfr_bp2[i*NB_BYTES_BP2+14] for cross23_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+14]);
|
|
627
|
printf("lfr_bp2[i*NB_BYTES_BP2+24] for cross23_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+24]);
|
|
633
|
printf("lfr_bp2[i*NB_BYTES_BP2+24] for cross23_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+24]);
|
|
628
|
#endif
|
|
634
|
#endif
|
|
629
|
// S24
|
|
635
|
// S24
|
|
630
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
|
|
636
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
|
|
631
|
if (aux != 0.) { // no division by 0.
|
|
637
|
if (aux != 0.) { // no division by 0.
|
|
632
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12] / aux;
|
|
638
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12] / aux;
|
|
633
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13] / aux;
|
|
639
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13] / aux;
|
|
634
|
}
|
|
640
|
}
|
|
635
|
else
|
|
641
|
else
|
|
636
|
{
|
|
642
|
{
|
|
637
|
cross_re = 0.;
|
|
643
|
cross_re = 0.;
|
|
638
|
cross_im = 0.;
|
|
644
|
cross_im = 0.;
|
|
639
|
}
|
|
645
|
}
|
|
640
|
lfr_bp2[i*NB_BYTES_BP2+15] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
646
|
lfr_bp2[i*NB_BYTES_BP2+15] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
641
|
lfr_bp2[i*NB_BYTES_BP2+25] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
647
|
lfr_bp2[i*NB_BYTES_BP2+25] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
642
|
#ifdef DEBUG_TCH
|
|
648
|
#ifdef DEBUG_TCH
|
|
643
|
printf("lfr_bp2[i*NB_BYTES_BP2+15] for cross24_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+15]);
|
|
649
|
printf("lfr_bp2[i*NB_BYTES_BP2+15] for cross24_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+15]);
|
|
644
|
printf("lfr_bp2[i*NB_BYTES_BP2+25] for cross24_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+25]);
|
|
650
|
printf("lfr_bp2[i*NB_BYTES_BP2+25] for cross24_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+25]);
|
|
645
|
#endif
|
|
651
|
#endif
|
|
646
|
// S25
|
|
652
|
// S25
|
|
647
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
|
|
653
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
|
|
648
|
if (aux != 0.) { // no division by 0.
|
|
654
|
if (aux != 0.) { // no division by 0.
|
|
649
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14] / aux;
|
|
655
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14] / aux;
|
|
650
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15] / aux;
|
|
656
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15] / aux;
|
|
651
|
}
|
|
657
|
}
|
|
652
|
else
|
|
658
|
else
|
|
653
|
{
|
|
659
|
{
|
|
654
|
cross_re = 0.;
|
|
660
|
cross_re = 0.;
|
|
655
|
cross_im = 0.;
|
|
661
|
cross_im = 0.;
|
|
656
|
}
|
|
662
|
}
|
|
657
|
lfr_bp2[i*NB_BYTES_BP2+16] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
663
|
lfr_bp2[i*NB_BYTES_BP2+16] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
658
|
lfr_bp2[i*NB_BYTES_BP2+26] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
664
|
lfr_bp2[i*NB_BYTES_BP2+26] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
659
|
#ifdef DEBUG_TCH
|
|
665
|
#ifdef DEBUG_TCH
|
|
660
|
printf("lfr_bp2[i*NB_BYTES_BP2+16] for cross25_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+16]);
|
|
666
|
printf("lfr_bp2[i*NB_BYTES_BP2+16] for cross25_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+16]);
|
|
661
|
printf("lfr_bp2[i*NB_BYTES_BP2+26] for cross25_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+26]);
|
|
667
|
printf("lfr_bp2[i*NB_BYTES_BP2+26] for cross25_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+26]);
|
|
662
|
#endif
|
|
668
|
#endif
|
|
663
|
// S34
|
|
669
|
// S34
|
|
664
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
|
|
670
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
|
|
665
|
if (aux != 0.) { // no division by 0.
|
|
671
|
if (aux != 0.) { // no division by 0.
|
|
666
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17] / aux;
|
|
672
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17] / aux;
|
|
667
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18] / aux;
|
|
673
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18] / aux;
|
|
668
|
}
|
|
674
|
}
|
|
669
|
else
|
|
675
|
else
|
|
670
|
{
|
|
676
|
{
|
|
671
|
cross_re = 0.;
|
|
677
|
cross_re = 0.;
|
|
672
|
cross_im = 0.;
|
|
678
|
cross_im = 0.;
|
|
673
|
}
|
|
679
|
}
|
|
674
|
lfr_bp2[i*NB_BYTES_BP2+17] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
680
|
lfr_bp2[i*NB_BYTES_BP2+17] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
675
|
lfr_bp2[i*NB_BYTES_BP2+27] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
681
|
lfr_bp2[i*NB_BYTES_BP2+27] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
676
|
#ifdef DEBUG_TCH
|
|
682
|
#ifdef DEBUG_TCH
|
|
677
|
printf("lfr_bp2[i*NB_BYTES_BP2+17] for cross34_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+17]);
|
|
683
|
printf("lfr_bp2[i*NB_BYTES_BP2+17] for cross34_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+17]);
|
|
678
|
printf("lfr_bp2[i*NB_BYTES_BP2+27] for cross34_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+27]);
|
|
684
|
printf("lfr_bp2[i*NB_BYTES_BP2+27] for cross34_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+27]);
|
|
679
|
#endif
|
|
685
|
#endif
|
|
680
|
// S35
|
|
686
|
// S35
|
|
681
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
|
|
687
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
|
|
682
|
if (aux != 0.) { // no division by 0.
|
|
688
|
if (aux != 0.) { // no division by 0.
|
|
683
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19] / aux;
|
|
689
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19] / aux;
|
|
684
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20] / aux;
|
|
690
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20] / aux;
|
|
685
|
}
|
|
691
|
}
|
|
686
|
else
|
|
692
|
else
|
|
687
|
{
|
|
693
|
{
|
|
688
|
cross_re = 0.;
|
|
694
|
cross_re = 0.;
|
|
689
|
cross_im = 0.;
|
|
695
|
cross_im = 0.;
|
|
690
|
}
|
|
696
|
}
|
|
691
|
lfr_bp2[i*NB_BYTES_BP2+18] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
697
|
lfr_bp2[i*NB_BYTES_BP2+18] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
692
|
lfr_bp2[i*NB_BYTES_BP2+28] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
698
|
lfr_bp2[i*NB_BYTES_BP2+28] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
693
|
#ifdef DEBUG_TCH
|
|
699
|
#ifdef DEBUG_TCH
|
|
694
|
printf("lfr_bp2[i*NB_BYTES_BP2+18] for cross35_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+18]);
|
|
700
|
printf("lfr_bp2[i*NB_BYTES_BP2+18] for cross35_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+18]);
|
|
695
|
printf("lfr_bp2[i*NB_BYTES_BP2+28] for cross35_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+28]);
|
|
701
|
printf("lfr_bp2[i*NB_BYTES_BP2+28] for cross35_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+28]);
|
|
696
|
#endif
|
|
702
|
#endif
|
|
697
|
// S45
|
|
703
|
// S45
|
|
698
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
|
|
704
|
aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
|
|
699
|
if (aux != 0.) { // no division by 0.
|
|
705
|
if (aux != 0.) { // no division by 0.
|
|
700
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] / aux;
|
|
706
|
cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] / aux;
|
|
701
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] / aux;
|
|
707
|
cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] / aux;
|
|
702
|
}
|
|
708
|
}
|
|
703
|
else
|
|
709
|
else
|
|
704
|
{
|
|
710
|
{
|
|
705
|
cross_re = 0.;
|
|
711
|
cross_re = 0.;
|
|
706
|
cross_im = 0.;
|
|
712
|
cross_im = 0.;
|
|
707
|
}
|
|
713
|
}
|
|
708
|
lfr_bp2[i*NB_BYTES_BP2+19] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
714
|
lfr_bp2[i*NB_BYTES_BP2+19] = (uint8_t) (cross_re*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
709
|
lfr_bp2[i*NB_BYTES_BP2+29] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
715
|
lfr_bp2[i*NB_BYTES_BP2+29] = (uint8_t) (cross_im*127.5 + 128); // Shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
|
|
710
|
#ifdef DEBUG_TCH
|
|
716
|
#ifdef DEBUG_TCH
|
|
711
|
printf("lfr_bp2[i*NB_BYTES_BP2+19] for cross45_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+19]);
|
|
717
|
printf("lfr_bp2[i*NB_BYTES_BP2+19] for cross45_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+19]);
|
|
712
|
printf("lfr_bp2[i*NB_BYTES_BP2+29] for cross45_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+29]);
|
|
718
|
printf("lfr_bp2[i*NB_BYTES_BP2+29] for cross45_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+29]);
|
|
713
|
#endif
|
|
719
|
#endif
|
|
714
|
//==============================================
|
|
720
|
//==============================================
|
|
715
|
// BP2 auto correlations == PA_LFR_SC_BP2_AUTO_F0 == 5*16 bits = 5*[6 bits (exponent) + 10 bits (significand)]
|
|
721
|
// BP2 auto correlations == PA_LFR_SC_BP2_AUTO_F0 == 5*16 bits = 5*[6 bits (exponent) + 10 bits (significand)]
|
|
716
|
// == PA_LFR_SC_BP2_AUTO_A0_F0 == 16 bits
|
|
722
|
// == PA_LFR_SC_BP2_AUTO_A0_F0 == 16 bits
|
|
717
|
// == PA_LFR_SC_BP2_AUTO_A1_F0 == 16 bits
|
|
723
|
// == PA_LFR_SC_BP2_AUTO_A1_F0 == 16 bits
|
|
718
|
// == PA_LFR_SC_BP2_AUTO_A2_F0 == 16 bits
|
|
724
|
// == PA_LFR_SC_BP2_AUTO_A2_F0 == 16 bits
|
|
719
|
// == PA_LFR_SC_BP2_AUTO_A3_F0 == 16 bits
|
|
725
|
// == PA_LFR_SC_BP2_AUTO_A3_F0 == 16 bits
|
|
720
|
// == PA_LFR_SC_BP2_AUTO_A4_F0 == 16 bits
|
|
726
|
// == PA_LFR_SC_BP2_AUTO_A4_F0 == 16 bits
|
|
721
|
// S11
|
|
727
|
// S11
|
|
722
|
significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX], &exponent); // 0.5 <= significand < 1
|
|
728
|
significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX], &exponent); // 0.5 <= significand < 1
|
|
723
|
// S11 = significand * 2^exponent
|
|
729
|
// S11 = significand * 2^exponent
|
|
724
|
#ifdef DEBUG_TCH
|
|
730
|
#ifdef DEBUG_TCH
|
|
725
|
printf("S11 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]);
|
|
731
|
printf("S11 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]);
|
|
726
|
printf("significand : %16.8e\n",significand);
|
|
732
|
printf("significand : %16.8e\n",significand);
|
|
727
|
printf("exponent : %d\n" ,exponent);
|
|
733
|
printf("exponent : %d\n" ,exponent);
|
|
728
|
#endif
|
|
734
|
#endif
|
|
729
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
735
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
730
|
exponent = expmin;
|
|
736
|
exponent = expmin;
|
|
731
|
significand = 0.5; // min value that can be recorded
|
|
737
|
significand = 0.5; // min value that can be recorded
|
|
732
|
}
|
|
738
|
}
|
|
733
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
739
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
734
|
exponent = expmax;
|
|
740
|
exponent = expmax;
|
|
735
|
significand = 1.0; // max value that can be recorded
|
|
741
|
significand = 1.0; // max value that can be recorded
|
|
736
|
}
|
|
742
|
}
|
|
737
|
if (significand == 0) { // in that case exponent == 0 too
|
|
743
|
if (significand == 0) { // in that case exponent == 0 too
|
|
738
|
exponent = expmin;
|
|
744
|
exponent = expmin;
|
|
739
|
significand = 0.5; // min value that can be recorded
|
|
745
|
significand = 0.5; // min value that can be recorded
|
|
740
|
}
|
|
746
|
}
|
|
741
|
|
|
747
|
|
|
742
|
autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
748
|
autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
743
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
749
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
744
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
750
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
745
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
751
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
746
|
tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
752
|
tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
747
|
// left place of the significand bits (nbitsig),
|
|
753
|
// left place of the significand bits (nbitsig),
|
|
748
|
// making the 16-bit word to be recorded
|
|
754
|
// making the 16-bit word to be recorded
|
|
749
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
755
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
750
|
#ifdef MSB_FIRST_TCH
|
|
756
|
#ifdef MSB_FIRST_TCH
|
|
751
|
lfr_bp2[i*NB_BYTES_BP2+0] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
757
|
lfr_bp2[i*NB_BYTES_BP2+0] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
752
|
lfr_bp2[i*NB_BYTES_BP2+1] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
758
|
lfr_bp2[i*NB_BYTES_BP2+1] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
753
|
#endif
|
|
759
|
#endif
|
|
754
|
#ifdef LSB_FIRST_TCH
|
|
760
|
#ifdef LSB_FIRST_TCH
|
|
755
|
lfr_bp2[i*NB_BYTES_BP2+0] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
761
|
lfr_bp2[i*NB_BYTES_BP2+0] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
756
|
lfr_bp2[i*NB_BYTES_BP2+1] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
762
|
lfr_bp2[i*NB_BYTES_BP2+1] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
757
|
#endif
|
|
763
|
#endif
|
|
758
|
#ifdef DEBUG_TCH
|
|
764
|
#ifdef DEBUG_TCH
|
|
759
|
printf("autocor for S11 significand : %u\n",autocor);
|
|
765
|
printf("autocor for S11 significand : %u\n",autocor);
|
|
760
|
printf("exp for S11 exponent : %u\n",exp);
|
|
766
|
printf("exp for S11 exponent : %u\n",exp);
|
|
761
|
printf("pt_uint8[1] for S11 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
|
|
767
|
printf("pt_uint8[1] for S11 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
|
|
762
|
printf("pt_uint8[0] for S11 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
|
|
768
|
printf("pt_uint8[0] for S11 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
|
|
763
|
printf("lfr_bp2[i*NB_BYTES_BP2+0] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+0], lfr_bp2[i*NB_BYTES_BP2+0]);
|
|
769
|
printf("lfr_bp2[i*NB_BYTES_BP2+0] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+0], lfr_bp2[i*NB_BYTES_BP2+0]);
|
|
764
|
printf("lfr_bp2[i*NB_BYTES_BP2+1] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+1], lfr_bp2[i*NB_BYTES_BP2+1]);
|
|
770
|
printf("lfr_bp2[i*NB_BYTES_BP2+1] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+1], lfr_bp2[i*NB_BYTES_BP2+1]);
|
|
765
|
#endif
|
|
771
|
#endif
|
|
766
|
// S22
|
|
772
|
// S22
|
|
767
|
significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9], &exponent); // 0.5 <= significand < 1
|
|
773
|
significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9], &exponent); // 0.5 <= significand < 1
|
|
768
|
// S22 = significand * 2^exponent
|
|
774
|
// S22 = significand * 2^exponent
|
|
769
|
#ifdef DEBUG_TCH
|
|
775
|
#ifdef DEBUG_TCH
|
|
770
|
printf("S22 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
|
|
776
|
printf("S22 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
|
|
771
|
printf("significand : %16.8e\n",significand);
|
|
777
|
printf("significand : %16.8e\n",significand);
|
|
772
|
printf("exponent : %d\n" ,exponent);
|
|
778
|
printf("exponent : %d\n" ,exponent);
|
|
773
|
#endif
|
|
779
|
#endif
|
|
774
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
780
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
775
|
exponent = expmin;
|
|
781
|
exponent = expmin;
|
|
776
|
significand = 0.5; // min value that can be recorded
|
|
782
|
significand = 0.5; // min value that can be recorded
|
|
777
|
}
|
|
783
|
}
|
|
778
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
784
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
779
|
exponent = expmax;
|
|
785
|
exponent = expmax;
|
|
780
|
significand = 1.0; // max value that can be recorded
|
|
786
|
significand = 1.0; // max value that can be recorded
|
|
781
|
}
|
|
787
|
}
|
|
782
|
if (significand == 0) { // in that case exponent == 0 too
|
|
788
|
if (significand == 0) { // in that case exponent == 0 too
|
|
783
|
exponent = expmin;
|
|
789
|
exponent = expmin;
|
|
784
|
significand = 0.5; // min value that can be recorded
|
|
790
|
significand = 0.5; // min value that can be recorded
|
|
785
|
}
|
|
791
|
}
|
|
786
|
|
|
792
|
|
|
787
|
autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
793
|
autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
788
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
794
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
789
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
795
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
790
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
796
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
791
|
tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
797
|
tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
792
|
// left place of the significand bits (nbitsig),
|
|
798
|
// left place of the significand bits (nbitsig),
|
|
793
|
// making the 16-bit word to be recorded
|
|
799
|
// making the 16-bit word to be recorded
|
|
794
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
800
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
795
|
#ifdef MSB_FIRST_TCH
|
|
801
|
#ifdef MSB_FIRST_TCH
|
|
796
|
lfr_bp2[i*NB_BYTES_BP2+2] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
802
|
lfr_bp2[i*NB_BYTES_BP2+2] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
797
|
lfr_bp2[i*NB_BYTES_BP2+3] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
803
|
lfr_bp2[i*NB_BYTES_BP2+3] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
798
|
#endif
|
|
804
|
#endif
|
|
799
|
#ifdef LSB_FIRST_TCH
|
|
805
|
#ifdef LSB_FIRST_TCH
|
|
800
|
lfr_bp2[i*NB_BYTES_BP2+2] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
806
|
lfr_bp2[i*NB_BYTES_BP2+2] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
801
|
lfr_bp2[i*NB_BYTES_BP2+3] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
807
|
lfr_bp2[i*NB_BYTES_BP2+3] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
802
|
#endif
|
|
808
|
#endif
|
|
803
|
#ifdef DEBUG_TCH
|
|
809
|
#ifdef DEBUG_TCH
|
|
804
|
printf("autocor for S22 significand : %u\n",autocor);
|
|
810
|
printf("autocor for S22 significand : %u\n",autocor);
|
|
805
|
printf("exp for S11 exponent : %u\n",exp);
|
|
811
|
printf("exp for S11 exponent : %u\n",exp);
|
|
806
|
printf("pt_uint8[1] for S22 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
|
|
812
|
printf("pt_uint8[1] for S22 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
|
|
807
|
printf("pt_uint8[0] for S22 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
|
|
813
|
printf("pt_uint8[0] for S22 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
|
|
808
|
printf("lfr_bp2[i*NB_BYTES_BP2+2] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+2], lfr_bp2[i*NB_BYTES_BP2+2]);
|
|
814
|
printf("lfr_bp2[i*NB_BYTES_BP2+2] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+2], lfr_bp2[i*NB_BYTES_BP2+2]);
|
|
809
|
printf("lfr_bp2[i*NB_BYTES_BP2+3] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+3], lfr_bp2[i*NB_BYTES_BP2+3]);
|
|
815
|
printf("lfr_bp2[i*NB_BYTES_BP2+3] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+3], lfr_bp2[i*NB_BYTES_BP2+3]);
|
|
810
|
#endif
|
|
816
|
#endif
|
|
811
|
// S33
|
|
817
|
// S33
|
|
812
|
significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16], &exponent); // 0.5 <= significand < 1
|
|
818
|
significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16], &exponent); // 0.5 <= significand < 1
|
|
813
|
// S33 = significand * 2^exponent
|
|
819
|
// S33 = significand * 2^exponent
|
|
814
|
#ifdef DEBUG_TCH
|
|
820
|
#ifdef DEBUG_TCH
|
|
815
|
printf("S33 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
|
|
821
|
printf("S33 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
|
|
816
|
printf("significand : %16.8e\n",significand);
|
|
822
|
printf("significand : %16.8e\n",significand);
|
|
817
|
printf("exponent : %d\n" ,exponent);
|
|
823
|
printf("exponent : %d\n" ,exponent);
|
|
818
|
#endif
|
|
824
|
#endif
|
|
819
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
825
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
820
|
exponent = expmin;
|
|
826
|
exponent = expmin;
|
|
821
|
significand = 0.5; // min value that can be recorded
|
|
827
|
significand = 0.5; // min value that can be recorded
|
|
822
|
}
|
|
828
|
}
|
|
823
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
829
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
824
|
exponent = expmax;
|
|
830
|
exponent = expmax;
|
|
825
|
significand = 1.0; // max value that can be recorded
|
|
831
|
significand = 1.0; // max value that can be recorded
|
|
826
|
}
|
|
832
|
}
|
|
827
|
if (significand == 0) { // in that case exponent == 0 too
|
|
833
|
if (significand == 0) { // in that case exponent == 0 too
|
|
828
|
exponent = expmin;
|
|
834
|
exponent = expmin;
|
|
829
|
significand = 0.5; // min value that can be recorded
|
|
835
|
significand = 0.5; // min value that can be recorded
|
|
830
|
}
|
|
836
|
}
|
|
831
|
|
|
837
|
|
|
832
|
autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
838
|
autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
833
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
839
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
834
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
840
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
835
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
841
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
836
|
tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
842
|
tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
837
|
// left place of the significand bits (nbitsig),
|
|
843
|
// left place of the significand bits (nbitsig),
|
|
838
|
// making the 16-bit word to be recorded
|
|
844
|
// making the 16-bit word to be recorded
|
|
839
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
845
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
840
|
#ifdef MSB_FIRST_TCH
|
|
846
|
#ifdef MSB_FIRST_TCH
|
|
841
|
lfr_bp2[i*NB_BYTES_BP2+4] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
847
|
lfr_bp2[i*NB_BYTES_BP2+4] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
842
|
lfr_bp2[i*NB_BYTES_BP2+5] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
848
|
lfr_bp2[i*NB_BYTES_BP2+5] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
843
|
#endif
|
|
849
|
#endif
|
|
844
|
#ifdef LSB_FIRST_TCH
|
|
850
|
#ifdef LSB_FIRST_TCH
|
|
845
|
lfr_bp2[i*NB_BYTES_BP2+4] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
851
|
lfr_bp2[i*NB_BYTES_BP2+4] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
846
|
lfr_bp2[i*NB_BYTES_BP2+5] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
852
|
lfr_bp2[i*NB_BYTES_BP2+5] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
847
|
#endif
|
|
853
|
#endif
|
|
848
|
#ifdef DEBUG_TCH
|
|
854
|
#ifdef DEBUG_TCH
|
|
849
|
printf("autocor for S33 significand : %u\n",autocor);
|
|
855
|
printf("autocor for S33 significand : %u\n",autocor);
|
|
850
|
printf("exp for S33 exponent : %u\n",exp);
|
|
856
|
printf("exp for S33 exponent : %u\n",exp);
|
|
851
|
printf("pt_uint8[1] for S33 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
|
|
857
|
printf("pt_uint8[1] for S33 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
|
|
852
|
printf("pt_uint8[0] for S33 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
|
|
858
|
printf("pt_uint8[0] for S33 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
|
|
853
|
printf("lfr_bp2[i*NB_BYTES_BP2+4] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+4], lfr_bp2[i*NB_BYTES_BP2+4]);
|
|
859
|
printf("lfr_bp2[i*NB_BYTES_BP2+4] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+4], lfr_bp2[i*NB_BYTES_BP2+4]);
|
|
854
|
printf("lfr_bp2[i*NB_BYTES_BP2+5] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+5], lfr_bp2[i*NB_BYTES_BP2+5]);
|
|
860
|
printf("lfr_bp2[i*NB_BYTES_BP2+5] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+5], lfr_bp2[i*NB_BYTES_BP2+5]);
|
|
855
|
#endif
|
|
861
|
#endif
|
|
856
|
// S44
|
|
862
|
// S44
|
|
857
|
significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21], &exponent); // 0.5 <= significand < 1
|
|
863
|
significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21], &exponent); // 0.5 <= significand < 1
|
|
858
|
// S44 = significand * 2^exponent
|
|
864
|
// S44 = significand * 2^exponent
|
|
859
|
#ifdef DEBUG_TCH
|
|
865
|
#ifdef DEBUG_TCH
|
|
860
|
printf("S44 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
|
|
866
|
printf("S44 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
|
|
861
|
printf("significand : %16.8e\n",significand);
|
|
867
|
printf("significand : %16.8e\n",significand);
|
|
862
|
printf("exponent : %d\n" ,exponent);
|
|
868
|
printf("exponent : %d\n" ,exponent);
|
|
863
|
#endif
|
|
869
|
#endif
|
|
864
|
|
|
870
|
|
|
865
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
871
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
866
|
exponent = expmin;
|
|
872
|
exponent = expmin;
|
|
867
|
significand = 0.5; // min value that can be recorded
|
|
873
|
significand = 0.5; // min value that can be recorded
|
|
868
|
}
|
|
874
|
}
|
|
869
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
875
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
870
|
exponent = expmax;
|
|
876
|
exponent = expmax;
|
|
871
|
significand = 1.0; // max value that can be recorded
|
|
877
|
significand = 1.0; // max value that can be recorded
|
|
872
|
}
|
|
878
|
}
|
|
873
|
if (significand == 0) { // in that case exponent == 0 too
|
|
879
|
if (significand == 0) { // in that case exponent == 0 too
|
|
874
|
exponent = expmin;
|
|
880
|
exponent = expmin;
|
|
875
|
significand = 0.5; // min value that can be recorded
|
|
881
|
significand = 0.5; // min value that can be recorded
|
|
876
|
}
|
|
882
|
}
|
|
877
|
|
|
883
|
|
|
878
|
autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
884
|
autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
879
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
885
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
880
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
886
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
881
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
887
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
882
|
tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
888
|
tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
883
|
// left place of the significand bits (nbitsig),
|
|
889
|
// left place of the significand bits (nbitsig),
|
|
884
|
// making the 16-bit word to be recorded
|
|
890
|
// making the 16-bit word to be recorded
|
|
885
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
891
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
886
|
#ifdef MSB_FIRST_TCH
|
|
892
|
#ifdef MSB_FIRST_TCH
|
|
887
|
lfr_bp2[i*NB_BYTES_BP2+6] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
893
|
lfr_bp2[i*NB_BYTES_BP2+6] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
888
|
lfr_bp2[i*NB_BYTES_BP2+7] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
894
|
lfr_bp2[i*NB_BYTES_BP2+7] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
889
|
#endif
|
|
895
|
#endif
|
|
890
|
#ifdef LSB_FIRST_TCH
|
|
896
|
#ifdef LSB_FIRST_TCH
|
|
891
|
lfr_bp2[i*NB_BYTES_BP2+6] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
897
|
lfr_bp2[i*NB_BYTES_BP2+6] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
892
|
lfr_bp2[i*NB_BYTES_BP2+7] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
898
|
lfr_bp2[i*NB_BYTES_BP2+7] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
893
|
#endif
|
|
899
|
#endif
|
|
894
|
#ifdef DEBUG_TCH
|
|
900
|
#ifdef DEBUG_TCH
|
|
895
|
printf("autocor for S44 significand : %u\n",autocor);
|
|
901
|
printf("autocor for S44 significand : %u\n",autocor);
|
|
896
|
printf("exp for S44 exponent : %u\n",exp);
|
|
902
|
printf("exp for S44 exponent : %u\n",exp);
|
|
897
|
printf("pt_uint8[1] for S44 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
|
|
903
|
printf("pt_uint8[1] for S44 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
|
|
898
|
printf("pt_uint8[0] for S44 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
|
|
904
|
printf("pt_uint8[0] for S44 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
|
|
899
|
printf("lfr_bp2[i*NB_BYTES_BP2+6] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+6], lfr_bp2[i*NB_BYTES_BP2+6]);
|
|
905
|
printf("lfr_bp2[i*NB_BYTES_BP2+6] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+6], lfr_bp2[i*NB_BYTES_BP2+6]);
|
|
900
|
printf("lfr_bp2[i*NB_BYTES_BP2+7] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+7], lfr_bp2[i*NB_BYTES_BP2+7]);
|
|
906
|
printf("lfr_bp2[i*NB_BYTES_BP2+7] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+7], lfr_bp2[i*NB_BYTES_BP2+7]);
|
|
901
|
#endif
|
|
907
|
#endif
|
|
902
|
// S55
|
|
908
|
// S55
|
|
903
|
significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24], &exponent); // 0.5 <= significand < 1
|
|
909
|
significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24], &exponent); // 0.5 <= significand < 1
|
|
904
|
// S55 = significand * 2^exponent
|
|
910
|
// S55 = significand * 2^exponent
|
|
905
|
#ifdef DEBUG_TCH
|
|
911
|
#ifdef DEBUG_TCH
|
|
906
|
printf("S55 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
|
|
912
|
printf("S55 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
|
|
907
|
printf("significand : %16.8e\n",significand);
|
|
913
|
printf("significand : %16.8e\n",significand);
|
|
908
|
printf("exponent : %d\n" ,exponent);
|
|
914
|
printf("exponent : %d\n" ,exponent);
|
|
909
|
#endif
|
|
915
|
#endif
|
|
910
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
916
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
911
|
exponent = expmin;
|
|
917
|
exponent = expmin;
|
|
912
|
significand = 0.5; // min value that can be recorded
|
|
918
|
significand = 0.5; // min value that can be recorded
|
|
913
|
}
|
|
919
|
}
|
|
914
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
920
|
if (exponent > expmax) { // value should be < 0.5 * 2^(expmax+1)
|
|
915
|
exponent = expmax;
|
|
921
|
exponent = expmax;
|
|
916
|
significand = 1.0; // max value that can be recorded
|
|
922
|
significand = 1.0; // max value that can be recorded
|
|
917
|
}
|
|
923
|
}
|
|
918
|
if (significand == 0) { // in that case exponent == 0 too
|
|
924
|
if (significand == 0) { // in that case exponent == 0 too
|
|
919
|
exponent = expmin;
|
|
925
|
exponent = expmin;
|
|
920
|
significand = 0.5; // min value that can be recorded
|
|
926
|
significand = 0.5; // min value that can be recorded
|
|
921
|
}
|
|
927
|
}
|
|
922
|
|
|
928
|
|
|
923
|
autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
929
|
autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
|
|
924
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
930
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
925
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
931
|
exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
|
|
926
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
932
|
// the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
927
|
tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
933
|
tmp_uint16 = autocor | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
928
|
// left place of the significand bits (nbitsig),
|
|
934
|
// left place of the significand bits (nbitsig),
|
|
929
|
// making the 16-bit word to be recorded
|
|
935
|
// making the 16-bit word to be recorded
|
|
930
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
936
|
pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
|
|
931
|
#ifdef MSB_FIRST_TCH
|
|
937
|
#ifdef MSB_FIRST_TCH
|
|
932
|
lfr_bp2[i*NB_BYTES_BP2+8] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
938
|
lfr_bp2[i*NB_BYTES_BP2+8] = pt_uint8[0]; // Record MSB of tmp_uint16
|
|
933
|
lfr_bp2[i*NB_BYTES_BP2+9] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
939
|
lfr_bp2[i*NB_BYTES_BP2+9] = pt_uint8[1]; // Record LSB of tmp_uint16
|
|
934
|
//printf("MSB:\n");
|
|
940
|
//printf("MSB:\n");
|
|
935
|
#endif
|
|
941
|
#endif
|
|
936
|
#ifdef LSB_FIRST_TCH
|
|
942
|
#ifdef LSB_FIRST_TCH
|
|
937
|
lfr_bp2[i*NB_BYTES_BP2+8] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
943
|
lfr_bp2[i*NB_BYTES_BP2+8] = pt_uint8[1]; // Record MSB of tmp_uint16
|
|
938
|
lfr_bp2[i*NB_BYTES_BP2+9] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
944
|
lfr_bp2[i*NB_BYTES_BP2+9] = pt_uint8[0]; // Record LSB of tmp_uint16
|
|
939
|
//printf("LSB:\n");
|
|
945
|
//printf("LSB:\n");
|
|
940
|
#endif
|
|
946
|
#endif
|
|
941
|
#ifdef DEBUG_TCH
|
|
947
|
#ifdef DEBUG_TCH
|
|
942
|
printf("autocor for S55 significand : %u\n",autocor);
|
|
948
|
printf("autocor for S55 significand : %u\n",autocor);
|
|
943
|
printf("exp for S55 exponent : %u\n",exp);
|
|
949
|
printf("exp for S55 exponent : %u\n",exp);
|
|
944
|
printf("pt_uint8[1] for S55 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
|
|
950
|
printf("pt_uint8[1] for S55 exponent + significand : %.3d or %2x\n",pt_uint8[1], pt_uint8[1]);
|
|
945
|
printf("pt_uint8[0] for S55 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
|
|
951
|
printf("pt_uint8[0] for S55 significand : %.3d or %2x\n",pt_uint8[0], pt_uint8[0]);
|
|
946
|
printf("lfr_bp2[i*NB_BYTES_BP2+8] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+8], lfr_bp2[i*NB_BYTES_BP2+8]);
|
|
952
|
printf("lfr_bp2[i*NB_BYTES_BP2+8] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+8], lfr_bp2[i*NB_BYTES_BP2+8]);
|
|
947
|
printf("lfr_bp2[i*NB_BYTES_BP2+9] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+9], lfr_bp2[i*NB_BYTES_BP2+9]);
|
|
953
|
printf("lfr_bp2[i*NB_BYTES_BP2+9] : %3u or %2x\n",lfr_bp2[i*NB_BYTES_BP2+9], lfr_bp2[i*NB_BYTES_BP2+9]);
|
|
948
|
#endif
|
|
954
|
#endif
|
|
949
|
}
|
|
955
|
}
|
|
950
|
}
|
|
956
|
}
|
|
951
|
|
|
957
|
|
|
952
|
|
|
958
|
|
|
953
|
#endif // BASIC_PARAMETERS_H_INCLUDED
|
|
959
|
#endif // BASIC_PARAMETERS_H_INCLUDED
|