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