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