# HG changeset patch # User paul # Date 2014-02-13 08:25:30 # Node ID 294fc10efc0eadddaba53149ef6dd1e60a0587c6 # Parent 6419d396838671e5f1d6006720088d1a32a542d2 Sync diff --git a/basic_parameters.c b/basic_parameters.c --- a/basic_parameters.c +++ b/basic_parameters.c @@ -43,7 +43,8 @@ float k_f0[NB_BINS_COMPRESSED_MATRIX_f0][32]; -void init_k_f0(){ +void init_k_f0( void ) +{ unsigned char i; for(i=0; i n1 - NVEC_V1 = -compressed_spectral_matrix_f0[i*30+4] / tmp; // S13 Im => n2 - NVEC_V2 = compressed_spectral_matrix_f0[i*30+2] / tmp; // S12 Im => n3 + NVEC_V0 = compressed_spec_mat[i*30+11]/ tmp; // S23 Im => 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 - LFR_BP1_F0[i*9+4] = (unsigned char) (NVEC_V0*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding - LFR_BP1_F0[i*9+5] = (unsigned char) (NVEC_V1*127.5 + 128); // shift and cast into a 8-bit unsigned char (0, ..., 255) with rounding + 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 pt_u_char = (unsigned char*) &NVEC_V2; // affect an unsigned char pointer with the adress of NVEC_V2 #ifdef LSB_FIRST_TCH - LFR_BP1_F0[i*9+6] = pt_u_char[3] & 0x80; // extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 4th octet:PC convention) - // record it at the 8th bit position (from the right to the left) of LFR_BP1_F0[i*9+6] + 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] #endif #ifdef MSB_FIRST_TCH - LFR_BP1_F0[i*9+6] = pt_u_char[0] & 0x80; // extract the sign bit of NVEC_V2 (32-bit float, sign bit in the 0th octet:SPARC convention) - // record it at the 8th bit position (from the right to the left) of LFR_BP1_F0[i*9+6] + 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] #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_F0[i*9+4] for NVEC_V0 : %u\n",LFR_BP1_F0[i*9+4]); - printf("LFR_BP1_F0[i*9+5] for NVEC_V1 : %u\n",LFR_BP1_F0[i*9+5]); - printf("LFR_BP1_F0[i*9+6] for NVEC_V2 : %u\n",LFR_BP1_F0[i*9+6]); + 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]); #endif //======================================================= // BP1 ellipticity == PA_LFR_SC_BP1_ELLIP_F0 == 4 bits @@ -245,81 +262,81 @@ void BP1_set(){ 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_F0[i*9+6] = LFR_BP1_F0[i*9+6] | (tmp_u_char << 3); // put these 4 bits next to the right place + LFR_BP1[i*9+6] = LFR_BP1[i*9+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_F0[i*9+6]) + // previously in LFR_BP1[i*9+6]) #ifdef DEBUG_TCH printf("ellipticity : %16.8e\n",aux); printf("tmp_u_char for ellipticity : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+6] for NVEC_V2 + ellipticity : %u\n",LFR_BP1_F0[i*9+6]); + printf("LFR_BP1[i*9+6] for NVEC_V2 + ellipticity : %u\n",LFR_BP1[i*9+6]); #endif //============================================================== // BP1 degree of polarization == PA_LFR_SC_BP1_DOP_F0 == 3 bits - tr_SB_SB = compressed_spectral_matrix_f0[i*30] *compressed_spectral_matrix_f0[i*30] - + compressed_spectral_matrix_f0[i*30+9] *compressed_spectral_matrix_f0[i*30+9] - + compressed_spectral_matrix_f0[i*30+16] *compressed_spectral_matrix_f0[i*30+16] - + 2 * compressed_spectral_matrix_f0[i*30+1] *compressed_spectral_matrix_f0[i*30+1] - + 2 * compressed_spectral_matrix_f0[i*30+2] *compressed_spectral_matrix_f0[i*30+2] - + 2 * compressed_spectral_matrix_f0[i*30+3] *compressed_spectral_matrix_f0[i*30+3] - + 2 * compressed_spectral_matrix_f0[i*30+4] *compressed_spectral_matrix_f0[i*30+4] - + 2 * compressed_spectral_matrix_f0[i*30+10]*compressed_spectral_matrix_f0[i*30+10] - + 2 * compressed_spectral_matrix_f0[i*30+11]*compressed_spectral_matrix_f0[i*30+11]; + 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]; 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_F0[i*9+6] = LFR_BP1_F0[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_F0[i*9+6] + 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] #ifdef DEBUG_TCH printf("DOP : %16.8e\n",tmp); printf("tmp_u_char for DOP : %u\n",tmp_u_char); - printf("LFR_BP1_F0[i*9+6] for NVEC_V2 + ellipticity + DOP : %u\n",LFR_BP1_F0[i*9+6]); + printf("LFR_BP1[i*9+6] for NVEC_V2 + ellipticity + DOP : %u\n",LFR_BP1[i*9+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_spectral_matrix_f0[i*30+17]*k_f0[i][K34_SX_RE] //S34 Re - + compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_SX_RE] //S35 Re - + compressed_spectral_matrix_f0[i*30+5] *k_f0[i][K14_SX_RE] //S14 Re - + compressed_spectral_matrix_f0[i*30+7] *k_f0[i][K15_SX_RE] //S15 Re - + compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_SX_RE] //S24 Re - + compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_SX_RE] //S25 Re - + compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_SX_IM] //S34 Im - + compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_SX_IM] //S35 Im - + compressed_spectral_matrix_f0[i*30+6] *k_f0[i][K14_SX_IM] //S14 Im - + compressed_spectral_matrix_f0[i*30+8] *k_f0[i][K15_SX_IM] //S15 Im - + compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_SX_IM] //S24 Im - + compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_SX_IM]; //S25 Im + 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 // Im(S_ji) = -Im(S_ij) // k_ji = k_ij - e_cross_b_im = compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_SX_IM] //S34 Re - + compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_SX_IM] //S35 Re - + compressed_spectral_matrix_f0[i*30+5] *k_f0[i][K14_SX_IM] //S14 Re - + compressed_spectral_matrix_f0[i*30+7] *k_f0[i][K15_SX_IM] //S15 Re - + compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_SX_IM] //S24 Re - + compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_SX_IM] //S25 Re - - compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_SX_RE] //S34 Im - - compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_SX_RE] //S35 Im - - compressed_spectral_matrix_f0[i*30+6] *k_f0[i][K14_SX_RE] //S14 Im - - compressed_spectral_matrix_f0[i*30+8] *k_f0[i][K15_SX_RE] //S15 Im - - compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_SX_RE] //S24 Im - - compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_SX_RE]; //S25 Im + 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 #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_F0[i*9+1] = LFR_BP1_F0[i*9+1] | (pt_u_char[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention) + 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) // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1_F0[i*9+1] + // of LFR_BP1[i*9+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_F0[i*9+1] = LFR_BP1_F0[i*9+1] | (pt_u_char[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 0th octet:SPARC convention) + 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) // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1_F0[i*9+1] + // of LFR_BP1[i*9+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 @@ -340,7 +357,7 @@ void BP1_set(){ significand = 0.5; // min value that can be recorded } - LFR_BP1_F0[i*9+7] = (unsigned char) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit unsigned char with rounding + LFR_BP1[i*9+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) @@ -348,14 +365,14 @@ void BP1_set(){ 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_F0[i*9+7] for ReaSX significand : %u\n",LFR_BP1_F0[i*9+7]); + printf("LFR_BP1[i*9+7] for ReaSX significand : %u\n",LFR_BP1[i*9+7]); printf("tmp_u_char for ReaSX exponent : %d\n",tmp_u_char); #endif - LFR_BP1_F0[i*9+7] = LFR_BP1_F0[i*9+7] | (tmp_u_char << 3); // shift these 5 bits to the left before logical addition - // with LFR_BP1_F0[i*9+7] + 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] #ifdef DEBUG_TCH - printf("LFR_BP1_F0[i*9+7] for ReaSX exponent + significand : %u\n",LFR_BP1_F0[i*9+7]); - printf("LFR_BP1_F0[i*9+1] for ReaSX sign + PSDE 'exponent' : %u\n",LFR_BP1_F0[i*9+1]); + 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("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 @@ -367,12 +384,12 @@ void BP1_set(){ #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_F0[i*9+1] = LFR_BP1_F0[i*9+1] | tmp_u_char; // Record it as a sign bit at the 7th bit position (from the right - // to the left) of LFR_BP1_F0[i*9+1], by simple logical addition. + 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. #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_F0[i*9+1] for ReaSX & ArgSX signs + PSDE 'exponent' : %u\n",LFR_BP1_F0[i*9+1]); + printf("LFR_BP1[i*9+1] for ReaSX & ArgSX signs + PSDE 'exponent' : %u\n",LFR_BP1[i*9+1]); #endif //====================================================================== // BP1 phase velocity estimator == PA_LFR_SC_BP1_VPHI_F0 == 8 (+ 2) bits @@ -380,44 +397,44 @@ void BP1_set(){ // + 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_spectral_matrix_f0[i*30+9] // S22 Re - + sin(alpha_M)*sin(alpha_M)*compressed_spectral_matrix_f0[i*30+16] // S33 Re - - 2*sin(alpha_M)*cos(alpha_M)*compressed_spectral_matrix_f0[i*30+10]; // S23 Re + 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 - n_cross_e_scal_b_re = ny * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NY_RE] //S24 Re - +compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NY_RE] //S25 Re - +compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NY_RE] //S34 Re - +compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NY_RE] //S35 Re - +compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NY_IM] //S24 Im - +compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NY_IM] //S25 Im - +compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NY_IM] //S34 Im - +compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NY_IM]) //S35 Im - + nz * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NZ_RE] //S24 Re - +compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NZ_RE] //S25 Re - +compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NZ_RE] //S34 Re - +compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NZ_RE] //S35 Re - +compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NZ_IM] //S24 Im - +compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NZ_IM] //S25 Im - +compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NZ_IM] //S34 Im - +compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NZ_IM]);//S35 Im + 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 // Im(S_ji) = -Im(S_ij) // k_ji = k_ij - n_cross_e_scal_b_im = ny * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NY_IM] //S24 Re - +compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NY_IM] //S25 Re - +compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NY_IM] //S34 Re - +compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NY_IM] //S35 Re - -compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NY_RE] //S24 Im - -compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NY_RE] //S25 Im - -compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NY_RE] //S34 Im - -compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NY_RE]) //S35 Im - + nz * (compressed_spectral_matrix_f0[i*30+12]*k_f0[i][K24_NZ_IM] //S24 Re - +compressed_spectral_matrix_f0[i*30+14]*k_f0[i][K25_NZ_IM] //S25 Re - +compressed_spectral_matrix_f0[i*30+17]*k_f0[i][K34_NZ_IM] //S34 Re - +compressed_spectral_matrix_f0[i*30+19]*k_f0[i][K35_NZ_IM] //S35 Re - -compressed_spectral_matrix_f0[i*30+13]*k_f0[i][K24_NZ_RE] //S24 Im - -compressed_spectral_matrix_f0[i*30+15]*k_f0[i][K25_NZ_RE] //S25 Im - -compressed_spectral_matrix_f0[i*30+18]*k_f0[i][K34_NZ_RE] //S34 Im - -compressed_spectral_matrix_f0[i*30+20]*k_f0[i][K35_NZ_RE]);//S35 Im + 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 #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); @@ -425,15 +442,15 @@ void BP1_set(){ // 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_F0[i*9+3] = LFR_BP1_F0[i*9+3] | (pt_u_char[3] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 4th octet:PC convention) + 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) // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1_F0[i*9+3] + // of LFR_BP1[i*9+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_F0[i*9+3] = LFR_BP1_F0[i*9+3] | (pt_u_char[0] & 0x80); // Extract its sign bit (32-bit float, sign bit in the 0th octet:SPARC convention) + 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) // Record it at the 8th bit position (from the right to the left) - // of LFR_BP1_F0[i*9+3] + // of LFR_BP1[i*9+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| @@ -460,19 +477,19 @@ void BP1_set(){ printf("significand : %16.8e\n",significand); printf("exponent : %d\n" ,exponent); #endif - LFR_BP1_F0[i*9+8] = (unsigned char) ((significand*2-1)*7 + 0.5); // Shift and cast into a 8-bit unsigned char with rounding + LFR_BP1[i*9+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_F0[i*9+8] for VPHI significand : %u\n",LFR_BP1_F0[i*9+8]); + printf("LFR_BP1[i*9+8] for VPHI significand : %u\n",LFR_BP1[i*9+8]); printf("tmp_u_char for VPHI exponent : %d\n",tmp_u_char); #endif - LFR_BP1_F0[i*9+8] = LFR_BP1_F0[i*9+8] | (tmp_u_char << 3); // shift these 5 bits to the left before logical addition - // with LFR_BP1_F0[i*9+8] + 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] #ifdef DEBUG_TCH - printf("LFR_BP1_F0[i*9+8] for VPHI exponent + significand : %u\n",LFR_BP1_F0[i*9+8]); - printf("LFR_BP1_F0[i*9+3] for VPHI sign + PSDB 'exponent' : %u\n",LFR_BP1_F0[i*9+3]); + 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]); #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 @@ -483,18 +500,19 @@ void BP1_set(){ #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_F0[i*9+3] = LFR_BP1_F0[i*9+3] | tmp_u_char; // Record it as a sign bit at the 7th bit position (from the right - // to the left) of LFR_BP1_F0[i*9+3], by simple logical addition. + 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. #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_F0[i*9+3] for VPHI & ArgNEBX signs + PSDB 'exponent' : %u\n",LFR_BP1_F0[i*9+3]); + printf("LFR_BP1[i*9+3] for VPHI & ArgNEBX signs + PSDB 'exponent' : %u\n",LFR_BP1[i*9+3]); #endif } } -void BP2_set(){ +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; signed char nbitexp, nbitsig, expmin, expmax; // 8 bits @@ -503,7 +521,7 @@ void BP2_set(){ unsigned short int *pt_u_short_int; // pointer on unsigned 16-bit words #ifdef DEBUG_TCH - printf("Number of bins: %d\n", NB_BINS_COMPRESSED_MATRIX_f0); + printf("Number of bins: %d\n", nb_bins_compressed_spec_mat); printf("BP2 : \n"); #endif @@ -519,7 +537,7 @@ void BP2_set(){ printf("expmin : %d, expmax : %d\n", expmin, expmax); #endif - for(i = 0; i