##// END OF EJS Templates
version 1.2 qui règle le problème d'alignement mémoire pour BP1 (pour BP2 plus tard ...)
chust -
r6:be100cfb14bd default
parent child
Show More
@@ -0,0 +1,18
1 TEMPLATE = app
2 CONFIG += console
3 CONFIG -= app_bundle
4 CONFIG -= qt
5
6 DEFINES += DEBUG_TCH
7 #DEFINES += MSB_FIRST_TCH # SPARC convention
8 DEFINES += LSB_FIRST_TCH # PC convention
9
10 SOURCES += main.c \
11 basic_parameters.c \
12 file_utilities.c
13
14 HEADERS += \
15 basic_parameters.h \
16 file_utilities.h
17
18
@@ -1,10 +1,12
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.0: 31/07/2013
2 // version 1.0: 31/07/2013
3 // version 1.1: 02/04/2014
3 // version 1.1: 02/04/2014
4 // version 1.2: 30/04/2014
4
5
5 #include "basic_parameters.h"
6 #include "basic_parameters.h"
6 #include <math.h>
7 #include <math.h>
7 #include <stdio.h>
8 #include <stdio.h>
9 #include <stdint.h>
8
10
9 #define K44_PE 0
11 #define K44_PE 0
10 #define K55_PE 1
12 #define K55_PE 1
@@ -46,7 +48,7 float k_f0[NB_BINS_COMPRESSED_MATRIX_f0]
46
48
47 void init_k_f0( void )
49 void init_k_f0( void )
48 {
50 {
49 unsigned char i;
51 uint16_t i; // 16 bits unsigned
50
52
51 for(i=0; i<NB_BINS_COMPRESSED_MATRIX_f0; i++){
53 for(i=0; i<NB_BINS_COMPRESSED_MATRIX_f0; i++){
52 k_f0[i][K44_PE] = 1;
54 k_f0[i][K44_PE] = 1;
@@ -89,9 +91,9 void init_k_f0( void )
89
91
90 float alpha_M = 45 * (3.1415927/180);
92 float alpha_M = 45 * (3.1415927/180);
91
93
92 void BP1_set( float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp1 ){
94 void BP1_set( float * compressed_spec_mat, uint8_t nb_bins_compressed_spec_mat, uint8_t * lfr_bp1 ){
93 int i, exponent;
95 int exponent; // 32 bits signed
94 float PSDB;
96 float PSDB; // 32 bits floating point
95 float PSDE;
97 float PSDE;
96 float tmp;
98 float tmp;
97 float NVEC_V0;
99 float NVEC_V0;
@@ -108,16 +110,17 void BP1_set( float * compressed_spec_ma
108 float bx_bx_star;
110 float bx_bx_star;
109 float vphi;
111 float vphi;
110 float significand;
112 float significand;
111 signed char nbitexp;
113 uint8_t nbitexp; // 8 bits unsigned
112 signed char nbitsig;
114 uint8_t nbitsig;
113 signed char expmin;
115 uint8_t tmp_uint8;
114 signed char expmax; // 8 bits
116 uint8_t *pt_uint8; // pointer on unsigned 8-bit bytes
115 short int rangesig; // 16 bits
117 int8_t expmin; // 8 bits signed
116 unsigned short int psd;
118 int8_t expmax;
117 unsigned short int tmp_u_short_int; // 16 bits
119 int16_t rangesig; // 16 bits unsigned
118 unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words
120 uint16_t psd;
119 unsigned char tmp_u_char; // 8 bits
121 uint16_t exp;
120 unsigned char *pt_u_char; // pointer on unsigned 8-bit bytes
122 uint16_t tmp_uint16;
123 uint16_t i;
121
124
122 init_k_f0();
125 init_k_f0();
123
126
@@ -131,7 +134,7 void BP1_set( float * compressed_spec_ma
131 expmax = 30; // maximum value of the exponent
134 expmax = 30; // maximum value of the exponent
132 expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value
135 expmin = expmax - (1 << nbitexp) + 1; // accordingly the minimum exponent value
133 // for floating point data to be recorded on 12-bit words:
136 // for floating point data to be recorded on 12-bit words:
134 nbitsig = 12 - nbitexp; // number of bits for the significand
137 nbitsig = 12 - nbitexp; // number of bits for the significand
135 rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
138 rangesig = (1 << nbitsig)-1; // == 2^nbitsig - 1
136
139
137 #ifdef DEBUG_TCH
140 #ifdef DEBUG_TCH
@@ -163,23 +166,31 void BP1_set( float * compressed_spec_ma
163 significand = 0.5; // min value that can be recorded
166 significand = 0.5; // min value that can be recorded
164 }
167 }
165
168
166 psd = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
169 psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
167 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
170 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
168 tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
171 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
169 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
172 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
170 pt_u_short_int = (unsigned short int*) &lfr_bp1[i*NB_BYTES_BP1+2]; // Affect an unsigned short int pointer with the
173 tmp_uint16 = psd | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
171 // adress where the 16-bit word result will be stored
174 // left place of the significand bits (nbitsig),
172 *pt_u_short_int = psd | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the
175 // making the 16-bit word to be recorded
173 // left place of the significand bits (nbitsig), making
176 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
174 // the 16-bit word to be recorded, and record it using the pointer
177 #ifdef LSB_FIRST_TCH
178 lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[0]; // Record LSB of tmp_uint16
179 lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[1]; // Record MSB of tmp_uint16
180 #endif
181 #ifdef MSB_FIRST_TCH
182 lfr_bp1[i*NB_BYTES_BP1+2] = pt_uint8[1]; // Record LSB of tmp_uint16
183 lfr_bp1[i*NB_BYTES_BP1+3] = pt_uint8[0]; // Record MSB of tmp_uint16
184 #endif
175 #ifdef DEBUG_TCH
185 #ifdef DEBUG_TCH
176 printf("\nBin number: %d\n", i);
186 printf("\nBin number: %d\n", i);
177 printf("PSDB / 3 : %16.8e\n",PSDB/3);
187 printf("PSDB / 3 : %16.8e\n",PSDB/3);
178 printf("significand : %16.8e\n",significand);
188 printf("significand : %16.8e\n",significand);
179 printf("exponent : %d\n" ,exponent);
189 printf("exponent : %d\n" ,exponent);
180 printf("psd for PSDB significand : %d\n",psd);
190 printf("psd for PSDB significand : %d\n",psd);
181 printf("tmp_u_short_int for PSDB exponent : %d\n",tmp_u_short_int);
191 printf("exp for PSDB exponent : %d\n",exp);
182 printf("*pt_u_short_int for PSDB exponent + significand: %.3d or %.4x\n",*pt_u_short_int, *pt_u_short_int);
192 printf("pt_uint8[1] for PSDB exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]);
193 printf("pt_uint8[0] for PSDB exponent + significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]);
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]);
194 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]);
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]);
195 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]);
185 #endif
196 #endif
@@ -208,22 +219,31 void BP1_set( float * compressed_spec_ma
208 significand = 0.5; // min value that can be recorded
219 significand = 0.5; // min value that can be recorded
209 }
220 }
210
221
211 psd = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
222 psd = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
212 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
223 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
213 tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
224 exp = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int where just
214 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
225 // the first nbitexp bits are used (0, ..., 2^nbitexp-1)
215 pt_u_short_int = (unsigned short int*) &lfr_bp1[i*NB_BYTES_BP1+0]; // Affect an unsigned short int pointer with the
226 tmp_uint16 = psd | (exp << nbitsig); // Put the exponent bits (nbitexp) next to the
216 // adress where the 16-bit word result will be stored
227 // left place of the significand bits (nbitsig),
217 *pt_u_short_int = psd | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the
228 // making the 16-bit word to be recorded
218 // left place of the significand bits (nbitsig), making
229 pt_uint8 = (uint8_t*) &tmp_uint16; // Affect an uint8_t pointer with the adress of tmp_uint16
219 // the 16-bit word to be recorded, and record it using the pointer
230 #ifdef LSB_FIRST_TCH
231 lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[0]; // Record LSB of tmp_uint16
232 lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[1]; // Record MSB of tmp_uint16
233 #endif
234 #ifdef MSB_FIRST_TCH
235 lfr_bp1[i*NB_BYTES_BP1+0] = pt_uint8[1]; // Record LSB of tmp_uint16
236 lfr_bp1[i*NB_BYTES_BP1+1] = pt_uint8[0]; // Record MSB of tmp_uint16
237 #endif
220 #ifdef DEBUG_TCH
238 #ifdef DEBUG_TCH
221 printf("PSDE / 2 : %16.8e\n",PSDE/2);
239 printf("Bin number: %d\n", i);
240 printf("PSDE/2 : %16.8e\n",PSDE/2);
222 printf("significand : %16.8e\n",significand);
241 printf("significand : %16.8e\n",significand);
223 printf("exponent : %d\n" ,exponent);
242 printf("exponent : %d\n" ,exponent);
224 printf("psd for PSDE significand : %d\n",psd);
243 printf("psd for PSDE significand : %d\n",psd);
225 printf("tmp_u_short_int for PSDE exponent : %d\n",tmp_u_short_int);
244 printf("exp for PSDE exponent : %d\n",exp);
226 printf("*pt_u_short_int for PSDE exponent + significand: %.3d or %.4x\n",*pt_u_short_int, *pt_u_short_int);
245 printf("pt_uint8[1] for PSDE exponent + significand: %.3d or %.2x\n",pt_uint8[1], pt_uint8[1]);
246 printf("pt_uint8[0] for PSDE exponent + significand: %.3d or %.2x\n",pt_uint8[0], pt_uint8[0]);
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]);
247 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]);
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]);
248 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]);
229 #endif
249 #endif
@@ -239,15 +259,15 void BP1_set( float * compressed_spec_ma
239 NVEC_V1 = -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / tmp; // S13 Im => n2
259 NVEC_V1 = -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / tmp; // S13 Im => n2
240 NVEC_V2 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / tmp; // S12 Im => n3
260 NVEC_V2 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / tmp; // S12 Im => n3
241
261
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
262 lfr_bp1[i*NB_BYTES_BP1+4] = (uint8_t) (NVEC_V0*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
263 lfr_bp1[i*NB_BYTES_BP1+5] = (uint8_t) (NVEC_V1*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
244 pt_u_char = (unsigned char*) &NVEC_V2; // affect an unsigned char pointer with the adress of NVEC_V2
264 pt_uint8 = (uint8_t*) &NVEC_V2; // affect an uint8_t pointer with the adress of NVEC_V2
245 #ifdef LSB_FIRST_TCH
265 #ifdef LSB_FIRST_TCH
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)
266 lfr_bp1[i*NB_BYTES_BP1+6] = pt_uint8[3] & 0x80; // extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 4th octet:PC convention)
247 // record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
267 // record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
248 #endif
268 #endif
249 #ifdef MSB_FIRST_TCH
269 #ifdef MSB_FIRST_TCH
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)
270 lfr_bp1[i*NB_BYTES_BP1+6] = pt_uint8[0] & 0x80; // extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 0th octet:SPARC convention)
251 // record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
271 // record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
252 #endif
272 #endif
253 #ifdef DEBUG_TCH
273 #ifdef DEBUG_TCH
@@ -262,14 +282,14 void BP1_set( float * compressed_spec_ma
262 // BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits
282 // BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits
263 aux = 2*tmp / PSDB; // compute the ellipticity
283 aux = 2*tmp / PSDB; // compute the ellipticity
264
284
265 tmp_u_char = (unsigned char) (aux*15 + 0.5); // shift and cast into a 8-bit unsigned char with rounding
285 tmp_uint8 = (uint8_t) (aux*15 + 0.5); // shift and cast into a 8-bit uint8_t with rounding
266 // where just the first 4 bits are used (0, ..., 15)
286 // where just the first 4 bits are used (0, ..., 15)
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
287 lfr_bp1[i*NB_BYTES_BP1+6] = lfr_bp1[i*NB_BYTES_BP1+6] | (tmp_uint8 << 3); // put these 4 bits next to the right place
268 // of the sign bit of NVEC_V2 (recorded
288 // of the sign bit of NVEC_V2 (recorded
269 // previously in lfr_bp1[i*NB_BYTES_BP1+6])
289 // previously in lfr_bp1[i*NB_BYTES_BP1+6])
270 #ifdef DEBUG_TCH
290 #ifdef DEBUG_TCH
271 printf("ellipticity : %16.8e\n",aux);
291 printf("ellipticity : %16.8e\n",aux);
272 printf("tmp_u_char for ellipticity : %u\n",tmp_u_char);
292 printf("tmp_uint8 for ellipticity : %u\n",tmp_uint8);
273 printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
293 printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
274 #endif
294 #endif
275 //==============================================================
295 //==============================================================
@@ -286,13 +306,13 void BP1_set( float * compressed_spec_ma
286 aux = PSDB*PSDB;
306 aux = PSDB*PSDB;
287 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // compute the degree of polarisation
307 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // compute the degree of polarisation
288
308
289 tmp_u_char = (unsigned char) (tmp*7 + 0.5);// shift and cast into a 8-bit unsigned char with rounding
309 tmp_uint8 = (uint8_t) (tmp*7 + 0.5);// shift and cast into a 8-bit uint8_t with rounding
290 // where just the first 3 bits are used (0, ..., 7)
310 // where just the first 3 bits are used (0, ..., 7)
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
311 lfr_bp1[i*NB_BYTES_BP1+6] = lfr_bp1[i*NB_BYTES_BP1+6] | tmp_uint8; // record these 3 bits at the 3 first bit positions
292 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
312 // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6]
293 #ifdef DEBUG_TCH
313 #ifdef DEBUG_TCH
294 printf("DOP : %16.8e\n",tmp);
314 printf("DOP : %16.8e\n",tmp);
295 printf("tmp_u_char for DOP : %u\n",tmp_u_char);
315 printf("tmp_uint8 for DOP : %u\n",tmp_uint8);
296 printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity + DOP : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
316 printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity + DOP : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]);
297 #endif
317 #endif
298 //=======================================================================================
318 //=======================================================================================
@@ -328,18 +348,18 void BP1_set( float * compressed_spec_ma
328 #ifdef DEBUG_TCH
348 #ifdef DEBUG_TCH
329 printf("ReaSX / 2 : %16.8e\n",e_cross_b_re/2);
349 printf("ReaSX / 2 : %16.8e\n",e_cross_b_re/2);
330 #endif
350 #endif
331 pt_u_char = (unsigned char*) &e_cross_b_re; // Affect an unsigned char pointer with the adress of e_cross_b_re
351 pt_uint8 = (uint8_t*) &e_cross_b_re; // Affect an uint8_t pointer with the adress of e_cross_b_re
332 #ifdef LSB_FIRST_TCH
352 #ifdef LSB_FIRST_TCH
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)
353 lfr_bp1[i*NB_BYTES_BP1+1] = lfr_bp1[i*NB_BYTES_BP1+1] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
334 // Record it at the 8th bit position (from the right to the left)
354 // Record it at the 8th bit position (from the right to the left)
335 // of lfr_bp1[i*NB_BYTES_BP1+1]
355 // of lfr_bp1[i*NB_BYTES_BP1+1]
336 pt_u_char[3] = (pt_u_char[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
356 pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
337 #endif
357 #endif
338 #ifdef MSB_FIRST_TCH
358 #ifdef MSB_FIRST_TCH
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)
359 lfr_bp1[i*NB_BYTES_BP1+1] = lfr_bp1[i*NB_BYTES_BP1+1] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 0th octet:SPARC convention)
340 // Record it at the 8th bit position (from the right to the left)
360 // Record it at the 8th bit position (from the right to the left)
341 // of lfr_bp1[i*NB_BYTES_BP1+1]
361 // of lfr_bp1[i*NB_BYTES_BP1+1]
342 pt_u_char[0] = (pt_u_char[0] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
362 pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX|
343 #endif
363 #endif
344 significand = frexpf(e_cross_b_re/2, &exponent);// 0.5 <= significand < 1
364 significand = frexpf(e_cross_b_re/2, &exponent);// 0.5 <= significand < 1
345 // ReaSX/2 = significand * 2^exponent
365 // ReaSX/2 = significand * 2^exponent
@@ -359,38 +379,38 void BP1_set( float * compressed_spec_ma
359 significand = 0.5; // min value that can be recorded
379 significand = 0.5; // min value that can be recorded
360 }
380 }
361
381
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
382 lfr_bp1[i*NB_BYTES_BP1+7] = (uint8_t) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
363 // where just the first 3 bits are used (0, ..., 7)
383 // where just the first 3 bits are used (0, ..., 7)
364 tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where
384 tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
365 // just the first 5 bits are used (0, ..., 2^5-1)
385 // just the first 5 bits are used (0, ..., 2^5-1)
366 #ifdef DEBUG_TCH
386 #ifdef DEBUG_TCH
367 printf("|ReaSX| / 2 : %16.8e\n",e_cross_b_re/2);
387 printf("|ReaSX| / 2 : %16.8e\n",e_cross_b_re/2);
368 printf("significand : %16.8e\n",significand);
388 printf("significand : %16.8e\n",significand);
369 printf("exponent : %d\n" ,exponent);
389 printf("exponent : %d\n" ,exponent);
370 printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
390 printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
371 printf("tmp_u_char for ReaSX exponent : %d\n",tmp_u_char);
391 printf("tmp_uint8 for ReaSX exponent : %d\n",tmp_uint8);
372 #endif
392 #endif
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
393 lfr_bp1[i*NB_BYTES_BP1+7] = lfr_bp1[i*NB_BYTES_BP1+7] | (tmp_uint8 << 3); // shift these 5 bits to the left before logical addition
374 // with lfr_bp1[i*NB_BYTES_BP1+7]
394 // with lfr_bp1[i*NB_BYTES_BP1+7]
375 #ifdef DEBUG_TCH
395 #ifdef DEBUG_TCH
376 printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX exponent + significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
396 printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX exponent + significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]);
377 printf("lfr_bp1[i*NB_BYTES_BP1+1] for ReaSX sign + PSDE 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+1]);
397 printf("lfr_bp1[i*NB_BYTES_BP1+1] for ReaSX sign + PSDE 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+1]);
378 printf("ImaSX / 2 : %16.8e\n",e_cross_b_im/2);
398 printf("ImaSX / 2 : %16.8e\n",e_cross_b_im/2);
379 #endif
399 #endif
380 pt_u_char = (unsigned char*) &e_cross_b_im; // Affect an unsigned char pointer with the adress of e_cross_b_im
400 pt_uint8 = (uint8_t*) &e_cross_b_im; // Affect an uint8_t pointer with the adress of e_cross_b_im
381 #ifdef LSB_FIRST_TCH
401 #ifdef LSB_FIRST_TCH
382 pt_u_char[3] = pt_u_char[3] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX|
402 pt_uint8[3] = pt_uint8[3] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX|
383 #endif
403 #endif
384 #ifdef MSB_FIRST_TCH
404 #ifdef MSB_FIRST_TCH
385 pt_u_char[0] = pt_u_char[0] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX|
405 pt_uint8[0] = pt_uint8[0] & 0x7f; // Make e_cross_b_im be positive in any case: |ImaSX|
386 #endif
406 #endif
387 tmp_u_char = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect
407 tmp_uint8 = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect
388 // an unsigned 8-bit char with 01000000; otherwise with null.
408 // an unsigned 8-bit char with 01000000; otherwise with null.
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
409 lfr_bp1[i*NB_BYTES_BP1+1] = lfr_bp1[i*NB_BYTES_BP1+1] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right
390 // to the left) of lfr_bp1[i*NB_BYTES_BP1+1], by simple logical addition.
410 // to the left) of lfr_bp1[i*NB_BYTES_BP1+1], by simple logical addition.
391 #ifdef DEBUG_TCH
411 #ifdef DEBUG_TCH
392 printf("|ImaSX| / 2 : %16.8e\n",e_cross_b_im/2);
412 printf("|ImaSX| / 2 : %16.8e\n",e_cross_b_im/2);
393 printf("ArgSX sign : %u\n",tmp_u_char);
413 printf("ArgSX sign : %u\n",tmp_uint8);
394 printf("lfr_bp1[i*NB_BYTES_BP1+1] for ReaSX & ArgSX signs + PSDE 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+1]);
414 printf("lfr_bp1[i*NB_BYTES_BP1+1] for ReaSX & ArgSX signs + PSDE 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+1]);
395 #endif
415 #endif
396 //======================================================================
416 //======================================================================
@@ -442,18 +462,18 void BP1_set( float * compressed_spec_ma
442 printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im);
462 printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im);
443 #endif
463 #endif
444 // vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re)
464 // vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(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
465 pt_uint8 = (uint8_t*) &n_cross_e_scal_b_re; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_re
446 #ifdef LSB_FIRST_TCH
466 #ifdef LSB_FIRST_TCH
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)
467 lfr_bp1[i*NB_BYTES_BP1+3] = lfr_bp1[i*NB_BYTES_BP1+3] | (pt_uint8[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention)
448 // Record it at the 8th bit position (from the right to the left)
468 // Record it at the 8th bit position (from the right to the left)
449 // of lfr_bp1[i*NB_BYTES_BP1+3]
469 // of lfr_bp1[i*NB_BYTES_BP1+3]
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|
470 pt_uint8[3] = (pt_uint8[3] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re|
451 #endif
471 #endif
452 #ifdef MSB_FIRST_TCH
472 #ifdef MSB_FIRST_TCH
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)
473 lfr_bp1[i*NB_BYTES_BP1+3] = lfr_bp1[i*NB_BYTES_BP1+3] | (pt_uint8[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 0th octet:SPARC convention)
454 // Record it at the 8th bit position (from the right to the left)
474 // Record it at the 8th bit position (from the right to the left)
455 // of lfr_bp1[i*NB_BYTES_BP1+3]
475 // of lfr_bp1[i*NB_BYTES_BP1+3]
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|
476 pt_uint8[0] = (pt_uint8[0] & 0x7f); // Make n_cross_e_scal_b_re be positive in any case: |n_cross_e_scal_b_re|
457 #endif
477 #endif
458 vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI|
478 vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI|
459
479
@@ -479,48 +499,48 void BP1_set( float * compressed_spec_ma
479 printf("significand : %16.8e\n",significand);
499 printf("significand : %16.8e\n",significand);
480 printf("exponent : %d\n" ,exponent);
500 printf("exponent : %d\n" ,exponent);
481 #endif
501 #endif
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
502 lfr_bp1[i*NB_BYTES_BP1+8] = (uint8_t) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit uint8_t with rounding
483 // where just the first 3 bits are used (0, ..., 7)
503 // where just the first 3 bits are used (0, ..., 7)
484 tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where
504 tmp_uint8 = (uint8_t) (exponent-expmin); // Shift and cast into a 8-bit uint8_t where
485 // just the first 5 bits are used (0, ..., 2^5-1)
505 // just the first 5 bits are used (0, ..., 2^5-1)
486 #ifdef DEBUG_TCH
506 #ifdef DEBUG_TCH
487 printf("lfr_bp1[i*NB_BYTES_BP1+8] for VPHI significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]);
507 printf("lfr_bp1[i*NB_BYTES_BP1+8] for VPHI significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]);
488 printf("tmp_u_char for VPHI exponent : %d\n",tmp_u_char);
508 printf("tmp_uint8 for VPHI exponent : %d\n",tmp_uint8);
489 #endif
509 #endif
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
510 lfr_bp1[i*NB_BYTES_BP1+8] = lfr_bp1[i*NB_BYTES_BP1+8] | (tmp_uint8 << 3); // shift these 5 bits to the left before logical addition
491 // with lfr_bp1[i*NB_BYTES_BP1+8]
511 // with lfr_bp1[i*NB_BYTES_BP1+8]
492 #ifdef DEBUG_TCH
512 #ifdef DEBUG_TCH
493 printf("lfr_bp1[i*NB_BYTES_BP1+8] for VPHI exponent + significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]);
513 printf("lfr_bp1[i*NB_BYTES_BP1+8] for VPHI exponent + significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]);
494 printf("lfr_bp1[i*NB_BYTES_BP1+3] for VPHI sign + PSDB 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+3]);
514 printf("lfr_bp1[i*NB_BYTES_BP1+3] for VPHI sign + PSDB 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+3]);
495 #endif
515 #endif
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
516 pt_uint8 = (uint8_t*) &n_cross_e_scal_b_im; // Affect an uint8_t pointer with the adress of n_cross_e_scal_b_im
497 #ifdef LSB_FIRST_TCH
517 #ifdef LSB_FIRST_TCH
498 pt_u_char[3] = pt_u_char[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaSX|
518 pt_uint8[3] = pt_uint8[3] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaSX|
499 #endif
519 #endif
500 #ifdef MSB_FIRST_TCH
520 #ifdef MSB_FIRST_TCH
501 pt_u_char[0] = pt_u_char[0] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaSX|
521 pt_uint8[0] = pt_uint8[0] & 0x7f; // Make n_cross_e_scal_b_im be positive in any case: |ImaSX|
502 #endif
522 #endif
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
523 tmp_uint8 = (n_cross_e_scal_b_im > n_cross_e_scal_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect
504 // an unsigned 8-bit char with 01000000; otherwise with null.
524 // an unsigned 8-bit char with 01000000; otherwise with null.
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
525 lfr_bp1[i*NB_BYTES_BP1+3] = lfr_bp1[i*NB_BYTES_BP1+3] | tmp_uint8; // Record it as a sign bit at the 7th bit position (from the right
506 // to the left) of lfr_bp1[i*NB_BYTES_BP1+3], by simple logical addition.
526 // to the left) of lfr_bp1[i*NB_BYTES_BP1+3], by simple logical addition.
507 #ifdef DEBUG_TCH
527 #ifdef DEBUG_TCH
508 printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im);
528 printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im);
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);
529 printf("|n_cross_e_scal_b_im|/bx_bx_star/2: %16.8e\n",n_cross_e_scal_b_im/bx_bx_star/2);
510 printf("ArgNEBX sign : %u\n",tmp_u_char);
530 printf("ArgNEBX sign : %u\n",tmp_uint8);
511 printf("lfr_bp1[i*NB_BYTES_BP1+3] for VPHI & ArgNEBX signs + PSDB 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+3]);
531 printf("lfr_bp1[i*NB_BYTES_BP1+3] for VPHI & ArgNEBX signs + PSDB 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+3]);
512 #endif
532 #endif
513 }
533 }
514 }
534 }
515
535
516 void BP2_set( float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp2 )
536 void BP2_set( float * compressed_spec_mat, uint8_t nb_bins_compressed_spec_mat, uint8_t * lfr_bp2 )
517 {
537 {
518 int i, exponent;
538 int i, exponent;
519 float aux, significand, cross_re, cross_im;
539 float aux, significand, cross_re, cross_im;
520 signed char nbitexp, nbitsig, expmin, expmax; // 8 bits
540 int8_t nbitexp, nbitsig, expmin, expmax; // 8 bits
521 short int rangesig; // 16 bits
541 int16_t rangesig; // 16 bits
522 unsigned short int autocor, tmp_u_short_int; // 16 bits
542 uint16_t autocor, tmp_uint16; // 16 bits
523 unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words
543 uint16_t *pt_u_short_int; // pointer on unsigned 16-bit words
524
544
525 #ifdef DEBUG_TCH
545 #ifdef DEBUG_TCH
526 printf("BP2 : \n");
546 printf("BP2 : \n");
@@ -566,8 +586,8 void BP2_set( float * compressed_spec_ma
566 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
586 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]);
567 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] / aux;
587 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] / aux;
568 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / aux;
588 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / aux;
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
589 lfr_bp2[i*NB_BYTES_BP2+10] = (uint8_t) (cross_re*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
590 lfr_bp2[i*NB_BYTES_BP2+20] = (uint8_t) (cross_im*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
571 #ifdef DEBUG_TCH
591 #ifdef DEBUG_TCH
572 printf("\nBin number: %d\n", i);
592 printf("\nBin number: %d\n", i);
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]);
593 printf("lfr_bp2[i*NB_BYTES_BP2+10] for cross12_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+10]);
@@ -577,8 +597,8 void BP2_set( float * compressed_spec_ma
577 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
597 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
578 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] / aux;
598 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] / aux;
579 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / aux;
599 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / aux;
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
600 lfr_bp2[i*NB_BYTES_BP2+11] = (uint8_t) (cross_re*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
601 lfr_bp2[i*NB_BYTES_BP2+21] = (uint8_t) (cross_im*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
582 #ifdef DEBUG_TCH
602 #ifdef DEBUG_TCH
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]);
603 printf("lfr_bp2[i*NB_BYTES_BP2+11] for cross13_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+11]);
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]);
604 printf("lfr_bp2[i*NB_BYTES_BP2+21] for cross13_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+21]);
@@ -587,8 +607,8 void BP2_set( float * compressed_spec_ma
587 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
607 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
588 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] / aux;
608 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] / aux;
589 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] / aux;
609 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] / aux;
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
610 lfr_bp2[i*NB_BYTES_BP2+12] = (uint8_t) (cross_re*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
611 lfr_bp2[i*NB_BYTES_BP2+22] = (uint8_t) (cross_im*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
592 #ifdef DEBUG_TCH
612 #ifdef DEBUG_TCH
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]);
613 printf("lfr_bp2[i*NB_BYTES_BP2+12] for cross14_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+12]);
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]);
614 printf("lfr_bp2[i*NB_BYTES_BP2+22] for cross14_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+22]);
@@ -597,8 +617,8 void BP2_set( float * compressed_spec_ma
597 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
617 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
598 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] / aux;
618 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] / aux;
599 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] / aux;
619 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] / aux;
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
620 lfr_bp2[i*NB_BYTES_BP2+13] = (uint8_t) (cross_re*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
621 lfr_bp2[i*NB_BYTES_BP2+23] = (uint8_t) (cross_im*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
602 #ifdef DEBUG_TCH
622 #ifdef DEBUG_TCH
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]);
623 printf("lfr_bp2[i*NB_BYTES_BP2+13] for cross15_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+13]);
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]);
624 printf("lfr_bp2[i*NB_BYTES_BP2+23] for cross15_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+23]);
@@ -607,8 +627,8 void BP2_set( float * compressed_spec_ma
607 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
627 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]);
608 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10] / aux;
628 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10] / aux;
609 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] / aux;
629 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] / aux;
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
630 lfr_bp2[i*NB_BYTES_BP2+14] = (uint8_t) (cross_re*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
631 lfr_bp2[i*NB_BYTES_BP2+24] = (uint8_t) (cross_im*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
612 #ifdef DEBUG_TCH
632 #ifdef DEBUG_TCH
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]);
633 printf("lfr_bp2[i*NB_BYTES_BP2+14] for cross23_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+14]);
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]);
634 printf("lfr_bp2[i*NB_BYTES_BP2+24] for cross23_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+24]);
@@ -617,8 +637,8 void BP2_set( float * compressed_spec_ma
617 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
637 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
618 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12] / aux;
638 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12] / aux;
619 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13] / aux;
639 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13] / aux;
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
640 lfr_bp2[i*NB_BYTES_BP2+15] = (uint8_t) (cross_re*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
641 lfr_bp2[i*NB_BYTES_BP2+25] = (uint8_t) (cross_im*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
622 #ifdef DEBUG_TCH
642 #ifdef DEBUG_TCH
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]);
643 printf("lfr_bp2[i*NB_BYTES_BP2+15] for cross24_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+15]);
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]);
644 printf("lfr_bp2[i*NB_BYTES_BP2+25] for cross24_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+25]);
@@ -627,8 +647,8 void BP2_set( float * compressed_spec_ma
627 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
647 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
628 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14] / aux;
648 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14] / aux;
629 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15] / aux;
649 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15] / aux;
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
650 lfr_bp2[i*NB_BYTES_BP2+16] = (uint8_t) (cross_re*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
651 lfr_bp2[i*NB_BYTES_BP2+26] = (uint8_t) (cross_im*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
632 #ifdef DEBUG_TCH
652 #ifdef DEBUG_TCH
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]);
653 printf("lfr_bp2[i*NB_BYTES_BP2+16] for cross25_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+16]);
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]);
654 printf("lfr_bp2[i*NB_BYTES_BP2+26] for cross25_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+26]);
@@ -637,8 +657,8 void BP2_set( float * compressed_spec_ma
637 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
657 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]);
638 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17] / aux;
658 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17] / aux;
639 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18] / aux;
659 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18] / aux;
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
660 lfr_bp2[i*NB_BYTES_BP2+17] = (uint8_t) (cross_re*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
661 lfr_bp2[i*NB_BYTES_BP2+27] = (uint8_t) (cross_im*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
642 #ifdef DEBUG_TCH
662 #ifdef DEBUG_TCH
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]);
663 printf("lfr_bp2[i*NB_BYTES_BP2+17] for cross34_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+17]);
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]);
664 printf("lfr_bp2[i*NB_BYTES_BP2+27] for cross34_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+27]);
@@ -647,8 +667,8 void BP2_set( float * compressed_spec_ma
647 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
667 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
648 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19] / aux;
668 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19] / aux;
649 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20] / aux;
669 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20] / aux;
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
670 lfr_bp2[i*NB_BYTES_BP2+18] = (uint8_t) (cross_re*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
671 lfr_bp2[i*NB_BYTES_BP2+28] = (uint8_t) (cross_im*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
652 #ifdef DEBUG_TCH
672 #ifdef DEBUG_TCH
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]);
673 printf("lfr_bp2[i*NB_BYTES_BP2+18] for cross35_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+18]);
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]);
674 printf("lfr_bp2[i*NB_BYTES_BP2+28] for cross35_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+28]);
@@ -657,8 +677,8 void BP2_set( float * compressed_spec_ma
657 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
677 aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]);
658 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] / aux;
678 cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] / aux;
659 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] / aux;
679 cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] / aux;
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
680 lfr_bp2[i*NB_BYTES_BP2+19] = (uint8_t) (cross_re*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
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
681 lfr_bp2[i*NB_BYTES_BP2+29] = (uint8_t) (cross_im*127.5 + 128); // shift and cast into a 8-bit uint8_t (0, ..., 255) with rounding
662 #ifdef DEBUG_TCH
682 #ifdef DEBUG_TCH
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]);
683 printf("lfr_bp2[i*NB_BYTES_BP2+19] for cross45_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+19]);
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]);
684 printf("lfr_bp2[i*NB_BYTES_BP2+29] for cross45_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+29]);
@@ -691,18 +711,18 void BP2_set( float * compressed_spec_ma
691 significand = 0.5; // min value that can be recorded
711 significand = 0.5; // min value that can be recorded
692 }
712 }
693
713
694 autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
714 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
695 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
715 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
696 tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
716 tmp_uint16 = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
697 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
717 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
698 pt_u_short_int = (unsigned short int*) &lfr_bp2[i*NB_BYTES_BP2+0]; // Affect an unsigned short int pointer with the
718 pt_u_short_int = (uint16_t*) &lfr_bp2[i*NB_BYTES_BP2+0]; // Affect an uint16_t pointer with the
699 // adress where the 16-bit word result will be stored
719 // adress where the 16-bit word result will be stored
700 *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the
720 *pt_u_short_int = autocor | (tmp_uint16 << nbitsig); // Put the exponent bits (nbitexp) next to the
701 // left place of the significand bits (nbitsig), making
721 // left place of the significand bits (nbitsig), making
702 // the 16-bit word to be recorded, and record it using the pointer
722 // the 16-bit word to be recorded, and record it using the pointer
703 #ifdef DEBUG_TCH
723 #ifdef DEBUG_TCH
704 printf("autocor for S11 significand : %u\n",autocor );
724 printf("autocor for S11 significand : %u\n",autocor );
705 printf("tmp_u_char for S11 exponent : %u\n",tmp_u_short_int );
725 printf("tmp_uint8 for S11 exponent : %u\n",tmp_uint16 );
706 printf("*pt_u_short_int for S11 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int);
726 printf("*pt_u_short_int for S11 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int);
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]);
727 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]);
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]);
728 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]);
@@ -728,18 +748,18 void BP2_set( float * compressed_spec_ma
728 significand = 0.5; // min value that can be recorded
748 significand = 0.5; // min value that can be recorded
729 }
749 }
730
750
731 autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
751 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
732 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
752 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
733 tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
753 tmp_uint16 = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
734 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
754 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
735 pt_u_short_int = (unsigned short int*) &lfr_bp2[i*NB_BYTES_BP2+2]; // Affect an unsigned short int pointer with the
755 pt_u_short_int = (uint16_t*) &lfr_bp2[i*NB_BYTES_BP2+2]; // Affect an uint16_t pointer with the
736 // adress where the 16-bit word result will be stored
756 // adress where the 16-bit word result will be stored
737 *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the
757 *pt_u_short_int = autocor | (tmp_uint16 << nbitsig); // Put the exponent bits (nbitexp) next to the
738 // left place of the significand bits (nbitsig), making
758 // left place of the significand bits (nbitsig), making
739 // the 16-bit word to be recorded, and record it using the pointer
759 // the 16-bit word to be recorded, and record it using the pointer
740 #ifdef DEBUG_TCH
760 #ifdef DEBUG_TCH
741 printf("autocor for S22 significand : %d\n",autocor );
761 printf("autocor for S22 significand : %d\n",autocor );
742 printf("tmp_u_char for S22 exponent : %d\n",tmp_u_short_int );
762 printf("tmp_uint8 for S22 exponent : %d\n",tmp_uint16 );
743 printf("*pt_u_short_int for S22 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int);
763 printf("*pt_u_short_int for S22 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int);
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]);
764 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]);
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]);
765 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]);
@@ -765,18 +785,18 void BP2_set( float * compressed_spec_ma
765 significand = 0.5; // min value that can be recorded
785 significand = 0.5; // min value that can be recorded
766 }
786 }
767
787
768 autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
788 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
769 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
789 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
770 tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
790 tmp_uint16 = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
771 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
791 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
772 pt_u_short_int = (unsigned short int*) &lfr_bp2[i*NB_BYTES_BP2+4]; // Affect an unsigned short int pointer with the
792 pt_u_short_int = (uint16_t*) &lfr_bp2[i*NB_BYTES_BP2+4]; // Affect an uint16_t pointer with the
773 // adress where the 16-bit word result will be stored
793 // adress where the 16-bit word result will be stored
774 *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the
794 *pt_u_short_int = autocor | (tmp_uint16 << nbitsig); // Put the exponent bits (nbitexp) next to the
775 // left place of the significand bits (nbitsig), making
795 // left place of the significand bits (nbitsig), making
776 // the 16-bit word to be recorded, and record it using the pointer
796 // the 16-bit word to be recorded, and record it using the pointer
777 #ifdef DEBUG_TCH
797 #ifdef DEBUG_TCH
778 printf("autocor for S33 significand : %d\n",autocor );
798 printf("autocor for S33 significand : %d\n",autocor );
779 printf("tmp_u_char for S33 exponent : %d\n",tmp_u_short_int );
799 printf("tmp_uint8 for S33 exponent : %d\n",tmp_uint16 );
780 printf("*pt_u_short_int for S33 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int);
800 printf("*pt_u_short_int for S33 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int);
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]);
801 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]);
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]);
802 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]);
@@ -803,18 +823,18 void BP2_set( float * compressed_spec_ma
803 significand = 0.5; // min value that can be recorded
823 significand = 0.5; // min value that can be recorded
804 }
824 }
805
825
806 autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
826 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
807 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
827 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
808 tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
828 tmp_uint16 = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
809 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
829 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
810 pt_u_short_int = (unsigned short int*) &lfr_bp2[i*NB_BYTES_BP2+6]; // Affect an unsigned short int pointer with the
830 pt_u_short_int = (uint16_t*) &lfr_bp2[i*NB_BYTES_BP2+6]; // Affect an uint16_t pointer with the
811 // adress where the 16-bit word result will be stored
831 // adress where the 16-bit word result will be stored
812 *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the
832 *pt_u_short_int = autocor | (tmp_uint16 << nbitsig); // Put the exponent bits (nbitexp) next to the
813 // left place of the significand bits (nbitsig), making
833 // left place of the significand bits (nbitsig), making
814 // the 16-bit word to be recorded, and record it using the pointer
834 // the 16-bit word to be recorded, and record it using the pointer
815 #ifdef DEBUG_TCH
835 #ifdef DEBUG_TCH
816 printf("autocor for S44 significand : %d\n",autocor );
836 printf("autocor for S44 significand : %d\n",autocor );
817 printf("tmp_u_char for S44 exponent : %d\n",tmp_u_short_int );
837 printf("tmp_uint8 for S44 exponent : %d\n",tmp_uint16 );
818 printf("*pt_u_short_int for S44 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int);
838 printf("*pt_u_short_int for S44 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int);
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]);
839 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]);
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]);
840 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]);
@@ -840,18 +860,18 void BP2_set( float * compressed_spec_ma
840 significand = 0.5; // min value that can be recorded
860 significand = 0.5; // min value that can be recorded
841 }
861 }
842
862
843 autocor = (unsigned short int) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
863 autocor = (uint16_t) ((significand*2-1)*rangesig + 0.5); // Shift and cast into a 16-bit unsigned int with rounding
844 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
864 // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1)
845 tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
865 tmp_uint16 = (uint16_t) (exponent-expmin); // Shift and cast into a 16-bit unsigned int
846 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
866 // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1)
847 pt_u_short_int = (unsigned short int*) &lfr_bp2[i*NB_BYTES_BP2+8]; // Affect an unsigned short int pointer with the
867 pt_u_short_int = (uint16_t*) &lfr_bp2[i*NB_BYTES_BP2+8]; // Affect an uint16_t pointer with the
848 // adress where the 16-bit word result will be stored
868 // adress where the 16-bit word result will be stored
849 *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the
869 *pt_u_short_int = autocor | (tmp_uint16 << nbitsig); // Put the exponent bits (nbitexp) next to the
850 // left place of the significand bits (nbitsig), making
870 // left place of the significand bits (nbitsig), making
851 // the 16-bit word to be recorded, and record it using the pointer
871 // the 16-bit word to be recorded, and record it using the pointer
852 #ifdef DEBUG_TCH
872 #ifdef DEBUG_TCH
853 printf("autocor for S55 significand : %d\n",autocor );
873 printf("autocor for S55 significand : %d\n",autocor );
854 printf("tmp_u_char for S55 exponent : %d\n",tmp_u_short_int );
874 printf("tmp_uint8 for S55 exponent : %d\n",tmp_uint16 );
855 printf("*pt_u_short_int for S55 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int);
875 printf("*pt_u_short_int for S55 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int);
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]);
876 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]);
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]);
877 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]);
@@ -1,6 +1,7
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.0: 31/07/2013
2 // version 1.0: 31/07/2013
3 // version 1.1: 02/04/2014
3 // version 1.1: 02/04/2014
4 // version 1.2: 30/04/2014
4
5
5 #ifndef BASIC_PARAMETERS_H_INCLUDED
6 #ifndef BASIC_PARAMETERS_H_INCLUDED
6 #define BASIC_PARAMETERS_H_INCLUDED
7 #define BASIC_PARAMETERS_H_INCLUDED
@@ -1,6 +1,7
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.0: 31/07/2013
2 // version 1.0: 31/07/2013
3 // version 1.1: 01/04/2014
3 // version 1.1: 02/04/2014
4 // version 1.2: 30/04/2014
4
5
5 #include <file_utilities.h>
6 #include <file_utilities.h>
6
7
@@ -1,6 +1,7
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.0: 31/07/2013
2 // version 1.0: 31/07/2013
3 // version 1.1: 01/04/2014
3 // version 1.1: 02/04/2014
4 // version 1.2: 30/04/2014
4
5
5 #ifndef FILE_UTILITIES_H
6 #ifndef FILE_UTILITIES_H
6 #define FILE_UTILITIES_H
7 #define FILE_UTILITIES_H
@@ -1,5 +1,7
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.O: 31/07/2013
3 // version 1.1: 02/04/2014
4 // version 1.2: 30/04/2014
3
5
4 #include <stdio.h>
6 #include <stdio.h>
5 #include <basic_parameters.h>
7 #include <basic_parameters.h>
@@ -15,8 +17,17 int main(void)
15 const char *filename;
17 const char *filename;
16 printf("Hello World!\n\n");
18 printf("Hello World!\n\n");
17
19
20 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
21 //LSB FIRST
22 printf("The multi-byte quantities are laid out in a LSB FIRST (little endian) fashion \n\n");
23 #endif
24
25 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
26 //MSB FIRST
27 printf("The multi-byte quantities are laid out in a MSB FIRST (big endian) fashion\n\n");
28 #endif
29
18 //filename="/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Prog C/tests bp Paul/tests2/sm_test2.dat";
30 //filename="/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Prog C/tests bp Paul/tests2/sm_test2.dat";
19 //filename="/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Prog C/tests bp Paul/tests2/asm_f0_test_paul_1.dat";
20 filename="sm_test2.dat";
31 filename="sm_test2.dat";
21
32
22 lecture_file_sm(filename);
33 lecture_file_sm(filename);
General Comments 0
You need to be logged in to leave comments. Login now