diff --git a/basic_parameters.c b/basic_parameters.c old mode 100644 new mode 100755 --- a/basic_parameters.c +++ b/basic_parameters.c @@ -1,5 +1,6 @@ // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) -// version 1: 31/07/2013 +// version 1.0: 31/07/2013 +// version 1.1: 02/04/2014 #include "basic_parameters.h" #include @@ -88,7 +89,7 @@ void init_k_f0( void ) float alpha_M = 45 * (3.1415927/180); -void BP1_set( float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1 ){ +void BP1_set( float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp1 ){ int i, exponent; float PSDB; float PSDE; @@ -110,8 +111,8 @@ void BP1_set( float * compressed_spec_ma signed char nbitexp; signed char nbitsig; signed char expmin; - signed char expmax; // 8 bits - short int rangesig; // 16 bits + signed char expmax; // 8 bits + short int rangesig; // 16 bits unsigned short int psd; unsigned short int tmp_u_short_int; // 16 bits unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words @@ -121,8 +122,8 @@ void BP1_set( float * compressed_spec_ma init_k_f0(); #ifdef DEBUG_TCH + printf("BP1 : \n"); printf("Number of bins: %d\n", nb_bins_compressed_spec_mat); - printf("BP1 : \n"); #endif // initialization for managing the exponents of the floating point data: @@ -141,9 +142,9 @@ void BP1_set( float * compressed_spec_ma for(i=0; i n1 - NVEC_V1 = -compressed_spec_mat[i*30+4] / tmp; // S13 Im => n2 - NVEC_V2 = compressed_spec_mat[i*30+2] / tmp; // S12 Im => n3 + NVEC_V0 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]/ tmp; // S23 Im => n1 + NVEC_V1 = -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / tmp; // S13 Im => n2 + NVEC_V2 = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / tmp; // S12 Im => n3 - 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 - 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 + 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 + 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 pt_u_char = (unsigned char*) &NVEC_V2; // affect an unsigned char pointer with the adress of NVEC_V2 #ifdef LSB_FIRST_TCH - 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) - // record it at the 8th bit position (from the right to the left) of LFR_BP1[i*9+6] + 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) + // record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6] #endif #ifdef MSB_FIRST_TCH - 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) - // record it at the 8th bit position (from the right to the left) of LFR_BP1[i*9+6] + 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) + // record it at the 8th bit position (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6] #endif #ifdef DEBUG_TCH printf("NVEC_V0 : %16.8e\n",NVEC_V0); printf("NVEC_V1 : %16.8e\n",NVEC_V1); printf("NVEC_V2 : %16.8e\n",NVEC_V2); - printf("LFR_BP1[i*9+4] for NVEC_V0 : %u\n",LFR_BP1[i*9+4]); - printf("LFR_BP1[i*9+5] for NVEC_V1 : %u\n",LFR_BP1[i*9+5]); - printf("LFR_BP1[i*9+6] for NVEC_V2 : %u\n",LFR_BP1[i*9+6]); + printf("lfr_bp1[i*NB_BYTES_BP1+4] for NVEC_V0 : %u\n",lfr_bp1[i*NB_BYTES_BP1+4]); + printf("lfr_bp1[i*NB_BYTES_BP1+5] for NVEC_V1 : %u\n",lfr_bp1[i*NB_BYTES_BP1+5]); + printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]); #endif //======================================================= // BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits @@ -262,81 +264,81 @@ void BP1_set( float * compressed_spec_ma tmp_u_char = (unsigned char) (aux*15 + 0.5); // shift and cast into a 8-bit unsigned char with rounding // where just the first 4 bits are used (0, ..., 15) - LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | (tmp_u_char << 3); // put these 4 bits next to the right place + 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 // of the sign bit of NVEC_V2 (recorded - // previously in LFR_BP1[i*9+6]) + // previously in lfr_bp1[i*NB_BYTES_BP1+6]) #ifdef DEBUG_TCH printf("ellipticity : %16.8e\n",aux); printf("tmp_u_char for ellipticity : %u\n",tmp_u_char); - printf("LFR_BP1[i*9+6] for NVEC_V2 + ellipticity : %u\n",LFR_BP1[i*9+6]); + printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]); #endif //============================================================== // BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits - tr_SB_SB = compressed_spec_mat[i*30] *compressed_spec_mat[i*30] - + compressed_spec_mat[i*30+9] *compressed_spec_mat[i*30+9] - + compressed_spec_mat[i*30+16] *compressed_spec_mat[i*30+16] - + 2 * compressed_spec_mat[i*30+1] *compressed_spec_mat[i*30+1] - + 2 * compressed_spec_mat[i*30+2] *compressed_spec_mat[i*30+2] - + 2 * compressed_spec_mat[i*30+3] *compressed_spec_mat[i*30+3] - + 2 * compressed_spec_mat[i*30+4] *compressed_spec_mat[i*30+4] - + 2 * compressed_spec_mat[i*30+10]*compressed_spec_mat[i*30+10] - + 2 * compressed_spec_mat[i*30+11]*compressed_spec_mat[i*30+11]; + tr_SB_SB = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX] + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] + + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] + + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] + + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] + + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] *compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] + + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10] + + 2 * compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]; aux = PSDB*PSDB; tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux ); // compute the degree of polarisation tmp_u_char = (unsigned char) (tmp*7 + 0.5);// shift and cast into a 8-bit unsigned char with rounding // where just the first 3 bits are used (0, ..., 7) - LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | tmp_u_char; // record these 3 bits at the 3 first bit positions - // (from the right to the left) of LFR_BP1[i*9+6] + 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 + // (from the right to the left) of lfr_bp1[i*NB_BYTES_BP1+6] #ifdef DEBUG_TCH printf("DOP : %16.8e\n",tmp); printf("tmp_u_char for DOP : %u\n",tmp_u_char); - printf("LFR_BP1[i*9+6] for NVEC_V2 + ellipticity + DOP : %u\n",LFR_BP1[i*9+6]); + printf("lfr_bp1[i*NB_BYTES_BP1+6] for NVEC_V2 + ellipticity + DOP : %u\n",lfr_bp1[i*NB_BYTES_BP1+6]); #endif //======================================================================================= // BP1 X_SO-component of the Poynting flux == PA_LFR_SC_BP1_SX_F0 == 8 (+ 2) bits // = 5 bits (exponent) + 3 bits (significand) // + 1 sign bit + 1 argument bit (two sectors) - e_cross_b_re = compressed_spec_mat[i*30+17]*k_f0[i][K34_SX_RE] //S34 Re - + compressed_spec_mat[i*30+19]*k_f0[i][K35_SX_RE] //S35 Re - + compressed_spec_mat[i*30+5] *k_f0[i][K14_SX_RE] //S14 Re - + compressed_spec_mat[i*30+7] *k_f0[i][K15_SX_RE] //S15 Re - + compressed_spec_mat[i*30+12]*k_f0[i][K24_SX_RE] //S24 Re - + compressed_spec_mat[i*30+14]*k_f0[i][K25_SX_RE] //S25 Re - + compressed_spec_mat[i*30+18]*k_f0[i][K34_SX_IM] //S34 Im - + compressed_spec_mat[i*30+20]*k_f0[i][K35_SX_IM] //S35 Im - + compressed_spec_mat[i*30+6] *k_f0[i][K14_SX_IM] //S14 Im - + compressed_spec_mat[i*30+8] *k_f0[i][K15_SX_IM] //S15 Im - + compressed_spec_mat[i*30+13]*k_f0[i][K24_SX_IM] //S24 Im - + compressed_spec_mat[i*30+15]*k_f0[i][K25_SX_IM]; //S25 Im + e_cross_b_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_f0[i][K34_SX_RE] //S34 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_f0[i][K35_SX_RE] //S35 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_f0[i][K14_SX_RE] //S14 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] *k_f0[i][K15_SX_RE] //S15 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_f0[i][K24_SX_RE] //S24 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_f0[i][K25_SX_RE] //S25 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_f0[i][K34_SX_IM] //S34 Im + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_f0[i][K35_SX_IM] //S35 Im + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] *k_f0[i][K14_SX_IM] //S14 Im + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] *k_f0[i][K15_SX_IM] //S15 Im + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_f0[i][K24_SX_IM] //S24 Im + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_f0[i][K25_SX_IM]; //S25 Im // Im(S_ji) = -Im(S_ij) // k_ji = k_ij - e_cross_b_im = compressed_spec_mat[i*30+17]*k_f0[i][K34_SX_IM] //S34 Re - + compressed_spec_mat[i*30+19]*k_f0[i][K35_SX_IM] //S35 Re - + compressed_spec_mat[i*30+5] *k_f0[i][K14_SX_IM] //S14 Re - + compressed_spec_mat[i*30+7] *k_f0[i][K15_SX_IM] //S15 Re - + compressed_spec_mat[i*30+12]*k_f0[i][K24_SX_IM] //S24 Re - + compressed_spec_mat[i*30+14]*k_f0[i][K25_SX_IM] //S25 Re - - compressed_spec_mat[i*30+18]*k_f0[i][K34_SX_RE] //S34 Im - - compressed_spec_mat[i*30+20]*k_f0[i][K35_SX_RE] //S35 Im - - compressed_spec_mat[i*30+6] *k_f0[i][K14_SX_RE] //S14 Im - - compressed_spec_mat[i*30+8] *k_f0[i][K15_SX_RE] //S15 Im - - compressed_spec_mat[i*30+13]*k_f0[i][K24_SX_RE] //S24 Im - - compressed_spec_mat[i*30+15]*k_f0[i][K25_SX_RE]; //S25 Im + e_cross_b_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_f0[i][K34_SX_IM] //S34 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_f0[i][K35_SX_IM] //S35 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] *k_f0[i][K14_SX_IM] //S14 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] *k_f0[i][K15_SX_IM] //S15 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_f0[i][K24_SX_IM] //S24 Re + + compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_f0[i][K25_SX_IM] //S25 Re + - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_f0[i][K34_SX_RE] //S34 Im + - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_f0[i][K35_SX_RE] //S35 Im + - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] *k_f0[i][K14_SX_RE] //S14 Im + - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] *k_f0[i][K15_SX_RE] //S15 Im + - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_f0[i][K24_SX_RE] //S24 Im + - compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_f0[i][K25_SX_RE]; //S25 Im #ifdef DEBUG_TCH printf("ReaSX / 2 : %16.8e\n",e_cross_b_re/2); #endif pt_u_char = (unsigned char*) &e_cross_b_re; // Affect an unsigned char pointer with the adress of e_cross_b_re #ifdef LSB_FIRST_TCH - 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) + 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) // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1[i*9+1] + // of lfr_bp1[i*NB_BYTES_BP1+1] pt_u_char[3] = (pt_u_char[3] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX| #endif #ifdef MSB_FIRST_TCH - 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) + 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) // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1[i*9+1] + // of lfr_bp1[i*NB_BYTES_BP1+1] pt_u_char[0] = (pt_u_char[0] & 0x7f); // Make e_cross_b_re be positive in any case: |ReaSX| #endif significand = frexpf(e_cross_b_re/2, &exponent);// 0.5 <= significand < 1 @@ -357,7 +359,7 @@ void BP1_set( float * compressed_spec_ma significand = 0.5; // min value that can be recorded } - LFR_BP1[i*9+7] = (unsigned char) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit unsigned char with rounding + 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 // where just the first 3 bits are used (0, ..., 7) tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where // just the first 5 bits are used (0, ..., 2^5-1) @@ -365,14 +367,14 @@ void BP1_set( float * compressed_spec_ma printf("|ReaSX| / 2 : %16.8e\n",e_cross_b_re/2); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); - printf("LFR_BP1[i*9+7] for ReaSX significand : %u\n",LFR_BP1[i*9+7]); + printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]); printf("tmp_u_char for ReaSX exponent : %d\n",tmp_u_char); #endif - LFR_BP1[i*9+7] = LFR_BP1[i*9+7] | (tmp_u_char << 3); // shift these 5 bits to the left before logical addition - // with LFR_BP1[i*9+7] + 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 + // with lfr_bp1[i*NB_BYTES_BP1+7] #ifdef DEBUG_TCH - printf("LFR_BP1[i*9+7] for ReaSX exponent + significand : %u\n",LFR_BP1[i*9+7]); - printf("LFR_BP1[i*9+1] for ReaSX sign + PSDE 'exponent' : %u\n",LFR_BP1[i*9+1]); + printf("lfr_bp1[i*NB_BYTES_BP1+7] for ReaSX exponent + significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+7]); + printf("lfr_bp1[i*NB_BYTES_BP1+1] for ReaSX sign + PSDE 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+1]); printf("ImaSX / 2 : %16.8e\n",e_cross_b_im/2); #endif pt_u_char = (unsigned char*) &e_cross_b_im; // Affect an unsigned char pointer with the adress of e_cross_b_im @@ -384,12 +386,12 @@ void BP1_set( float * compressed_spec_ma #endif tmp_u_char = (e_cross_b_im > e_cross_b_re) ? 0x40 : 0x00; // Determine the sector argument of SX. If |Im| > |Re| affect // an unsigned 8-bit char with 01000000; otherwise with null. - 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 - // to the left) of LFR_BP1[i*9+1], by simple logical addition. + 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 + // to the left) of lfr_bp1[i*NB_BYTES_BP1+1], by simple logical addition. #ifdef DEBUG_TCH printf("|ImaSX| / 2 : %16.8e\n",e_cross_b_im/2); printf("ArgSX sign : %u\n",tmp_u_char); - printf("LFR_BP1[i*9+1] for ReaSX & ArgSX signs + PSDE 'exponent' : %u\n",LFR_BP1[i*9+1]); + printf("lfr_bp1[i*NB_BYTES_BP1+1] for ReaSX & ArgSX signs + PSDE 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+1]); #endif //====================================================================== // BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 8 (+ 2) bits @@ -397,44 +399,44 @@ void BP1_set( float * compressed_spec_ma // + 1 sign bit + 1 argument bit (two sectors) ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2; nz = NVEC_V0; - bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*30+9] // S22 Re - + sin(alpha_M)*sin(alpha_M)*compressed_spec_mat[i*30+16] // S33 Re - - 2*sin(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*30+10]; // S23 Re + bx_bx_star = cos(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9] // S22 Re + + sin(alpha_M)*sin(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16] // S33 Re + - 2*sin(alpha_M)*cos(alpha_M)*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10]; // S23 Re - n_cross_e_scal_b_re = ny * (compressed_spec_mat[i*30+12]*k_f0[i][K24_NY_RE] //S24 Re - +compressed_spec_mat[i*30+14]*k_f0[i][K25_NY_RE] //S25 Re - +compressed_spec_mat[i*30+17]*k_f0[i][K34_NY_RE] //S34 Re - +compressed_spec_mat[i*30+19]*k_f0[i][K35_NY_RE] //S35 Re - +compressed_spec_mat[i*30+13]*k_f0[i][K24_NY_IM] //S24 Im - +compressed_spec_mat[i*30+15]*k_f0[i][K25_NY_IM] //S25 Im - +compressed_spec_mat[i*30+18]*k_f0[i][K34_NY_IM] //S34 Im - +compressed_spec_mat[i*30+20]*k_f0[i][K35_NY_IM]) //S35 Im - + nz * (compressed_spec_mat[i*30+12]*k_f0[i][K24_NZ_RE] //S24 Re - +compressed_spec_mat[i*30+14]*k_f0[i][K25_NZ_RE] //S25 Re - +compressed_spec_mat[i*30+17]*k_f0[i][K34_NZ_RE] //S34 Re - +compressed_spec_mat[i*30+19]*k_f0[i][K35_NZ_RE] //S35 Re - +compressed_spec_mat[i*30+13]*k_f0[i][K24_NZ_IM] //S24 Im - +compressed_spec_mat[i*30+15]*k_f0[i][K25_NZ_IM] //S25 Im - +compressed_spec_mat[i*30+18]*k_f0[i][K34_NZ_IM] //S34 Im - +compressed_spec_mat[i*30+20]*k_f0[i][K35_NZ_IM]);//S35 Im + 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 + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_f0[i][K25_NY_RE] //S25 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_f0[i][K34_NY_RE] //S34 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_f0[i][K35_NY_RE] //S35 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_f0[i][K24_NY_IM] //S24 Im + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_f0[i][K25_NY_IM] //S25 Im + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_f0[i][K34_NY_IM] //S34 Im + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_f0[i][K35_NY_IM]) //S35 Im + + nz * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_f0[i][K24_NZ_RE] //S24 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_f0[i][K25_NZ_RE] //S25 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_f0[i][K34_NZ_RE] //S34 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_f0[i][K35_NZ_RE] //S35 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_f0[i][K24_NZ_IM] //S24 Im + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_f0[i][K25_NZ_IM] //S25 Im + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_f0[i][K34_NZ_IM] //S34 Im + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_f0[i][K35_NZ_IM]);//S35 Im // Im(S_ji) = -Im(S_ij) // k_ji = k_ij - n_cross_e_scal_b_im = ny * (compressed_spec_mat[i*30+12]*k_f0[i][K24_NY_IM] //S24 Re - +compressed_spec_mat[i*30+14]*k_f0[i][K25_NY_IM] //S25 Re - +compressed_spec_mat[i*30+17]*k_f0[i][K34_NY_IM] //S34 Re - +compressed_spec_mat[i*30+19]*k_f0[i][K35_NY_IM] //S35 Re - -compressed_spec_mat[i*30+13]*k_f0[i][K24_NY_RE] //S24 Im - -compressed_spec_mat[i*30+15]*k_f0[i][K25_NY_RE] //S25 Im - -compressed_spec_mat[i*30+18]*k_f0[i][K34_NY_RE] //S34 Im - -compressed_spec_mat[i*30+20]*k_f0[i][K35_NY_RE]) //S35 Im - + nz * (compressed_spec_mat[i*30+12]*k_f0[i][K24_NZ_IM] //S24 Re - +compressed_spec_mat[i*30+14]*k_f0[i][K25_NZ_IM] //S25 Re - +compressed_spec_mat[i*30+17]*k_f0[i][K34_NZ_IM] //S34 Re - +compressed_spec_mat[i*30+19]*k_f0[i][K35_NZ_IM] //S35 Re - -compressed_spec_mat[i*30+13]*k_f0[i][K24_NZ_RE] //S24 Im - -compressed_spec_mat[i*30+15]*k_f0[i][K25_NZ_RE] //S25 Im - -compressed_spec_mat[i*30+18]*k_f0[i][K34_NZ_RE] //S34 Im - -compressed_spec_mat[i*30+20]*k_f0[i][K35_NZ_RE]);//S35 Im + 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 + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_f0[i][K25_NY_IM] //S25 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_f0[i][K34_NY_IM] //S34 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_f0[i][K35_NY_IM] //S35 Re + -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_f0[i][K24_NY_RE] //S24 Im + -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_f0[i][K25_NY_RE] //S25 Im + -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_f0[i][K34_NY_RE] //S34 Im + -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_f0[i][K35_NY_RE]) //S35 Im + + nz * (compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12]*k_f0[i][K24_NZ_IM] //S24 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14]*k_f0[i][K25_NZ_IM] //S25 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17]*k_f0[i][K34_NZ_IM] //S34 Re + +compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19]*k_f0[i][K35_NZ_IM] //S35 Re + -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]*k_f0[i][K24_NZ_RE] //S24 Im + -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]*k_f0[i][K25_NZ_RE] //S25 Im + -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]*k_f0[i][K34_NZ_RE] //S34 Im + -compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]*k_f0[i][K35_NZ_RE]);//S35 Im #ifdef DEBUG_TCH printf("n_cross_e_scal_b_re : %16.8e\n",n_cross_e_scal_b_re); printf("n_cross_e_scal_b_im : %16.8e\n",n_cross_e_scal_b_im); @@ -442,15 +444,15 @@ void BP1_set( float * compressed_spec_ma // vphi = n_cross_e_scal_b_re / bx_bx_star => sign(VPHI) = sign(n_cross_e_scal_b_re) 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 #ifdef LSB_FIRST_TCH - 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) + 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) // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1[i*9+3] + // of lfr_bp1[i*NB_BYTES_BP1+3] 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| #endif #ifdef MSB_FIRST_TCH - 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) + 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) // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1[i*9+3] + // of lfr_bp1[i*NB_BYTES_BP1+3] 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| #endif vphi = n_cross_e_scal_b_re / bx_bx_star; // Compute |VPHI| @@ -477,19 +479,19 @@ void BP1_set( float * compressed_spec_ma printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); #endif - LFR_BP1[i*9+8] = (unsigned char) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit unsigned char with rounding + 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 // where just the first 3 bits are used (0, ..., 7) tmp_u_char = (unsigned char) (exponent-expmin); // Shift and cast into a 8-bit unsigned char where // just the first 5 bits are used (0, ..., 2^5-1) #ifdef DEBUG_TCH - printf("LFR_BP1[i*9+8] for VPHI significand : %u\n",LFR_BP1[i*9+8]); + printf("lfr_bp1[i*NB_BYTES_BP1+8] for VPHI significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]); printf("tmp_u_char for VPHI exponent : %d\n",tmp_u_char); #endif - LFR_BP1[i*9+8] = LFR_BP1[i*9+8] | (tmp_u_char << 3); // shift these 5 bits to the left before logical addition - // with LFR_BP1[i*9+8] + 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 + // with lfr_bp1[i*NB_BYTES_BP1+8] #ifdef DEBUG_TCH - printf("LFR_BP1[i*9+8] for VPHI exponent + significand : %u\n",LFR_BP1[i*9+8]); - printf("LFR_BP1[i*9+3] for VPHI sign + PSDB 'exponent' : %u\n",LFR_BP1[i*9+3]); + printf("lfr_bp1[i*NB_BYTES_BP1+8] for VPHI exponent + significand : %u\n",lfr_bp1[i*NB_BYTES_BP1+8]); + printf("lfr_bp1[i*NB_BYTES_BP1+3] for VPHI sign + PSDB 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+3]); #endif 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 #ifdef LSB_FIRST_TCH @@ -500,18 +502,18 @@ void BP1_set( float * compressed_spec_ma #endif 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 // an unsigned 8-bit char with 01000000; otherwise with null. - 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 - // to the left) of LFR_BP1[i*9+3], by simple logical addition. + 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 + // to the left) of lfr_bp1[i*NB_BYTES_BP1+3], by simple logical addition. #ifdef DEBUG_TCH printf("|n_cross_e_scal_b_im| : %16.8e\n",n_cross_e_scal_b_im); printf("|n_cross_e_scal_b_im|/bx_bx_star/2: %16.8e\n",n_cross_e_scal_b_im/bx_bx_star/2); printf("ArgNEBX sign : %u\n",tmp_u_char); - printf("LFR_BP1[i*9+3] for VPHI & ArgNEBX signs + PSDB 'exponent' : %u\n",LFR_BP1[i*9+3]); + printf("lfr_bp1[i*NB_BYTES_BP1+3] for VPHI & ArgNEBX signs + PSDB 'exponent' : %u\n",lfr_bp1[i*NB_BYTES_BP1+3]); #endif } } -void BP2_set( float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP2 ) +void BP2_set( float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp2 ) { int i, exponent; float aux, significand, cross_re, cross_im; @@ -521,8 +523,8 @@ void BP2_set( float * compressed_spec_ma unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words #ifdef DEBUG_TCH + printf("BP2 : \n"); printf("Number of bins: %d\n", nb_bins_compressed_spec_mat); - printf("BP2 : \n"); #endif // For floating point data to be recorded on 16-bit words : @@ -561,104 +563,105 @@ void BP2_set( float * compressed_spec_ma // == PA_LFR_SC_BP2_CROSS_RE_9_F0 == 8 bits // == PA_LFR_SC_BP2_CROSS_IM_9_F0 == 8 bits // S12 - aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+9]); - cross_re = compressed_spec_mat[i*30+1] / aux; - cross_im = compressed_spec_mat[i*30+2] / aux; - 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 - 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 + aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]); + cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+1] / aux; + cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+2] / aux; + 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 + 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 #ifdef DEBUG_TCH - printf("LFR_BP2[i*30+10] for cross12_re (%16.8e) : %.3u\n",cross_re, LFR_BP2[i*30+10]); - printf("LFR_BP2[i*30+20] for cross12_im (%16.8e) : %.3u\n",cross_im, LFR_BP2[i*30+20]); + printf("\nBin number: %d\n", i); + printf("lfr_bp2[i*NB_BYTES_BP2+10] for cross12_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+10]); + printf("lfr_bp2[i*NB_BYTES_BP2+20] for cross12_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+20]); #endif // S13 - aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+16]); - cross_re = compressed_spec_mat[i*30+3] / aux; - cross_im = compressed_spec_mat[i*30+4] / aux; - 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 - 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 + aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]); + cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+3] / aux; + cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+4] / aux; + 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 + 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 #ifdef DEBUG_TCH - printf("LFR_BP2[i*30+11] for cross13_re (%16.8e) : %.3u\n",cross_re, LFR_BP2[i*30+11]); - printf("LFR_BP2[i*30+21] for cross13_im (%16.8e) : %.3u\n",cross_im, LFR_BP2[i*30+21]); + printf("lfr_bp2[i*NB_BYTES_BP2+11] for cross13_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+11]); + printf("lfr_bp2[i*NB_BYTES_BP2+21] for cross13_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+21]); #endif // S14 - aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+21]); - cross_re = compressed_spec_mat[i*30+5] / aux; - cross_im = compressed_spec_mat[i*30+6] / aux; - 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 - 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 + aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]); + cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+5] / aux; + cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+6] / aux; + 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 + 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 #ifdef DEBUG_TCH - printf("LFR_BP2[i*30+12] for cross14_re (%16.8e) : %.3u\n",cross_re, LFR_BP2[i*30+12]); - printf("LFR_BP2[i*30+22] for cross14_im (%16.8e) : %.3u\n",cross_im, LFR_BP2[i*30+22]); + printf("lfr_bp2[i*NB_BYTES_BP2+12] for cross14_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+12]); + printf("lfr_bp2[i*NB_BYTES_BP2+22] for cross14_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+22]); #endif // S15 - aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+24]); - cross_re = compressed_spec_mat[i*30+7] / aux; - cross_im = compressed_spec_mat[i*30+8] / aux; - 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 - 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 + aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]); + cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+7] / aux; + cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+8] / aux; + 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 + 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 #ifdef DEBUG_TCH - printf("LFR_BP2[i*30+13] for cross15_re (%16.8e) : %.3u\n",cross_re, LFR_BP2[i*30+13]); - printf("LFR_BP2[i*30+23] for cross15_im (%16.8e) : %.3u\n",cross_im, LFR_BP2[i*30+23]); + printf("lfr_bp2[i*NB_BYTES_BP2+13] for cross15_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+13]); + printf("lfr_bp2[i*NB_BYTES_BP2+23] for cross15_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+23]); #endif // S23 - aux = sqrt(compressed_spec_mat[i*30+9]*compressed_spec_mat[i*30+16]); - cross_re = compressed_spec_mat[i*30+10] / aux; - cross_im = compressed_spec_mat[i*30+11] / aux; - 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 - 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 + aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]); + cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+10] / aux; + cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+11] / aux; + 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 + 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 #ifdef DEBUG_TCH - printf("LFR_BP2[i*30+14] for cross23_re (%16.8e) : %.3u\n",cross_re, LFR_BP2[i*30+14]); - printf("LFR_BP2[i*30+24] for cross23_im (%16.8e) : %.3u\n",cross_im, LFR_BP2[i*30+24]); + printf("lfr_bp2[i*NB_BYTES_BP2+14] for cross23_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+14]); + printf("lfr_bp2[i*NB_BYTES_BP2+24] for cross23_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+24]); #endif // S24 - aux = sqrt(compressed_spec_mat[i*30+9]*compressed_spec_mat[i*30+21]); - cross_re = compressed_spec_mat[i*30+12] / aux; - cross_im = compressed_spec_mat[i*30+13] / aux; - 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 - 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 + aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]); + cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+12] / aux; + cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+13] / aux; + 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 + 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 #ifdef DEBUG_TCH - printf("LFR_BP2[i*30+15] for cross24_re (%16.8e) : %.3u\n",cross_re, LFR_BP2[i*30+15]); - printf("LFR_BP2[i*30+25] for cross24_im (%16.8e) : %.3u\n",cross_im, LFR_BP2[i*30+25]); + printf("lfr_bp2[i*NB_BYTES_BP2+15] for cross24_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+15]); + printf("lfr_bp2[i*NB_BYTES_BP2+25] for cross24_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+25]); #endif // S25 - aux = sqrt(compressed_spec_mat[i*30+9]*compressed_spec_mat[i*30+24]); - cross_re = compressed_spec_mat[i*30+14] / aux; - cross_im = compressed_spec_mat[i*30+15] / aux; - 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 - 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 + aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]); + cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+14] / aux; + cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+15] / aux; + 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 + 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 #ifdef DEBUG_TCH - printf("LFR_BP2[i*30+16] for cross25_re (%16.8e) : %.3u\n",cross_re, LFR_BP2[i*30+16]); - printf("LFR_BP2[i*30+26] for cross25_im (%16.8e) : %.3u\n",cross_im, LFR_BP2[i*30+26]); + printf("lfr_bp2[i*NB_BYTES_BP2+16] for cross25_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+16]); + printf("lfr_bp2[i*NB_BYTES_BP2+26] for cross25_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+26]); #endif // S34 - aux = sqrt(compressed_spec_mat[i*30+16]*compressed_spec_mat[i*30+21]); - cross_re = compressed_spec_mat[i*30+17] / aux; - cross_im = compressed_spec_mat[i*30+18] / aux; - 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 - 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 + aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]); + cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+17] / aux; + cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+18] / aux; + 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 + 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 #ifdef DEBUG_TCH - printf("LFR_BP2[i*30+17] for cross34_re (%16.8e) : %.3u\n",cross_re, LFR_BP2[i*30+17]); - printf("LFR_BP2[i*30+27] for cross34_im (%16.8e) : %.3u\n",cross_im, LFR_BP2[i*30+27]); + printf("lfr_bp2[i*NB_BYTES_BP2+17] for cross34_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+17]); + printf("lfr_bp2[i*NB_BYTES_BP2+27] for cross34_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+27]); #endif // S35 - aux = sqrt(compressed_spec_mat[i*30+16]*compressed_spec_mat[i*30+24]); - cross_re = compressed_spec_mat[i*30+19] / aux; - cross_im = compressed_spec_mat[i*30+20] / aux; - 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 - 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 + aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]); + cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+19] / aux; + cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+20] / aux; + 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 + 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 #ifdef DEBUG_TCH - printf("LFR_BP2[i*30+18] for cross35_re (%16.8e) : %.3u\n",cross_re, LFR_BP2[i*30+18]); - printf("LFR_BP2[i*30+28] for cross35_im (%16.8e) : %.3u\n",cross_im, LFR_BP2[i*30+28]); + printf("lfr_bp2[i*NB_BYTES_BP2+18] for cross35_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+18]); + printf("lfr_bp2[i*NB_BYTES_BP2+28] for cross35_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+28]); #endif // S45 - aux = sqrt(compressed_spec_mat[i*30+21]*compressed_spec_mat[i*30+24]); - cross_re = compressed_spec_mat[i*30+22] / aux; - cross_im = compressed_spec_mat[i*30+23] / aux; - 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 - 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 + aux = sqrt(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]*compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]); + cross_re = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+22] / aux; + cross_im = compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+23] / aux; + 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 + 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 #ifdef DEBUG_TCH - printf("LFR_BP2[i*30+19] for cross45_re (%16.8e) : %.3u\n",cross_re, LFR_BP2[i*30+19]); - printf("LFR_BP2[i*30+29] for cross45_im (%16.8e) : %.3u\n",cross_im, LFR_BP2[i*30+29]); + printf("lfr_bp2[i*NB_BYTES_BP2+19] for cross45_re (%16.8e) : %.3u\n",cross_re, lfr_bp2[i*NB_BYTES_BP2+19]); + printf("lfr_bp2[i*NB_BYTES_BP2+29] for cross45_im (%16.8e) : %.3u\n",cross_im, lfr_bp2[i*NB_BYTES_BP2+29]); #endif //============================================== // BP2 auto correlations == PA_LFR_SC_BP2_AUTO_F0 == 5*16 bits = 5*[6 bits (exponent) + 10 bits (significand)] @@ -668,10 +671,10 @@ void BP2_set( float * compressed_spec_ma // == PA_LFR_SC_BP2_AUTO_A3_F0 == 16 bits // == PA_LFR_SC_BP2_AUTO_A4_F0 == 16 bits // S11 - significand = frexpf(compressed_spec_mat[i*30], &exponent); // 0.5 <= significand < 1 + significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX], &exponent); // 0.5 <= significand < 1 // S11 = significand * 2^exponent #ifdef DEBUG_TCH - printf("S11 : %16.8e\n",compressed_spec_mat[i*30]); + printf("S11 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX]); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); #endif @@ -692,7 +695,7 @@ void BP2_set( float * compressed_spec_ma // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2[i*30+0]; // Affect an unsigned short int pointer with the + pt_u_short_int = (unsigned short int*) &lfr_bp2[i*NB_BYTES_BP2+0]; // Affect an unsigned short int pointer with the // adress where the 16-bit word result will be stored *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the // left place of the significand bits (nbitsig), making @@ -701,14 +704,14 @@ void BP2_set( float * compressed_spec_ma printf("autocor for S11 significand : %u\n",autocor ); printf("tmp_u_char for S11 exponent : %u\n",tmp_u_short_int ); printf("*pt_u_short_int for S11 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2[i*30+1] : %u or %x\n",LFR_BP2[i*30+1], LFR_BP2[i*30+1]); - printf("LFR_BP2[i*30+0] : %u or %x\n",LFR_BP2[i*30+0], LFR_BP2[i*30+0]); + 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]); + 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]); #endif // S22 - significand = frexpf(compressed_spec_mat[i*30+9], &exponent); // 0.5 <= significand < 1 + significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9], &exponent); // 0.5 <= significand < 1 // S22 = significand * 2^exponent #ifdef DEBUG_TCH - printf("S22 : %16.8e\n",compressed_spec_mat[i*30+9]); + printf("S22 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+9]); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); #endif @@ -729,7 +732,7 @@ void BP2_set( float * compressed_spec_ma // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2[i*30+2]; // Affect an unsigned short int pointer with the + pt_u_short_int = (unsigned short int*) &lfr_bp2[i*NB_BYTES_BP2+2]; // Affect an unsigned short int pointer with the // adress where the 16-bit word result will be stored *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the // left place of the significand bits (nbitsig), making @@ -738,14 +741,14 @@ void BP2_set( float * compressed_spec_ma printf("autocor for S22 significand : %d\n",autocor ); printf("tmp_u_char for S22 exponent : %d\n",tmp_u_short_int ); printf("*pt_u_short_int for S22 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2[i*30+3] : %.3d or %x\n",LFR_BP2[i*30+3], LFR_BP2[i*30+3]); - printf("LFR_BP2[i*30+2] : %.3d or %x\n",LFR_BP2[i*30+2], LFR_BP2[i*30+2]); + 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]); + 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]); #endif // S33 - significand = frexpf(compressed_spec_mat[i*30+16], &exponent); // 0.5 <= significand < 1 + significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16], &exponent); // 0.5 <= significand < 1 // S33 = significand * 2^exponent #ifdef DEBUG_TCH - printf("S33 : %16.8e\n",compressed_spec_mat[i*30+16]); + printf("S33 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+16]); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); #endif @@ -766,7 +769,7 @@ void BP2_set( float * compressed_spec_ma // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2[i*30+4]; // Affect an unsigned short int pointer with the + pt_u_short_int = (unsigned short int*) &lfr_bp2[i*NB_BYTES_BP2+4]; // Affect an unsigned short int pointer with the // adress where the 16-bit word result will be stored *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the // left place of the significand bits (nbitsig), making @@ -775,14 +778,14 @@ void BP2_set( float * compressed_spec_ma printf("autocor for S33 significand : %d\n",autocor ); printf("tmp_u_char for S33 exponent : %d\n",tmp_u_short_int ); printf("*pt_u_short_int for S33 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2[i*30+5] : %.3d or %x\n",LFR_BP2[i*30+5], LFR_BP2[i*30+5]); - printf("LFR_BP2[i*30+4] : %.3d or %x\n",LFR_BP2[i*30+4], LFR_BP2[i*30+4]); + 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]); + 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]); #endif // S44 - significand = frexpf(compressed_spec_mat[i*30+21], &exponent); // 0.5 <= significand < 1 + significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21], &exponent); // 0.5 <= significand < 1 // S44 = significand * 2^exponent #ifdef DEBUG_TCH - printf("S44 : %16.8e\n",compressed_spec_mat[i*30+21]); + printf("S44 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+21]); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); #endif @@ -804,7 +807,7 @@ void BP2_set( float * compressed_spec_ma // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2[i*30+6]; // Affect an unsigned short int pointer with the + pt_u_short_int = (unsigned short int*) &lfr_bp2[i*NB_BYTES_BP2+6]; // Affect an unsigned short int pointer with the // adress where the 16-bit word result will be stored *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the // left place of the significand bits (nbitsig), making @@ -813,14 +816,14 @@ void BP2_set( float * compressed_spec_ma printf("autocor for S44 significand : %d\n",autocor ); printf("tmp_u_char for S44 exponent : %d\n",tmp_u_short_int ); printf("*pt_u_short_int for S44 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2[i*30+7] : %.3d or %x\n",LFR_BP2[i*30+7], LFR_BP2[i*30+7]); - printf("LFR_BP2[i*30+6] : %.3d or %x\n",LFR_BP2[i*30+6], LFR_BP2[i*30+6]); + 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]); + 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]); #endif // S55 - significand = frexpf(compressed_spec_mat[i*30+24], &exponent); // 0.5 <= significand < 1 + significand = frexpf(compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24], &exponent); // 0.5 <= significand < 1 // S55 = significand * 2^exponent #ifdef DEBUG_TCH - printf("S55 : %16.8e\n",compressed_spec_mat[i*30+24]); + printf("S55 : %16.8e\n",compressed_spec_mat[i*NB_VALUES_PER_SPECTRAL_MATRIX+24]); printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); #endif @@ -841,7 +844,7 @@ void BP2_set( float * compressed_spec_ma // where just the first nbitsig bits are used (0, ..., 2^nbitsig-1) tmp_u_short_int = (unsigned short int) (exponent-expmin); // Shift and cast into a 16-bit unsigned int // where just the first nbitexp bits are used (0, ..., 2^nbitexp-1) - pt_u_short_int = (unsigned short int*) &LFR_BP2[i*30+8]; // Affect an unsigned short int pointer with the + pt_u_short_int = (unsigned short int*) &lfr_bp2[i*NB_BYTES_BP2+8]; // Affect an unsigned short int pointer with the // adress where the 16-bit word result will be stored *pt_u_short_int = autocor | (tmp_u_short_int << nbitsig); // Put the exponent bits (nbitexp) next to the // left place of the significand bits (nbitsig), making @@ -850,8 +853,8 @@ void BP2_set( float * compressed_spec_ma printf("autocor for S55 significand : %d\n",autocor ); printf("tmp_u_char for S55 exponent : %d\n",tmp_u_short_int ); printf("*pt_u_short_int for S55 exponent + significand : %.3d or %x\n",*pt_u_short_int, *pt_u_short_int); - printf("LFR_BP2[i*30+9] : %.3d or %x\n",LFR_BP2[i*30+9], LFR_BP2[i*30+9]); - printf("LFR_BP2[i*30+8] : %.3d or %x\n",LFR_BP2[i*30+8], LFR_BP2[i*30+8]); + 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]); + 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]); #endif } } diff --git a/basic_parameters.h b/basic_parameters.h old mode 100644 new mode 100755 --- a/basic_parameters.h +++ b/basic_parameters.h @@ -1,13 +1,18 @@ // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) -// version 1: 31/07/2013 +// version 1.0: 31/07/2013 +// version 1.1: 02/04/2014 #ifndef BASIC_PARAMETERS_H_INCLUDED #define BASIC_PARAMETERS_H_INCLUDED +#define NB_VALUES_PER_SPECTRAL_MATRIX 25 #define NB_BINS_COMPRESSED_MATRIX_f0 1 +#define NB_BYTES_BP1 9 +#define NB_BYTES_BP2 30 + void init_k_f0( void ); -void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1); -void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP2); +void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp1); +void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * lfr_bp2); #endif // BASIC_PARAMETERS_H_INCLUDED diff --git a/file_utilities.c b/file_utilities.c old mode 100644 new mode 100755 --- a/file_utilities.c +++ b/file_utilities.c @@ -1,11 +1,12 @@ // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) -// version 1: 31/07/2013 +// version 1.0: 31/07/2013 +// version 1.1: 01/04/2014 #include int lecture_file_sm(const char *fileName) { - // unsigned int i; + int i; FILE *infile; infile = fopen(fileName, "rb"); // open explicitely a binary file !!! ... @@ -15,41 +16,47 @@ int lecture_file_sm(const char *fileName } (void) fread(compressed_spectral_matrix_f0, sizeof(compressed_spectral_matrix_f0), 1, infile); (void) fclose(infile); - printf("size of compressed_spectral_matrix_f0 : %d\n", sizeof(compressed_spectral_matrix_f0)); + printf("size of compressed_spectral_matrix_f0 : %lu\n", sizeof(compressed_spectral_matrix_f0)); + printf("Number of bins: %d\n\n", NB_BINS_COMPRESSED_MATRIX_f0); printf("compressed_spectral_matrix_f0 : \n"); + for(i=0; i Re:%16.8e Im:%16.8e\n", 1, 0, - compressed_spectral_matrix_f0[0], 0.); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+0], 0.); printf("Element %.2d (S12) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 2, 1, 2, - compressed_spectral_matrix_f0[1], compressed_spectral_matrix_f0[2]); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+1], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+2]); printf("Element %.2d (S13) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 3, 3, 4, - compressed_spectral_matrix_f0[3], compressed_spectral_matrix_f0[4]); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+3], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+4]); printf("Element %.2d (S14) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 4, 5, 6, - compressed_spectral_matrix_f0[5], compressed_spectral_matrix_f0[6]); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+5], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+6]); printf("Element %.2d (S15) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 5, 7, 8, - compressed_spectral_matrix_f0[7], compressed_spectral_matrix_f0[8]); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+7], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+8]); printf("Element %.2d (S22) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 6, 9, - compressed_spectral_matrix_f0[9], 0.); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+9], 0.); printf("Element %.2d (S23) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 7, 10, 11, - compressed_spectral_matrix_f0[10], compressed_spectral_matrix_f0[11]); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+10], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+11]); printf("Element %.2d (S24) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 8, 12, 13, - compressed_spectral_matrix_f0[12], compressed_spectral_matrix_f0[13]); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+12], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+13]); printf("Element %.2d (S25) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 9, 14, 15, - compressed_spectral_matrix_f0[14], compressed_spectral_matrix_f0[15]); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+14], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+15]); printf("Element %.2d (S33) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 10, 16, - compressed_spectral_matrix_f0[16], 0.); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+16], 0.); printf("Element %.2d (S34) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 11, 17, 18, - compressed_spectral_matrix_f0[17], compressed_spectral_matrix_f0[18]); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+17], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+18]); printf("Element %.2d (S35) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 12, 19, 20, - compressed_spectral_matrix_f0[19], compressed_spectral_matrix_f0[20]); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+19], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+20]); printf("Element %.2d (S44) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 13, 21, - compressed_spectral_matrix_f0[21], 0.); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+21], 0.); printf("Element %.2d (S45) (%.2d & %.2d) => Re:%16.8e Im:%16.8e\n", 14, 22, 23, - compressed_spectral_matrix_f0[22], compressed_spectral_matrix_f0[23]); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+22], compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+23]); printf("Element %.2d (S55) (%.2d & --) => Re:%16.8e Im:%16.8e\n", 15, 24, - compressed_spectral_matrix_f0[24], 0.); + compressed_spectral_matrix_f0[i*NB_VALUES_PER_SPECTRAL_MATRIX+24], 0.); + } return 0; } diff --git a/file_utilities.h b/file_utilities.h old mode 100644 new mode 100755 --- a/file_utilities.h +++ b/file_utilities.h @@ -1,5 +1,6 @@ // In the frame of RPW LFR Sofware ICD Issue1 Rev8 (05/07/2013) -// version 1: 31/07/2013 +// version 1.0: 31/07/2013 +// version 1.1: 01/04/2014 #ifndef FILE_UTILITIES_H #define FILE_UTILITIES_H @@ -8,7 +9,7 @@ #include #include -extern float compressed_spectral_matrix_f0[TOTAL_SIZE_COMPRESSED_MATRIX_f0]; +extern float compressed_spectral_matrix_f0[NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_SPECTRAL_MATRIX]; int lecture_file_sm(const char *fileName); diff --git a/main.c b/main.c old mode 100644 new mode 100755 --- a/main.c +++ b/main.c @@ -5,20 +5,29 @@ #include #include -float compressed_spectral_matrix_f0[TOTAL_SIZE_COMPRESSED_MATRIX_f0]; +float compressed_spectral_matrix_f0[NB_BINS_COMPRESSED_MATRIX_f0 * NB_VALUES_PER_SPECTRAL_MATRIX]; -unsigned char LFR_BP1_F0[NB_BINS_COMPRESSED_MATRIX_f0*9]; -unsigned char LFR_BP2_F0[NB_BINS_COMPRESSED_MATRIX_f0*30]; +unsigned char LFR_BP1_f0[NB_BINS_COMPRESSED_MATRIX_f0*NB_BYTES_BP1]; +unsigned char LFR_BP2_f0[NB_BINS_COMPRESSED_MATRIX_f0*NB_BYTES_BP2]; int main(void) { - printf("Hello World!\n"); + const char *filename; + printf("Hello World!\n\n"); - lecture_file_sm("sm_test1.dat"); + //filename="/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Prog C/tests bp Paul/tests2/sm_test2.dat"; + //filename="/WIN/Users/chust/DD CHUST/Missions/Solar Orbiter/LFR/Prog C/tests bp Paul/tests2/asm_f0_test_paul_1.dat"; + filename="sm_test2.dat"; - BP1_set(); + lecture_file_sm(filename); + + printf("\n"); - BP2_set(); + BP1_set(compressed_spectral_matrix_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_f0); + + printf("\n"); + + BP2_set(compressed_spectral_matrix_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP2_f0); return 0; } diff --git a/sm_test2.dat b/sm_test2.dat new file mode 100755 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..90cff683351d8171552d2257db15e769448984dc GIT binary patch literal 100 zc$@)b0Gt03j(JJYo~OspxBJHFZpKI6)kR4Xd+0|?P*lkQ;PgmF9>>Q5u2V*gt`El} zv)IP~pQJ{;tS?72&??6WmTyI#kAO*PSH;Nr-T}x^#}P