This diff has been collapsed as it changes many lines, (935 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
|
#include <math.h>
|
|
5
|
#include <math.h>
|
|
3
|
#include <stdio.h>
|
|
6
|
#include <stdio.h>
|
|
4
|
|
|
7
|
|
|
5
|
float k44_pe = 1;
|
|
8
|
#define K44_PE 0
|
|
6
|
float k55_pe = 1;
|
|
9
|
#define K55_PE 1
|
|
7
|
float k45_pe_re = 1;
|
|
10
|
#define K45_PE_RE 2
|
|
8
|
float k45_pe_im = 1;
|
|
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;
|
|
26
|
#define K24_NY_RE 16
|
|
11
|
float k14_sx_im = 1;
|
|
27
|
#define K24_NY_IM 17
|
|
12
|
float k15_sx_re = 1;
|
|
28
|
#define K25_NY_RE 18
|
|
13
|
float k15_sx_im = 1;
|
|
29
|
#define K25_NY_IM 19
|
|
14
|
float k24_sx_re = 1;
|
|
30
|
#define K34_NY_RE 20
|
|
15
|
float k24_sx_im = 1;
|
|
31
|
#define K34_NY_IM 21
|
|
16
|
float k25_sx_re = 1;
|
|
32
|
#define K35_NY_RE 22
|
|
17
|
float k25_sx_im = 1;
|
|
33
|
#define K35_NY_IM 23
|
|
18
|
float k34_sx_re = 1;
|
|
34
|
|
|
19
|
float k34_sx_im = 1;
|
|
35
|
#define K24_NZ_RE 24
|
|
20
|
float k35_sx_re = 1;
|
|
36
|
#define K24_NZ_IM 25
|
|
21
|
float k35_sx_im = 1;
|
|
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;
|
|
46
|
void init_k_f0(){
|
|
24
|
float k24_ny_im = 1;
|
|
47
|
unsigned char i;
|
|
25
|
float k25_ny_re = 1;
|
|
48
|
|
|
26
|
float k25_ny_im = 1;
|
|
49
|
for(i=0; i<NB_BINS_COMPRESSED_MATRIX_f0; i++){
|
|
27
|
float k34_ny_re = 1;
|
|
50
|
k_f0[i][K44_PE] = 1;
|
|
28
|
float k34_ny_im = 1;
|
|
51
|
k_f0[i][K55_PE] = 1;
|
|
29
|
float k35_ny_re = 1;
|
|
52
|
k_f0[i][K45_PE_RE] = 1;
|
|
30
|
float k35_ny_im = 1;
|
|
53
|
k_f0[i][K45_PE_IM] = 1;
|
|
31
|
|
|
54
|
|
|
32
|
float k24_nz_re = 1;
|
|
55
|
k_f0[i][K14_SX_RE] = 1;
|
|
33
|
float k24_nz_im = 1;
|
|
56
|
k_f0[i][K14_SX_IM] = 1;
|
|
34
|
float k25_nz_re = 1;
|
|
57
|
k_f0[i][K15_SX_RE] = 1;
|
|
35
|
float k25_nz_im = 1;
|
|
58
|
k_f0[i][K15_SX_IM] = 1;
|
|
36
|
float k34_nz_re = 1;
|
|
59
|
k_f0[i][K24_SX_RE] = 1;
|
|
37
|
float k34_nz_im = 1;
|
|
60
|
k_f0[i][K24_SX_IM] = 1;
|
|
38
|
float k35_nz_re = 1;
|
|
61
|
k_f0[i][K25_SX_RE] = 1;
|
|
39
|
float k35_nz_im = 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
|
float alpha_M = 45 * (3.1415927/180);
|
|
88
|
float alpha_M = 45 * (3.1415927/180);
|
|
42
|
|
|
89
|
|
|
43
|
void BP1_set(){
|
|
90
|
void BP1_set(){
|
|
44
|
int i, exponent;
|
|
91
|
int i, exponent;
|
|
45
|
// int j;
|
|
|
|
|
46
|
float PSDB, PSDE, tmp, NVEC_V0, NVEC_V1, NVEC_V2, aux, tr_SB_SB,
|
|
92
|
float PSDB, PSDE, tmp, NVEC_V0, NVEC_V1, NVEC_V2, aux, tr_SB_SB,
|
|
47
|
e_cross_b_re, e_cross_b_im,
|
|
93
|
e_cross_b_re, e_cross_b_im,
|
|
48
|
n_cross_e_scal_b_re, n_cross_e_scal_b_im,
|
|
94
|
n_cross_e_scal_b_re, n_cross_e_scal_b_im,
|
|
@@
-55,39
+101,37
void BP1_set(){
|
|
55
|
unsigned char tmp_u_char; // 8 bits
|
|
101
|
unsigned char tmp_u_char; // 8 bits
|
|
56
|
unsigned char *pt_u_char; // pointer on unsigned 8-bit bytes
|
|
102
|
unsigned char *pt_u_char; // pointer on unsigned 8-bit bytes
|
|
57
|
|
|
103
|
|
|
58
|
// unsigned char toto_u_char;
|
|
104
|
init_k_f0();
|
|
59
|
// unsigned char *pt_toto_u_char;
|
|
|
|
|
60
|
// signed char toto_s_char;
|
|
|
|
|
61
|
// float toto_f;
|
|
|
|
|
62
|
|
|
105
|
|
|
|
|
|
106
|
#ifdef DEBUG_TCH
|
|
63
|
printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0);
|
|
107
|
printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0);
|
|
64
|
printf("BP1 : \n");
|
|
108
|
printf("BP1 : \n");
|
|
|
|
|
109
|
#endif
|
|
65
|
|
|
110
|
|
|
66
|
// initialization for managing the exponents of the floating point data:
|
|
111
|
// initialization for managing the exponents of the floating point data:
|
|
67
|
nbitexp = 5; // number of bits for the exponent
|
|
112
|
nbitexp = 5; // number of bits for the exponent
|
|
68
|
expmax = 30; // maximum value of the exponent
|
|
113
|
expmax = 30; // maximum value of the exponent
|
|
69
|
expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value
|
|
114
|
expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value
|
|
70
|
printf("nbitexp : %d, expmax : %d, expmin : %d\n", nbitexp, expmax, expmin);
|
|
|
|
|
71
|
// for floating point data to be recorded on 12-bit words:
|
|
115
|
// for floating point data to be recorded on 12-bit words:
|
|
72
|
nbitsig = 12 - nbitexp; // number of bits for the significand
|
|
116
|
nbitsig = 12 - nbitexp; // number of bits for the significand
|
|
73
|
rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
|
|
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
|
// BP1 PSDB == PA_LFR_SC_BP1_PB_F0 == 12 bits = 5 bits (exponent) + 7 bits (significand)
|
|
126
|
// BP1 PSDB == PA_LFR_SC_BP1_PB_F0 == 12 bits = 5 bits (exponent) + 7 bits (significand)
|
|
79
|
PSDB = compressed_spectral_matrix_f0[i*30] // S11
|
|
127
|
PSDB = compressed_spectral_matrix_f0[i*30] // S11
|
|
80
|
+ compressed_spectral_matrix_f0[i*30+10] // S22
|
|
128
|
+ compressed_spectral_matrix_f0[i*30+9] // S22
|
|
81
|
+ compressed_spectral_matrix_f0[i*30+18]; // S33
|
|
129
|
+ compressed_spectral_matrix_f0[i*30+16]; // S33
|
|
82
|
|
|
130
|
|
|
83
|
significand = frexpf(PSDB/3, &exponent); // 0.5 <= significand < 1
|
|
131
|
significand = frexpf(PSDB/3, &exponent); // 0.5 <= significand < 1
|
|
84
|
// PSDB/3 = significand * 2^exponent
|
|
132
|
// PSDB/3 = significand * 2^exponent
|
|
85
|
// the division by 3 is to ensure that max value <= 2^30
|
|
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
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
135
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
92
|
exponent = expmin;
|
|
136
|
exponent = expmin;
|
|
93
|
significand = 0.5; // min value that can be recorded
|
|
137
|
significand = 0.5; // min value that can be recorded
|
|
@@
-101,46
+145,37
void BP1_set(){
|
|
101
|
significand = 0.5; // min value that can be recorded
|
|
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
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
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
|
// where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
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
|
|
152
|
pt_u_short_int = (unsigned short int*) &LFR_BP1_F0[i*9+2]; // Affect an unsigned short int pointer with the
|
|
109
|
// adress where the 16-bit word result will be stored
|
|
153
|
// 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
|
|
154
|
*pt_u_short_int = psd | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
111
|
// left place of the significand bits (nbitsig), making
|
|
155
|
// left place of the significand bits (nbitsig), making
|
|
112
|
// the 16-bit word to be recorded, and record it using the pointer
|
|
156
|
// the 16-bit word to be recorded, and record it using the pointer
|
|
113
|
#ifdef DEBUG_TCH
|
|
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
|
printf("psd for PSDB significand : %d\n",psd);
|
|
161
|
printf("psd for PSDB significand : %d\n",psd);
|
|
115
|
printf("tmp_u_short_int for PSDB exponent : %d\n",tmp_u_short_int);
|
|
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);
|
|
163
|
printf("*pt_u_short_int for PSDB exponent + significand: %.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]);
|
|
164
|
printf("LFR_BP1_F0[i*9+3] : %.3d or %.2x\n",LFR_BP1_F0[i*9+3], LFR_BP1_F0[i*9+3]);
|
|
118
|
printf("LFR_BP1_F0[i*9+7] : %.3d or %.2x\n",LFR_BP1_F0[i*9+7], LFR_BP1_F0[i*9+7]);
|
|
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
|
#endif
|
|
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
|
// BP1 PSDE == PA_LFR_SC_BP1_PE_F0 == 12 bits = 5 bits (exponent) + 7 bits (significand)
|
|
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
|
|
169
|
PSDE = compressed_spectral_matrix_f0[i*30+21] * k_f0[i][K44_PE] // S44
|
|
131
|
+ compressed_spectral_matrix_f0[i*30+28] * k55_pe // S55
|
|
170
|
+ compressed_spectral_matrix_f0[i*30+24] * k_f0[i][K55_PE] // S55
|
|
132
|
+ compressed_spectral_matrix_f0[i*30+26] * k45_pe_re // S45 Re
|
|
171
|
+ compressed_spectral_matrix_f0[i*30+22] * k_f0[i][K45_PE_RE] // S45 Re
|
|
133
|
- compressed_spectral_matrix_f0[i*30+27] * k45_pe_im; // S45 Im
|
|
172
|
- compressed_spectral_matrix_f0[i*30+23] * k_f0[i][K45_PE_IM]; // S45 Im
|
|
134
|
|
|
173
|
|
|
135
|
significand = frexpf(PSDE/2, &exponent); // 0.5 <= significand < 1
|
|
174
|
significand = frexpf(PSDE/2, &exponent); // 0.5 <= significand < 1
|
|
136
|
// PSDE/2 = significand * 2^exponent
|
|
175
|
// PSDE/2 = significand * 2^exponent
|
|
137
|
// the division by 2 is to ensure that max value <= 2^30
|
|
176
|
// the division by 2 is to ensure that max value <= 2^30
|
|
138
|
// should be reconsidered by taking into account the k-coefficients ...
|
|
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
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
179
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
145
|
exponent = expmin;
|
|
180
|
exponent = expmin;
|
|
146
|
significand = 0.5; // min value that can be recorded
|
|
181
|
significand = 0.5; // min value that can be recorded
|
|
@@
-154,137
+189,139
void BP1_set(){
|
|
154
|
significand = 0.5; // min value that can be recorded
|
|
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
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
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
|
// where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
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
|
// adress where the 16-bit word result will be stored
|
|
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
|
// left place of the significand bits (nbitsig), making
|
|
199
|
// left place of the significand bits (nbitsig), making
|
|
165
|
// the 16-bit word to be recorded, and record it using the pointer
|
|
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
|
printf("psd for PSDE significand : %d\n",psd);
|
|
205
|
printf("psd for PSDE significand : %d\n",psd);
|
|
167
|
printf("tmp_u_short_int for PSDE exponent : %d\n",tmp_u_short_int);
|
|
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);
|
|
207
|
printf("*pt_u_short_int for PSDE exponent + significand: %.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]);
|
|
208
|
printf("LFR_BP1_F0[i*9+1] : %.3d or %.2x\n",LFR_BP1_F0[i*9+1], LFR_BP1_F0[i*9+1]);
|
|
170
|
printf("LFR_BP1_F0[i*9+5] : %.3d or %.2x\n",LFR_BP1_F0[i*9+5], LFR_BP1_F0[i*9+5]);
|
|
209
|
printf("LFR_BP1_F0[i*9+0] : %.3d or %.2x\n",LFR_BP1_F0[i*9+0], LFR_BP1_F0[i*9+0]);
|
|
171
|
|
|
210
|
#endif
|
|
172
|
//==============================================================================
|
|
211
|
//==============================================================================
|
|
173
|
// BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
|
|
212
|
// BP1 normal wave vector == PA_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
|
|
174
|
// == PA_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
|
|
213
|
// == PA_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
|
|
175
|
// == PA_LFR_SC_BP1_NVEC_V2_F0 == 1 sign bit
|
|
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
|
|
215
|
tmp = sqrt( compressed_spectral_matrix_f0[i*30+2] *compressed_spectral_matrix_f0[i*30+2] //Im S12
|
|
177
|
+compressed_spectral_matrix_f0[i*30+5] *compressed_spectral_matrix_f0[i*30+5] //Im S13
|
|
216
|
+compressed_spectral_matrix_f0[i*30+4] *compressed_spectral_matrix_f0[i*30+4] //Im S13
|
|
178
|
+compressed_spectral_matrix_f0[i*30+13]*compressed_spectral_matrix_f0[i*30+13] //Im S23
|
|
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
|
|
219
|
NVEC_V0 = compressed_spectral_matrix_f0[i*30+11]/ tmp; // S23 Im => n1
|
|
181
|
NVEC_V1 = -compressed_spectral_matrix_f0[i*30+5] / tmp; // S13 Im => n2
|
|
220
|
NVEC_V1 = -compressed_spectral_matrix_f0[i*30+4] / tmp; // S13 Im => n2
|
|
182
|
NVEC_V2 = compressed_spectral_matrix_f0[i*30+3] / tmp; // S12 Im => n3
|
|
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
|
printf("NVEC_V0 : %16.8e\n",NVEC_V0);
|
|
235
|
printf("NVEC_V0 : %16.8e\n",NVEC_V0);
|
|
185
|
printf("NVEC_V1 : %16.8e\n",NVEC_V1);
|
|
236
|
printf("NVEC_V1 : %16.8e\n",NVEC_V1);
|
|
186
|
printf("NVEC_V2 : %16.8e\n",NVEC_V2);
|
|
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
|
printf("LFR_BP1_F0[i*9+4] for NVEC_V0 : %u\n",LFR_BP1_F0[i*9+4]);
|
|
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]);
|
|
239
|
printf("LFR_BP1_F0[i*9+5] for NVEC_V1 : %u\n",LFR_BP1_F0[i*9+5]);
|
|
196
|
printf("LFR_BP1_F0[i*9+2] for NVEC_V2 : %u\n",LFR_BP1_F0[i*9+2]);
|
|
240
|
printf("LFR_BP1_F0[i*9+6] for NVEC_V2 : %u\n",LFR_BP1_F0[i*9+6]);
|
|
197
|
|
|
241
|
#endif
|
|
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
|
|
|
|
|
|
210
|
//=======================================================
|
|
242
|
//=======================================================
|
|
211
|
// BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits
|
|
243
|
// BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits
|
|
212
|
aux = 2*tmp / PSDB; // compute the ellipticity
|
|
244
|
aux = 2*tmp / PSDB; // compute the ellipticity
|
|
213
|
|
|
245
|
|
|
214
|
printf("ellipticity : %16.8e\n",aux);
|
|
|
|
|
215
|
|
|
|
|
|
216
|
tmp_u_char = (unsigned char) (aux*15 + 0.5); // shift and cast into a 8-bit unsigned char with rounding
|
|
246
|
tmp_u_char = (unsigned char) (aux*15 + 0.5); // shift and cast into a 8-bit unsigned char with rounding
|
|
217
|
// where just the first 4 bits are used (0, ..., 15)
|
|
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
|
// of the sign bit of NVEC_V2 (recorded
|
|
249
|
// of the sign bit of NVEC_V2 (recorded
|
|
220
|
// previously in LFR_BP1_F0[i*9+2])
|
|
250
|
// previously in LFR_BP1_F0[i*9+6])
|
|
221
|
|
|
251
|
#ifdef DEBUG_TCH
|
|
|
|
|
252
|
printf("ellipticity : %16.8e\n",aux);
|
|
222
|
printf("tmp_u_char for ellipticity : %u\n",tmp_u_char);
|
|
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]);
|
|
254
|
printf("LFR_BP1_F0[i*9+6] for NVEC_V2 + ellipticity : %u\n",LFR_BP1_F0[i*9+6]);
|
|
224
|
|
|
255
|
#endif
|
|
225
|
//==============================================================
|
|
256
|
//==============================================================
|
|
226
|
// BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits
|
|
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]
|
|
258
|
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]
|
|
259
|
+ compressed_spectral_matrix_f0[i*30+9] *compressed_spectral_matrix_f0[i*30+9]
|
|
229
|
+ compressed_spectral_matrix_f0[i*30+18]*compressed_spectral_matrix_f0[i*30+18]
|
|
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
|
+ 2 * compressed_spectral_matrix_f0[i*30+2] *compressed_spectral_matrix_f0[i*30+2]
|
|
262
|
+ 2 * compressed_spectral_matrix_f0[i*30+2] *compressed_spectral_matrix_f0[i*30+2]
|
|
231
|
+ 2 * compressed_spectral_matrix_f0[i*30+3] *compressed_spectral_matrix_f0[i*30+3]
|
|
263
|
+ 2 * compressed_spectral_matrix_f0[i*30+3] *compressed_spectral_matrix_f0[i*30+3]
|
|
232
|
+ 2 * compressed_spectral_matrix_f0[i*30+4] *compressed_spectral_matrix_f0[i*30+4]
|
|
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]
|
|
265
|
+ 2 * compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+10]
|
|
234
|
+ 2 * compressed_spectral_matrix_f0[i*30+12]*compressed_spectral_matrix_f0[i*30+12]
|
|
266
|
+ 2 * compressed_spectral_matrix_f0[i*30+11]*compressed_spectral_matrix_f0[i*30+11];
|
|
235
|
+ 2 * compressed_spectral_matrix_f0[i*30+13]*compressed_spectral_matrix_f0[i*30+13];
|
|
|
|
|
236
|
aux = PSDB*PSDB;
|
|
267
|
aux = PSDB*PSDB;
|
|
237
|
tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // compute the degree of polarisation
|
|
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
|
tmp_u_char = (unsigned char) (tmp*7 + 0.5);// shift and cast into a 8-bit unsigned char with rounding
|
|
270
|
tmp_u_char = (unsigned char) (tmp*7 + 0.5);// shift and cast into a 8-bit unsigned char with rounding
|
|
242
|
// where just the first 3 bits are used (0, ..., 7)
|
|
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
|
|
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
|
|
244
|
// (from the right to the left) of LFR_BP1_F0[i*9+2]
|
|
273
|
// (from the right to the left) of LFR_BP1_F0[i*9+6]
|
|
245
|
|
|
274
|
#ifdef DEBUG_TCH
|
|
|
|
|
275
|
printf("DOP : %16.8e\n",tmp);
|
|
246
|
printf("tmp_u_char for DOP : %u\n",tmp_u_char);
|
|
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]);
|
|
277
|
printf("LFR_BP1_F0[i*9+6] for NVEC_V2 + ellipticity + DOP : %u\n",LFR_BP1_F0[i*9+6]);
|
|
248
|
|
|
278
|
#endif
|
|
249
|
//=======================================================================================
|
|
279
|
//=======================================================================================
|
|
250
|
// BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 8 (+ 2) bits
|
|
280
|
// BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 8 (+ 2) bits
|
|
251
|
// = 5 bits (exponent) + 3 bits (significand)
|
|
281
|
// = 5 bits (exponent) + 3 bits (significand)
|
|
252
|
// + 1 sign bit + 1 argument bit (two sectors)
|
|
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
|
|
283
|
e_cross_b_re = compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_SX_RE] //S34 Re
|
|
254
|
+ compressed_spectral_matrix_f0[i*30+22]*k35_sx_re //S35 Re
|
|
284
|
+ compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_SX_RE] //S35 Re
|
|
255
|
+ compressed_spectral_matrix_f0[i*30+6] *k14_sx_re //S14 Re
|
|
285
|
+ compressed_spectral_matrix_f0[i*30+5] *k_f0[i][K14_SX_RE] //S14 Re
|
|
256
|
+ compressed_spectral_matrix_f0[i*30+8] *k15_sx_re //S15 Re
|
|
286
|
+ compressed_spectral_matrix_f0[i*30+7] *k_f0[i][K15_SX_RE] //S15 Re
|
|
257
|
+ compressed_spectral_matrix_f0[i*30+14]*k24_sx_re //S24 Re
|
|
287
|
+ compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_SX_RE] //S24 Re
|
|
258
|
+ compressed_spectral_matrix_f0[i*30+16]*k25_sx_re //S25 Re
|
|
288
|
+ compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_SX_RE] //S25 Re
|
|
259
|
+ compressed_spectral_matrix_f0[i*30+21]*k34_sx_im //S34 Im
|
|
289
|
+ compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_SX_IM] //S34 Im
|
|
260
|
+ compressed_spectral_matrix_f0[i*30+23]*k35_sx_im //S35 Im
|
|
290
|
+ compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_SX_IM] //S35 Im
|
|
261
|
+ compressed_spectral_matrix_f0[i*30+7] *k14_sx_im //S14 Im
|
|
291
|
+ compressed_spectral_matrix_f0[i*30+6] *k_f0[i][K14_SX_IM] //S14 Im
|
|
262
|
+ compressed_spectral_matrix_f0[i*30+9] *k15_sx_im //S15 Im
|
|
292
|
+ compressed_spectral_matrix_f0[i*30+8] *k_f0[i][K15_SX_IM] //S15 Im
|
|
263
|
+ compressed_spectral_matrix_f0[i*30+15]*k24_sx_im //S24 Im
|
|
293
|
+ compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_SX_IM] //S24 Im
|
|
264
|
+ compressed_spectral_matrix_f0[i*30+17]*k25_sx_im; //S25 Im
|
|
294
|
+ compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_SX_IM]; //S25 Im
|
|
265
|
// Im(S_ji) = -Im(S_ij)
|
|
295
|
// Im(S_ji) = -Im(S_ij)
|
|
266
|
// k_ji = k_ij
|
|
296
|
// k_ji = k_ij
|
|
267
|
e_cross_b_im = compressed_spectral_matrix_f0[i*30+20]*k34_sx_im //S34 Re
|
|
297
|
e_cross_b_im = compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_SX_IM] //S34 Re
|
|
268
|
+ compressed_spectral_matrix_f0[i*30+22]*k35_sx_im //S35 Re
|
|
298
|
+ compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_SX_IM] //S35 Re
|
|
269
|
+ compressed_spectral_matrix_f0[i*30+6] *k14_sx_im //S14 Re
|
|
299
|
+ compressed_spectral_matrix_f0[i*30+5] *k_f0[i][K14_SX_IM] //S14 Re
|
|
270
|
+ compressed_spectral_matrix_f0[i*30+8] *k15_sx_im //S15 Re
|
|
300
|
+ compressed_spectral_matrix_f0[i*30+7] *k_f0[i][K15_SX_IM] //S15 Re
|
|
271
|
+ compressed_spectral_matrix_f0[i*30+14]*k24_sx_im //S24 Re
|
|
301
|
+ compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_SX_IM] //S24 Re
|
|
272
|
+ compressed_spectral_matrix_f0[i*30+16]*k25_sx_im //S25 Re
|
|
302
|
+ compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_SX_IM] //S25 Re
|
|
273
|
- compressed_spectral_matrix_f0[i*30+21]*k34_sx_re //S34 Im
|
|
303
|
- compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_SX_RE] //S34 Im
|
|
274
|
- compressed_spectral_matrix_f0[i*30+23]*k35_sx_re //S35 Im
|
|
304
|
- compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_SX_RE] //S35 Im
|
|
275
|
- compressed_spectral_matrix_f0[i*30+7] *k14_sx_re //S14 Im
|
|
305
|
- compressed_spectral_matrix_f0[i*30+6] *k_f0[i][K14_SX_RE] //S14 Im
|
|
276
|
- compressed_spectral_matrix_f0[i*30+9] *k15_sx_re //S15 Im
|
|
306
|
- compressed_spectral_matrix_f0[i*30+8] *k_f0[i][K15_SX_RE] //S15 Im
|
|
277
|
- compressed_spectral_matrix_f0[i*30+15]*k24_sx_re //S24 Im
|
|
307
|
- compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_SX_RE] //S24 Im
|
|
278
|
- compressed_spectral_matrix_f0[i*30+17]*k25_sx_re; //S25 Im
|
|
308
|
- compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_SX_RE]; //S25 Im
|
|
279
|
|
|
309
|
#ifdef DEBUG_TCH
|
|
280
|
printf("ReaSX / 2 : %16.8e\n",e_cross_b_re/2);
|
|
310
|
printf("ReaSX / 2 : %16.8e\n",e_cross_b_re/2);
|
|
281
|
|
|
311
|
#endif
|
|
282
|
pt_u_char = (unsigned char*) &e_cross_b_re; // Affect an unsigned char pointer with the adress of e_cross_b_re
|
|
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
|
// Record it at the 8th bit position (from the right to the left)
|
|
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
|
pt_u_char[3] = (pt_u_char[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
|
|
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
|
significand = frexpf(e_cross_b_re/2, &exponent);// 0.5 <= significand < 1
|
|
325
|
significand = frexpf(e_cross_b_re/2, &exponent);// 0.5 <= significand < 1
|
|
289
|
// ReaSX/2 = significand * 2^exponent
|
|
326
|
// ReaSX/2 = significand * 2^exponent
|
|
290
|
// The division by 2 is to ensure that max value <= 2^30 (rough estimate)
|
|
327
|
// The division by 2 is to ensure that max value <= 2^30 (rough estimate)
|
|
@@
-302,87
+339,103
void BP1_set(){
|
|
302
|
exponent = expmin;
|
|
339
|
exponent = expmin;
|
|
303
|
significand = 0.5; // min value that can be recorded
|
|
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
|
// where just the first 3 bits are used (0, ..., 7)
|
|
344
|
// where just the first 3 bits are used (0, ..., 7)
|
|
311
|
tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where
|
|
345
|
tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where
|
|
312
|
// just the first 5 bits are used (0, ..., 2^5-1)
|
|
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
|
printf("tmp_u_char for ReaSX exponent : %d\n",tmp_u_char);
|
|
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
|
|
353
|
#endif
|
|
316
|
// with LFR_BP1_F0[i*9+1]
|
|
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
|
|
317
|
printf("LFR_BP1_F0[i*9+1] for ReaSX exponent + significand : %u\n",LFR_BP1_F0[i*9+1]);
|
|
355
|
// with LFR_BP1_F0[i*9+7]
|
|
318
|
printf("LFR_BP1_F0[i*9+8] for ReaSX sign + PSDB 'exponent' : %u\n",LFR_BP1_F0[i*9+8]);
|
|
356
|
#ifdef DEBUG_TCH
|
|
319
|
|
|
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
|
printf("ImaSX / 2 : %16.8e\n",e_cross_b_im/2);
|
|
359
|
printf("ImaSX / 2 : %16.8e\n",e_cross_b_im/2);
|
|
321
|
|
|
360
|
#endif
|
|
322
|
pt_u_char = (unsigned char*) &e_cross_b_im; // Affect an unsigned char pointer with the adress of e_cross_b_im
|
|
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
|
pt_u_char[3] = pt_u_char[3] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX|
|
|
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
|
tmp_u_char = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect
|
|
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
|
// an unsigned 8-bit char with 01000000; otherwise with null.
|
|
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
|
|
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
|
|
327
|
// to the left) of LFR_BP1_F0[i*9+7], by simple logical addition.
|
|
371
|
// to the left) of LFR_BP1_F0[i*9+1], by simple logical addition.
|
|
328
|
|
|
372
|
#ifdef DEBUG_TCH
|
|
329
|
printf("|ImaSX| / 2 : %16.8e\n",e_cross_b_im/2);
|
|
373
|
printf("|ImaSX| / 2 : %16.8e\n",e_cross_b_im/2);
|
|
330
|
printf("ArgSX sign : %u\n",tmp_u_char);
|
|
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]);
|
|
375
|
printf("LFR_BP1_F0[i*9+1] for ReaSX & ArgSX signs + PSDE 'exponent' : %u\n",LFR_BP1_F0[i*9+1]);
|
|
332
|
|
|
376
|
#endif
|
|
333
|
//======================================================================
|
|
377
|
//======================================================================
|
|
334
|
// BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 8 (+ 2) bits
|
|
378
|
// BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 8 (+ 2) bits
|
|
335
|
// = 5 bits (exponent) + 3 bits (significand)
|
|
379
|
// = 5 bits (exponent) + 3 bits (significand)
|
|
336
|
// + 1 sign bit + 1 argument bit (two sectors)
|
|
380
|
// + 1 sign bit + 1 argument bit (two sectors)
|
|
337
|
ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2;
|
|
381
|
ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2;
|
|
338
|
nz = NVEC_V0;
|
|
382
|
nz = NVEC_V0;
|
|
339
|
bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spectral_matrix_f0[i*30+10] // S22 Re
|
|
383
|
bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spectral_matrix_f0[i*30+9] // S22 Re
|
|
340
|
+ sin(alpha_M)*sin(alpha_M)*compressed_spectral_matrix_f0[i*30+18] // S33 Re
|
|
384
|
+ sin(alpha_M)*sin(alpha_M)*compressed_spectral_matrix_f0[i*30+16] // S33 Re
|
|
341
|
- 2*sin(alpha_M)*cos(alpha_M)*compressed_spectral_matrix_f0[i*30+12]; // S23 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
|
|
387
|
n_cross_e_scal_b_re = ny * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NY_RE] //S24 Re
|
|
344
|
+compressed_spectral_matrix_f0[i*30+16]*k25_ny_re //S25 Re
|
|
388
|
+compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NY_RE] //S25 Re
|
|
345
|
+compressed_spectral_matrix_f0[i*30+20]*k34_ny_re //S34 Re
|
|
389
|
+compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NY_RE] //S34 Re
|
|
346
|
+compressed_spectral_matrix_f0[i*30+22]*k35_ny_re //S35 Re
|
|
390
|
+compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NY_RE] //S35 Re
|
|
347
|
+compressed_spectral_matrix_f0[i*30+15]*k24_ny_im //S24 Im
|
|
391
|
+compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NY_IM] //S24 Im
|
|
348
|
+compressed_spectral_matrix_f0[i*30+17]*k25_ny_im //S25 Im
|
|
392
|
+compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NY_IM] //S25 Im
|
|
349
|
+compressed_spectral_matrix_f0[i*30+21]*k34_ny_im //S34 Im
|
|
393
|
+compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NY_IM] //S34 Im
|
|
350
|
+compressed_spectral_matrix_f0[i*30+23]*k35_ny_im) //S35 Im
|
|
394
|
+compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NY_IM]) //S35 Im
|
|
351
|
+ nz * (compressed_spectral_matrix_f0[i*30+14]*k24_nz_re //S24 Re
|
|
395
|
+ nz * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NZ_RE] //S24 Re
|
|
352
|
+compressed_spectral_matrix_f0[i*30+16]*k25_nz_re //S25 Re
|
|
396
|
+compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NZ_RE] //S25 Re
|
|
353
|
+compressed_spectral_matrix_f0[i*30+20]*k34_nz_re //S34 Re
|
|
397
|
+compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NZ_RE] //S34 Re
|
|
354
|
+compressed_spectral_matrix_f0[i*30+22]*k35_nz_re //S35 Re
|
|
398
|
+compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NZ_RE] //S35 Re
|
|
355
|
+compressed_spectral_matrix_f0[i*30+15]*k24_nz_im //S24 Im
|
|
399
|
+compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NZ_IM] //S24 Im
|
|
356
|
+compressed_spectral_matrix_f0[i*30+17]*k25_nz_im //S25 Im
|
|
400
|
+compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NZ_IM] //S25 Im
|
|
357
|
+compressed_spectral_matrix_f0[i*30+21]*k34_nz_im //S34 Im
|
|
401
|
+compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NZ_IM] //S34 Im
|
|
358
|
+compressed_spectral_matrix_f0[i*30+23]*k35_nz_im);//S35 Im
|
|
402
|
+compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NZ_IM]);//S35 Im
|
|
359
|
// Im(S_ji) = -Im(S_ij)
|
|
403
|
// Im(S_ji) = -Im(S_ij)
|
|
360
|
// k_ji = k_ij
|
|
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
|
|
405
|
n_cross_e_scal_b_im = ny * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NY_IM] //S24 Re
|
|
362
|
+compressed_spectral_matrix_f0[i*30+16]*k25_ny_im //S25 Re
|
|
406
|
+compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NY_IM] //S25 Re
|
|
363
|
+compressed_spectral_matrix_f0[i*30+20]*k34_ny_im //S34 Re
|
|
407
|
+compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NY_IM] //S34 Re
|
|
364
|
+compressed_spectral_matrix_f0[i*30+22]*k35_ny_im //S35 Re
|
|
408
|
+compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NY_IM] //S35 Re
|
|
365
|
-compressed_spectral_matrix_f0[i*30+15]*k24_ny_re //S24 Im
|
|
409
|
-compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NY_RE] //S24 Im
|
|
366
|
-compressed_spectral_matrix_f0[i*30+17]*k25_ny_re //S25 Im
|
|
410
|
-compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NY_RE] //S25 Im
|
|
367
|
-compressed_spectral_matrix_f0[i*30+21]*k34_ny_re //S34 Im
|
|
411
|
-compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NY_RE] //S34 Im
|
|
368
|
-compressed_spectral_matrix_f0[i*30+23]*k35_ny_re) //S35 Im
|
|
412
|
-compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NY_RE]) //S35 Im
|
|
369
|
+ nz * (compressed_spectral_matrix_f0[i*30+14]*k24_nz_im //S24 Re
|
|
413
|
+ nz * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NZ_IM] //S24 Re
|
|
370
|
+compressed_spectral_matrix_f0[i*30+16]*k25_nz_im //S25 Re
|
|
414
|
+compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NZ_IM] //S25 Re
|
|
371
|
+compressed_spectral_matrix_f0[i*30+20]*k34_nz_im //S34 Re
|
|
415
|
+compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NZ_IM] //S34 Re
|
|
372
|
+compressed_spectral_matrix_f0[i*30+22]*k35_nz_im //S35 Re
|
|
416
|
+compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NZ_IM] //S35 Re
|
|
373
|
-compressed_spectral_matrix_f0[i*30+15]*k24_nz_re //S24 Im
|
|
417
|
-compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NZ_RE] //S24 Im
|
|
374
|
-compressed_spectral_matrix_f0[i*30+17]*k25_nz_re //S25 Im
|
|
418
|
-compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NZ_RE] //S25 Im
|
|
375
|
-compressed_spectral_matrix_f0[i*30+21]*k34_nz_re //S34 Im
|
|
419
|
-compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NZ_RE] //S34 Im
|
|
376
|
-compressed_spectral_matrix_f0[i*30+23]*k35_nz_re);//S35 Im
|
|
420
|
-compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NZ_RE]);//S35 Im
|
|
377
|
|
|
421
|
#ifdef DEBUG_TCH
|
|
378
|
printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re);
|
|
422
|
printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re);
|
|
379
|
printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im);
|
|
423
|
printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im);
|
|
|
|
|
424
|
#endif
|
|
380
|
// vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re)
|
|
425
|
// vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re)
|
|
381
|
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
|
|
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
|
// Record it at the 8th bit position (from the right to the left)
|
|
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
|
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|
|
|
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
|
vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI|
|
|
439
|
vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI|
|
|
387
|
|
|
440
|
|
|
388
|
significand = frexpf(vphi/2, &exponent); // 0.5 <= significand < 1
|
|
441
|
significand = frexpf(vphi/2, &exponent); // 0.5 <= significand < 1
|
|
@@
-402,33
+455,42
void BP1_set(){
|
|
402
|
exponent = expmin;
|
|
455
|
exponent = expmin;
|
|
403
|
significand = 0.5; // min value that can be recorded
|
|
456
|
significand = 0.5; // min value that can be recorded
|
|
404
|
}
|
|
457
|
}
|
|
|
|
|
458
|
#ifdef DEBUG_TCH
|
|
405
|
printf("|VPHI| / 2 : %16.8e\n",vphi/2);
|
|
459
|
printf("|VPHI| / 2 : %16.8e\n",vphi/2);
|
|
406
|
printf("significand : %16.8e\n",significand);
|
|
460
|
printf("significand : %16.8e\n",significand);
|
|
407
|
printf("exponent : %d\n" ,exponent);
|
|
461
|
printf("exponent : %d\n" ,exponent);
|
|
408
|
|
|
462
|
#endif
|
|
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
|
|
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
|
// where just the first 3 bits are used (0, ..., 7)
|
|
464
|
// where just the first 3 bits are used (0, ..., 7)
|
|
411
|
tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where
|
|
465
|
tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where
|
|
412
|
// just the first 5 bits are used (0, ..., 2^5-1)
|
|
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
|
printf("tmp_u_char for VPHI exponent : %d\n",tmp_u_char);
|
|
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
|
|
470
|
#endif
|
|
416
|
// with LFR_BP1_F0[i*9+0]
|
|
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
|
|
417
|
printf("LFR_BP1_F0[i*9+0] for VPHI exponent + significand : %u\n",LFR_BP1_F0[i*9+0]);
|
|
472
|
// with LFR_BP1_F0[i*9+8]
|
|
418
|
printf("LFR_BP1_F0[i*9+6] for VPHI sign + PSDE 'exponent' : %u\n",LFR_BP1_F0[i*9+6]);
|
|
473
|
#ifdef DEBUG_TCH
|
|
419
|
|
|
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
|
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
|
|
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
|
pt_u_char[3] = pt_u_char[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaSX|
|
|
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
|
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
|
|
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
|
// an unsigned 8-bit char with 01000000; otherwise with null.
|
|
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
|
|
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
|
|
425
|
// to the left) of LFR_BP1_F0[i*9+6], by simple logical addition.
|
|
487
|
// to the left) of LFR_BP1_F0[i*9+3], by simple logical addition.
|
|
426
|
|
|
488
|
#ifdef DEBUG_TCH
|
|
427
|
printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im);
|
|
489
|
printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im);
|
|
428
|
printf("|n_cross_e_scal_b_im|/bx_bx_star/2: %16.8e\n",n_cross_e_scal_b_im/bx_bx_star/2);
|
|
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
|
printf("ArgNEBX sign : %u\n",tmp_u_char);
|
|
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]);
|
|
492
|
printf("LFR_BP1_F0[i*9+3] for VPHI & ArgNEBX signs + PSDB 'exponent' : %u\n",LFR_BP1_F0[i*9+3]);
|
|
431
|
|
|
493
|
#endif
|
|
432
|
}
|
|
494
|
}
|
|
433
|
}
|
|
495
|
}
|
|
434
|
|
|
496
|
|
|
@@
-440,19
+502,24
void BP2_set(){
|
|
440
|
unsigned short int autocor, tmp_u_short_int; // 16 bits
|
|
502
|
unsigned short int autocor, tmp_u_short_int; // 16 bits
|
|
441
|
unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words
|
|
503
|
unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words
|
|
442
|
|
|
504
|
|
|
|
|
|
505
|
#ifdef DEBUG_TCH
|
|
443
|
printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0);
|
|
506
|
printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0);
|
|
444
|
printf("BP2 : \n");
|
|
507
|
printf("BP2 : \n");
|
|
|
|
|
508
|
#endif
|
|
445
|
|
|
509
|
|
|
446
|
// For floating point data to be recorded on 16-bit words :
|
|
510
|
// For floating point data to be recorded on 16-bit words :
|
|
447
|
nbitexp = 6; // number of bits for the exponent
|
|
511
|
nbitexp = 6; // number of bits for the exponent
|
|
448
|
nbitsig = 16 - nbitexp; // number of bits for the significand
|
|
512
|
nbitsig = 16 - nbitexp; // number of bits for the significand
|
|
449
|
rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
|
|
513
|
rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
|
|
450
|
printf("nbitexp : %d, nbitsig : %d, rangesig : %d\n", nbitexp, nbitsig, rangesig);
|
|
|
|
|
451
|
expmax = 32;
|
|
514
|
expmax = 32;
|
|
452
|
expmin = expmax - (1 << nbitexp) + 1;
|
|
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
|
// BP2 normalized cross correlations == PA_LFR_SC_BP2_CROSS_F0 == 10 * (8+8) bits
|
|
524
|
// BP2 normalized cross correlations == PA_LFR_SC_BP2_CROSS_F0 == 10 * (8+8) bits
|
|
458
|
// == PA_LFR_SC_BP2_CROSS_RE_0_F0 == 8 bits
|
|
525
|
// == PA_LFR_SC_BP2_CROSS_RE_0_F0 == 8 bits
|
|
@@
-476,88
+543,105
void BP2_set(){
|
|
476
|
// == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits
|
|
543
|
// == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits
|
|
477
|
// == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits
|
|
544
|
// == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits
|
|
478
|
// S12
|
|
545
|
// S12
|
|
479
|
aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+10]);
|
|
546
|
aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+9]);
|
|
480
|
cross_re = compressed_spectral_matrix_f0[i*30+2] / aux;
|
|
547
|
cross_re = compressed_spectral_matrix_f0[i*30+1] / aux;
|
|
481
|
cross_im = compressed_spectral_matrix_f0[i*30+3] / aux;
|
|
548
|
cross_im = compressed_spectral_matrix_f0[i*30+2] / 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
|
|
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
|
|
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
|
|
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
|
|
484
|
printf("LFR_BP2_F0[i*30+19] for cross12_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+19]);
|
|
551
|
#ifdef DEBUG_TCH
|
|
485
|
printf("LFR_BP2_F0[i*30+9] for cross12_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+9]);
|
|
552
|
printf("LFR_BP2_F0[i*30+10] for cross12_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+10]);
|
|
486
|
|
|
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
|
// S13
|
|
555
|
// S13
|
|
488
|
aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+18]);
|
|
556
|
aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+16]);
|
|
489
|
cross_re = compressed_spectral_matrix_f0[i*30+4] / aux;
|
|
557
|
cross_re = compressed_spectral_matrix_f0[i*30+3] / aux;
|
|
490
|
cross_im = compressed_spectral_matrix_f0[i*30+5] / aux;
|
|
558
|
cross_im = compressed_spectral_matrix_f0[i*30+4] / 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
|
|
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
|
|
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
|
|
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
|
|
493
|
printf("LFR_BP2_F0[i*30+18] for cross13_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+18]);
|
|
561
|
#ifdef DEBUG_TCH
|
|
494
|
printf("LFR_BP2_F0[i*30+8] for cross13_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+8]);
|
|
562
|
printf("LFR_BP2_F0[i*30+11] for cross13_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+11]);
|
|
495
|
|
|
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
|
// S14
|
|
565
|
// S14
|
|
497
|
aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+24]);
|
|
566
|
aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+21]);
|
|
498
|
cross_re = compressed_spectral_matrix_f0[i*30+6] / aux;
|
|
567
|
cross_re = compressed_spectral_matrix_f0[i*30+5] / aux;
|
|
499
|
cross_im = compressed_spectral_matrix_f0[i*30+7] / aux;
|
|
568
|
cross_im = compressed_spectral_matrix_f0[i*30+6] / 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
|
|
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
|
|
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
|
|
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
|
|
502
|
printf("LFR_BP2_F0[i*30+17] for cross14_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+17]);
|
|
571
|
#ifdef DEBUG_TCH
|
|
503
|
printf("LFR_BP2_F0[i*30+7] for cross14_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+7]);
|
|
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
|
// S15
|
|
575
|
// S15
|
|
505
|
aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+28]);
|
|
576
|
aux = sqrt(compressed_spectral_matrix_f0[i*30]*compressed_spectral_matrix_f0[i*30+24]);
|
|
506
|
cross_re = compressed_spectral_matrix_f0[i*30+8] / aux;
|
|
577
|
cross_re = compressed_spectral_matrix_f0[i*30+7] / aux;
|
|
507
|
cross_im = compressed_spectral_matrix_f0[i*30+9] / aux;
|
|
578
|
cross_im = compressed_spectral_matrix_f0[i*30+8] / 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
|
|
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
|
|
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
|
|
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
|
|
510
|
printf("LFR_BP2_F0[i*30+16] for cross15_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+16]);
|
|
581
|
#ifdef DEBUG_TCH
|
|
511
|
printf("LFR_BP2_F0[i*30+6] for cross15_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+6]);
|
|
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
|
// S23
|
|
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
|
cross_re = compressed_spectral_matrix_f0[i*30+12] / aux;
|
|
597
|
cross_re = compressed_spectral_matrix_f0[i*30+12] / aux;
|
|
515
|
cross_im = compressed_spectral_matrix_f0[i*30+13] / aux;
|
|
598
|
cross_im = compressed_spectral_matrix_f0[i*30+13] / aux;
|
|
516
|
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
|
|
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
|
|
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
|
|
518
|
printf("LFR_BP2_F0[i*30+15] for cross23_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+15]);
|
|
601
|
#ifdef DEBUG_TCH
|
|
519
|
printf("LFR_BP2_F0[i*30+5] for cross23_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+5]);
|
|
602
|
printf("LFR_BP2_F0[i*30+15] for cross24_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+15]);
|
|
520
|
// S24
|
|
603
|
printf("LFR_BP2_F0[i*30+25] for cross24_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+25]);
|
|
521
|
aux = sqrt(compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+24]);
|
|
604
|
#endif
|
|
|
|
|
605
|
// S25
|
|
|
|
|
606
|
aux = sqrt(compressed_spectral_matrix_f0[i*30+9]*compressed_spectral_matrix_f0[i*30+24]);
|
|
522
|
cross_re = compressed_spectral_matrix_f0[i*30+14] / aux;
|
|
607
|
cross_re = compressed_spectral_matrix_f0[i*30+14] / aux;
|
|
523
|
cross_im = compressed_spectral_matrix_f0[i*30+15] / aux;
|
|
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
|
|
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
|
|
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
|
|
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
|
|
526
|
printf("LFR_BP2_F0[i*30+14] for cross24_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+14]);
|
|
611
|
#ifdef DEBUG_TCH
|
|
527
|
printf("LFR_BP2_F0[i*30+4] for cross24_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+4]);
|
|
612
|
printf("LFR_BP2_F0[i*30+16] for cross25_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+16]);
|
|
528
|
// S25
|
|
613
|
printf("LFR_BP2_F0[i*30+26] for cross25_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+26]);
|
|
529
|
aux = sqrt(compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+28]);
|
|
614
|
#endif
|
|
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]);
|
|
|
|
|
536
|
// S34
|
|
615
|
// S34
|
|
537
|
aux = sqrt(compressed_spectral_matrix_f0[i*30+18]*compressed_spectral_matrix_f0[i*30+24]);
|
|
616
|
aux = sqrt(compressed_spectral_matrix_f0[i*30+16]*compressed_spectral_matrix_f0[i*30+21]);
|
|
538
|
cross_re = compressed_spectral_matrix_f0[i*30+20] / aux;
|
|
617
|
cross_re = compressed_spectral_matrix_f0[i*30+17] / aux;
|
|
539
|
cross_im = compressed_spectral_matrix_f0[i*30+21] / aux;
|
|
618
|
cross_im = compressed_spectral_matrix_f0[i*30+18] / 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
|
|
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
|
|
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
|
|
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
|
|
542
|
printf("LFR_BP2_F0[i*30+12] for cross34_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+12]);
|
|
621
|
#ifdef DEBUG_TCH
|
|
543
|
printf("LFR_BP2_F0[i*30+2] for cross34_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+2]);
|
|
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
|
// S35
|
|
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
|
cross_re = compressed_spectral_matrix_f0[i*30+22] / aux;
|
|
637
|
cross_re = compressed_spectral_matrix_f0[i*30+22] / aux;
|
|
547
|
cross_im = compressed_spectral_matrix_f0[i*30+23] / aux;
|
|
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
|
|
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
|
|
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
|
|
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
|
|
550
|
printf("LFR_BP2_F0[i*30+11] for cross35_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+11]);
|
|
641
|
#ifdef DEBUG_TCH
|
|
551
|
printf("LFR_BP2_F0[i*30+1] for cross35_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+1]);
|
|
642
|
printf("LFR_BP2_F0[i*30+19] for cross45_re (%16.8e) : %.3u\n",cross_re, LFR_BP2_F0[i*30+19]);
|
|
552
|
// S45
|
|
643
|
printf("LFR_BP2_F0[i*30+29] for cross45_im (%16.8e) : %.3u\n",cross_im, LFR_BP2_F0[i*30+29]);
|
|
553
|
aux = sqrt(compressed_spectral_matrix_f0[i*30+24]*compressed_spectral_matrix_f0[i*30+28]);
|
|
644
|
#endif
|
|
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
|
|
|
|
|
|
561
|
//==============================================
|
|
645
|
//==============================================
|
|
562
|
// BP2 auto correlations == PA_LFR_SC_BP2_AUTO_F0 == 5*16 bits = 5*[6 bits (exponent) + 10 bits (significand)]
|
|
646
|
// BP2 auto correlations == PA_LFR_SC_BP2_AUTO_F0 == 5*16 bits = 5*[6 bits (exponent) + 10 bits (significand)]
|
|
563
|
// == PA_LFR_SC_BP2_AUTO_A0_F0 == 16 bits
|
|
647
|
// == PA_LFR_SC_BP2_AUTO_A0_F0 == 16 bits
|
|
@@
-568,9
+652,122
void BP2_set(){
|
|
568
|
// S11
|
|
652
|
// S11
|
|
569
|
significand = frexpf(compressed_spectral_matrix_f0[i*30], &exponent); // 0.5 <= significand < 1
|
|
653
|
significand = frexpf(compressed_spectral_matrix_f0[i*30], &exponent); // 0.5 <= significand < 1
|
|
570
|
// S11 = significand * 2^exponent
|
|
654
|
// S11 = significand * 2^exponent
|
|
|
|
|
655
|
#ifdef DEBUG_TCH
|
|
571
|
printf("S11 : %16.8e\n",compressed_spectral_matrix_f0[i*30]);
|
|
656
|
printf("S11 : %16.8e\n",compressed_spectral_matrix_f0[i*30]);
|
|
572
|
printf("significand : %16.8e\n",significand);
|
|
657
|
printf("significand : %16.8e\n",significand);
|
|
573
|
printf("exponent : %d\n" ,exponent);
|
|
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
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
772
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
576
|
exponent = expmin;
|
|
773
|
exponent = expmin;
|
|
@@
-585,63
+782,30
void BP2_set(){
|
|
585
|
significand = 0.5; // min value that can be recorded
|
|
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
|
// where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
|
|
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
|
// where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
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
|
|
789
|
pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+6]; // Affect an unsigned short int pointer with the
|
|
593
|
// adress where the 16-bit word result will be stored
|
|
790
|
// 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
|
|
791
|
*pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
595
|
// left place of the significand bits (nbitsig), making
|
|
792
|
// left place of the significand bits (nbitsig), making
|
|
596
|
// the 16-bit word to be recorded, and record it using the pointer
|
|
793
|
// the 16-bit word to be recorded, and record it using the pointer
|
|
597
|
//printf("size of autocor : %d\n",sizeof(autocor) );
|
|
794
|
#ifdef DEBUG_TCH
|
|
598
|
//printf("size of tmp_u_short_int : %d\n",sizeof(tmp_u_short_int) );
|
|
795
|
printf("autocor for S44 significand : %d\n",autocor );
|
|
599
|
printf("autocor for S11 significand : %u\n",autocor );
|
|
796
|
printf("tmp_u_char for S44 exponent : %d\n",tmp_u_short_int );
|
|
600
|
printf("tmp_u_char for S11 exponent : %u\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);
|
|
601
|
printf("*pt_u_short_int for S11 significand + exponent: %u 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]);
|
|
602
|
printf("LFR_BP2_F0[i*30+29] : %u or %x\n",LFR_BP2_F0[i*30+29], LFR_BP2_F0[i*30+29]);
|
|
799
|
printf("LFR_BP2_F0[i*30+6] : %.3d or %x\n",LFR_BP2_F0[i*30+6], LFR_BP2_F0[i*30+6]);
|
|
603
|
printf("LFR_BP2_F0[i*30+28] : %u or %x\n",LFR_BP2_F0[i*30+28], LFR_BP2_F0[i*30+28]);
|
|
800
|
#endif
|
|
604
|
// S22
|
|
801
|
// S55
|
|
605
|
significand = frexpf(compressed_spectral_matrix_f0[i*30+10], &exponent); // 0.5 <= significand < 1
|
|
802
|
significand = frexpf(compressed_spectral_matrix_f0[i*30+24], &exponent); // 0.5 <= significand < 1
|
|
606
|
// S22 = significand * 2^exponent
|
|
803
|
// S55 = significand * 2^exponent
|
|
607
|
printf("S22 : %16.8e\n",compressed_spectral_matrix_f0[i*30+10]);
|
|
804
|
#ifdef DEBUG_TCH
|
|
|
|
|
805
|
printf("S55 : %16.8e\n",compressed_spectral_matrix_f0[i*30+24]);
|
|
608
|
printf("significand : %16.8e\n",significand);
|
|
806
|
printf("significand : %16.8e\n",significand);
|
|
609
|
printf("exponent : %d\n" ,exponent);
|
|
807
|
printf("exponent : %d\n" ,exponent);
|
|
610
|
|
|
808
|
#endif
|
|
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
|
|
|
|
|
|
645
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
809
|
if (exponent < expmin) { // value should be >= 0.5 * 2^expmin
|
|
646
|
exponent = expmin;
|
|
810
|
exponent = expmin;
|
|
647
|
significand = 0.5; // min value that can be recorded
|
|
811
|
significand = 0.5; // min value that can be recorded
|
|
@@
-655,89
+819,22
void BP2_set(){
|
|
655
|
significand = 0.5; // min value that can be recorded
|
|
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
|
|
822
|
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)
|
|
823
|
// 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
|
|
824
|
tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
|
|
661
|
// where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
|
|
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
|
|
826
|
pt_u_short_int = (unsigned short int*) &LFR_BP2_F0[i*30+8]; // Affect an unsigned short int pointer with the
|
|
663
|
// adress where the 16-bit word result will be stored
|
|
827
|
// 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
|
|
828
|
*pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the
|
|
665
|
// left place of the significand bits (nbitsig), making
|
|
829
|
// left place of the significand bits (nbitsig), making
|
|
666
|
// the 16-bit word to be recorded, and record it using the pointer
|
|
830
|
// the 16-bit word to be recorded, and record it using the pointer
|
|
667
|
printf("autocor for S33 significand : %d\n",autocor );
|
|
831
|
#ifdef DEBUG_TCH
|
|
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
|
|
|
|
|
735
|
printf("autocor for S55 significand : %d\n",autocor );
|
|
832
|
printf("autocor for S55 significand : %d\n",autocor );
|
|
736
|
printf("tmp_u_char for S55 exponent : %d\n",tmp_u_short_int );
|
|
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);
|
|
834
|
printf("*pt_u_short_int for S55 exponent + significand : %.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]);
|
|
835
|
printf("LFR_BP2_F0[i*30+9] : %.3d or %x\n",LFR_BP2_F0[i*30+9], LFR_BP2_F0[i*30+9]);
|
|
739
|
printf("LFR_BP2_F0[i*30+20] : %.3d or %x\n",LFR_BP2_F0[i*30+20], LFR_BP2_F0[i*30+20]);
|
|
836
|
printf("LFR_BP2_F0[i*30+8] : %.3d or %x\n",LFR_BP2_F0[i*30+8], LFR_BP2_F0[i*30+8]);
|
|
740
|
|
|
837
|
#endif
|
|
741
|
}
|
|
838
|
}
|
|
742
|
}
|
|
839
|
}
|
|
743
|
|
|
840
|
|