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