Flux Ghll( Vars Uimo, Vars Ui, Vars Uipo, Vars Uipt){//calculates the HLL flux for a given interface in y Flux G_HLL; Vars UL = U_L(Ui, Uimo, Uipo); Vars UR = U_R(Ui, Uipo, Uipt); //Calculates the conserved variables at the interfaces double alphap = alpha(UL, UR, 1., -1); double alpham = alpha(UL, UR, -1., -1); Flux FL = get_G(UL); Flux FR = get_G(UR); //Calculates the Fluxes from the left and right at the interface G_HLL.rhov = (alphap*FL.rhov + alpham*FR.rhov - alphap*alpham*(UR.mass - UL.mass))/(alphap + alpham); G_HLL.momx = (alphap*FL.momx + alpham*FR.momx - alphap*alpham*(UR.xvelocity - UL.xvelocity))/(alphap + alpham); G_HLL.momy = (alphap*FL.momy + alpham*FR.momy - alphap*alpham*(UR.yvelocity - UL.yvelocity))/(alphap + alpham); G_HLL.energy = (alphap*FL.energy + alpham*FR.energy - alphap*alpham*(UR.energy - UL.energy))/(alphap + alpham); return(G_HLL); }
quan::three_d::vect<DATA_STRUCT::force> DATA_STRUCT::calculate_forces(DATA_STRUCT::particle const & x, DATA_STRUCT::particle const & y) { // find absolute distance between particles quan::three_d::vect<DATA_STRUCT::length> pos_diff = y.pos - x.pos; quan::meta::binary_op< DATA_STRUCT::length, quan::meta::times, DATA_STRUCT::length >::type norm_pos = norm(pos_diff); // DATA_STRUCT::length abs_distance = magnitude(pos_diff); quan::three_d::vect<DATA_STRUCT::force> result; if ( abs_distance > DATA_STRUCT::length_epsilon){ #ifdef USE_QUAN DATA_STRUCT::force abs_force = get_quan_G() * x.mass * y.mass / norm_pos; #else DATA_STRUCT::force abs_force = get_G() * x.mass * y.mass / norm_pos; #endif result = abs_force * pos_diff / abs_distance; } else{ result = quan::three_d::vect<DATA_STRUCT::force>( DATA_STRUCT::force(0), DATA_STRUCT::force(0), DATA_STRUCT::force(0) ); }; return result; }
/* this function takes in the Y, Pb, Pr representation and outputs the 4 pixels in a UArray_T */ UArray_T CVC_to_rgb_pixels(CVC *YPbPr) { UArray_T r_array = UArray_new(PIX_PER_BLOCK, sizeof(struct Pnm_rgb)); assert(r_array != NULL); Pnm_rgb cur_pix; Pnm_rgb_float cur_pix_float = malloc(sizeof(struct Pnm_rgb_float)); for (int i = 0; i < PIX_PER_BLOCK; i++) { cur_pix = (Pnm_rgb)UArray_at(r_array, i); assert(cur_pix != NULL); cur_pix_float->red = get_R(YPbPr, i); cur_pix_float->green = get_G(YPbPr, i); cur_pix_float->blue = get_B(YPbPr, i); denormalize_pixel(cur_pix_float, DEFAULT_DENOMINATOR); /* we could have rounded this properly before assigning to integers, but we ran out of time. sorry! */ cur_pix->red = cur_pix_float->red; cur_pix->blue = cur_pix_float->blue; cur_pix->green = cur_pix_float->green; } free(cur_pix_float); return r_array; }
void sync_const() { String s; Form2->Edit1->Text = get_nb(); Form2->Edit2->Text = get_k(); Form2->Edit3->Text = make_name(get_Pb()); Form2->Edit4->Text = make_name(get_E()); Form2->Edit5->Text = make_name(get_G()); }
void IASIAM::get_G(complex<double>* V) { r->mu = real(V[0]); get_G(); V[0] = r->mu + get_n(r->G) - r->n; }
void SIAM::get_G(complex<double>* V) { mu = real(V[0]); get_G(); V[0] = mu + get_n(G) - n; }
void SIAM::SolveSiam(complex<double>* V) { mu0 = real(V[0]); MPT_B = real(V[1]); //--------------------// get_G0(); n = get_n(G0); MPT_B0 = get_MPT_B0(); get_As(); get_Ps(); get_SOCSigma(); get_Sigma(); get_G(); //--------------------// V[0] = mu0 + (get_n(G) - n); //we need to satisfy (get_n(G) == n) and V[1] = get_MPT_B(); // (MPT_B == get_MPT_B()) }
void IASIAM::SolveSiam(complex<double>* V) { mu0 = real(V[0]); //--------------------// //printf("IASIAM: about to get G0\n"); get_G0(); //printf("IASIAM: about to get n\n"); r->n0 = get_n(r->G0); r->n = r->n0; //printf("IASIAM: about to get n\n"); fft->FtoT(r->G0, r->G0_tau); get_SOCSigma_tau(); fft->TtoF(r->SOCSigma_tau, r->SOCSigma); get_G(); r->n = get_n(r->G); //--------------------// V[0] = mu0 + (r->n - r->n0); //we need to satisfy (get_n(G) == n) and }
void Targets::read_file_wang(string filename) { ifstream file (filename.c_str()); if(!file.is_open()) { printf("Error: Could not open file '%s'!\n",filename.c_str()); return; } string line; while(file) { getline(file, line); if(line.substr(0,1) != "#" && line.size() > 4) { string temp_key = line.substr(0,4); float temp_mlogKi = atof(line.substr(5,11).c_str()); float temp_resolution = atof(line.substr(14,18).c_str()); int temp_no_rotor = atoi(line.substr(19,21).c_str()); float temp_G = -log_conversion*R*T*temp_mlogKi; keys.push_back(temp_key); mlogKis.push_back(temp_mlogKi); resolutions.push_back(temp_resolution); no_rotors.push_back(temp_no_rotor); Gs.push_back(temp_G); } }//end while file.close(); printf("key -logKi resolution #rotor \n"); for(unsigned int i=0; i<keys.size();i++) printf("%s %f %f %d\n",keys[i].c_str(),mlogKis[i],resolutions[i],no_rotors[i]); printf("Affinity data for use in database - wang (temp)\n"); for(unsigned int i=0; i<keys.size();i++) printf("%-4s -1 %8.3f\n", keys[i].c_str(), get_G(keys[i])); /* printf("Decoy Data for use in database (temp)\n"); for(unsigned int i=0; i<keys.size();i++) for(unsigned int d=1; d<=101; d++) printf("%-4s %4d %8.3f\n", keys[i].c_str(), d, get_decoy_G(keys[i], get_rmsd(keys[i], d))); */ /* printf("%-4s %-4d %8f %8f\n", keys[i].c_str(), d, get_decoy_G(keys[i], get_rmsd(keys[i], d)), get_rmsd(keys[i], d)); */ }
int main(int argc, char *argv[]) { int ret,ret2; unsigned int errors,uerrors,errors2,crc_misses,iterations,trials,trials2,block_length,errors3,trials3; double SNR,sigma,rate=.5; unsigned char qbits,mcs; char done0=0; char done1=1; char done2=1; unsigned short iind; unsigned int coded_bits; unsigned char NB_RB=25; int num_pdcch_symbols = 3; int subframe = 6; randominit(0); logInit(); lte_param_init(1,1,1,0,0,3); PHY_vars_eNB->dlsch_eNB[0][0] = new_eNB_dlsch(1,8,0); PHY_vars_UE->dlsch_ue[0][0] = new_ue_dlsch(1,8,0); PHY_vars_eNB->dlsch_eNB[0][1] = new_eNB_dlsch(1,8,0); PHY_vars_UE->dlsch_ue[0][1] = new_ue_dlsch(1,8,0); if (argc>1) mcs = atoi(argv[1]); else mcs = 0; printf("NB_RB %d\n",NB_RB); DLSCH_alloc_pdu2.rah = 0; DLSCH_alloc_pdu2.rballoc = DLSCH_RB_ALLOC; DLSCH_alloc_pdu2.TPC = 0; DLSCH_alloc_pdu2.dai = 0; DLSCH_alloc_pdu2.harq_pid = 0; DLSCH_alloc_pdu2.tb_swap = 0; DLSCH_alloc_pdu2.mcs1 = mcs; DLSCH_alloc_pdu2.ndi1 = 1; DLSCH_alloc_pdu2.rv1 = 0; if (argc>2) qbits = atoi(argv[2]); else qbits = 4; printf("Quantization bits %d\n",qbits); generate_eNB_dlsch_params_from_dci(subframe, &DLSCH_alloc_pdu2, 0x1234, format2_2A_M10PRB, PHY_vars_eNB->dlsch_eNB[0], &PHY_vars_eNB->lte_frame_parms, SI_RNTI, 0, P_RNTI, 0); //change this later generate_ue_dlsch_params_from_dci(subframe, &DLSCH_alloc_pdu2, C_RNTI, format2_2A_M10PRB, PHY_vars_UE->dlsch_ue[0], &PHY_vars_UE->lte_frame_parms, SI_RNTI, 0, P_RNTI); coded_bits = get_G(&PHY_vars_eNB->lte_frame_parms,NB_RB,PHY_vars_eNB->dlsch_eNB[0][0]->rb_alloc, get_Qm(mcs),num_pdcch_symbols,subframe); printf("Coded_bits (G) = %d\n",coded_bits); block_length = dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1]>>3; printf("Block_length = %d bytes (%d bits, rate %f), mcs %d, I_TBS %d, NB_RB %d\n",block_length, dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1],(double)dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1]/coded_bits, mcs,get_I_TBS(mcs),NB_RB); // Test Openair0 3GPP encoder /* test_encoder(block_length, f1f2mat[(block_length-5)*2], // f1 (see 36121-820, page 14) f1f2mat[((block_length-5)*2)+1], // f2 (see 36121-820, page 14) 3); */ // exit(0); for (SNR=-6;SNR<16;SNR+=.5) { // printf("\n\nSNR %f dB\n",SNR); sigma = pow(10.0,-.05*SNR); errors=0; crc_misses=0; errors2=0; errors3=0; iterations=0; if (done0 == 0) { ret = test_logmap8(PHY_vars_eNB->dlsch_eNB[0][0], PHY_vars_UE->dlsch_ue[0][0], coded_bits, NB_RB, sigma, // noise standard deviation qbits, block_length, // block length bytes NTRIALS, &errors, &trials, &uerrors, &crc_misses, &iterations, num_pdcch_symbols, subframe); if (ret>=0) // printf("ref: Errors %d (%f), Uerrors %d (%f), CRC Misses %d (%f), Avg iterations %f\n",errors,(double)errors/trials,uerrors,(double)uerrors/trials,crc_misses,(double)crc_misses/trials,(double)iterations/trials); printf("%f,%f,%f,%f\n",SNR,(double)errors/trials,(double)crc_misses/trials,(double)iterations/trials); if (((double)errors/trials) < 1e-2) done0=1; } /* if (done1 == 0) { printf("exmimo\n"); ret = test_logmapexmimo(rate, // code rate sigma, // noise standard deviation qbits, block_length, // block length bytes f1f2mat[iind*2], // f1 (see 36121-820, page 14) f1f2mat[(iind*2)+1], // f2 (see 36121-820, page 14) 3, NTRIALS, &errors3, &trials3); if (ret>=0) printf("exmimo : Errors %d (%f)\n",errors3,(double)errors3/trials3); if (((double)errors3/trials3) < 1e-3) done1=1; } if (done2 == 0) { printf("Viterbi ...\n"); ret2 = test_viterbi(sigma, 8*block_length, NTRIALS, &errors2, &trials2, rate); if (ret2>=0) printf("viterbi : Errors %d (%f)\n",errors2,(double)errors2/trials2); if (((double)errors2/trials2) < 1e-3) done2=1; } */ if ((done0==1) && (done1==1) && (done2==1)) { printf("done\n"); break; } } return(0); }
memcpy(phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->b, a, phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->TBS>>3); LOG_D(PHY, "[eNB %d] dlsch_encoding_emul pmch , tbs is %d \n", phy_vars_eNB->Mod_id, phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->TBS>>3); memcpy(&eNB_transport_info[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id].transport_blocks[eNB_transport_info_TB_index[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]], a, phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->TBS>>3); eNB_transport_info_TB_index[phy_vars_eNB->Mod_id][phy_vars_eNB->CC_id]+= phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->TBS>>3;//=eNB_transport_info[phy_vars_eNB->Mod_id].tbs[0]; } else { G = get_G(&phy_vars_eNB->lte_frame_parms, phy_vars_eNB->lte_frame_parms.N_RB_DL, phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->rb_alloc, get_Qm(phy_vars_eNB->dlsch_eNB_MCH->harq_processes[0]->mcs),1, 2,phy_vars_eNB->proc[sched_subframe].frame_tx,subframe); generate_mbsfn_pilot(phy_vars_eNB, phy_vars_eNB->lte_eNB_common_vars.txdataF[0], AMP, subframe); if (dlsch_encoding(a, &phy_vars_eNB->lte_frame_parms, 1, phy_vars_eNB->dlsch_eNB_MCH, phy_vars_eNB->proc[sched_subframe].frame_tx, subframe, &phy_vars_eNB->dlsch_rate_matching_stats,
// void compute_drop( lattice_ptr lattice) // // Compute the width and height of the drop. (SCMP) // void compute_drop( lattice_ptr lattice, int output_to_file, int jbase, double rho_cut, int header) { int i, j; double rho; const double rho_v=85.7042; const double rho_l=524.3905; const double psi_v = 4.*exp(-200./(rho_v)); const double psi_l = 4.*exp(-200./(rho_l)); const double psi_cut=(psi_v+psi_l)/2.; //const double rho_cut=(rho_v+rho_l)/2.; //const double rho_cut= -200./log(.25*psi_cut); //const double rho_cut=450.; //const double rho_cut=100.; double i1, i2, icut_left, icut_right; double j1, j2, jcut; double rho1, rho2; // INPUTE PARAM NOW: const int jbase = 4; // jbase frame_rate theta_low theta theta_high // ----- ---------- ---------- ---------- ---------- // 1 100 91.909683 93.327450 94.732496 // 1 1000 90.947016 92.357518 93.755755 // 2 100 90.962932 92.396963 93.818305 // 2 1000 90.000000 91.426377 92.840531 // 3 100 89.037068 90.479460 91.909683 // 3 1000 89.037068 90.479460 91.909683 // 4 100 88.057956 89.516494 90.962932 // 4 1000 88.057956 89.516494 90.962932 const double rho_min=100.; //const double rho_min=rho_v; //psi(rho_l)=4.*exp(-200/524.3905) //psi(rho_v)=4.*exp(-200/85.7042) int width=0, width_temp=0, max_width=0, max_width_j=0; int height=0; double theta; double max_rho=0.; int imax; int imax1; int imax2; double G = get_G( lattice); double Gads = get_Gads( lattice, /*subs*/0); jcut = -1.; // Flag value. // Start at about 3/4 the height of the domain to skip over any condensing // blobs on the ceiling. Main drop being measured should not be that high. for( j=(int)floor((3./4.)*get_LY(lattice)); j>0; j--) { max_rho=0.; for( i=0; i<get_LX( lattice); i++) { rho = get_rho(lattice,i,/*j=*/j,/*subs=*/0); if( max_rho < fabs(rho)) { max_rho = fabs(rho); imax = i; } } if( /*row j crosses the drop*/ max_rho > rho_min) { if( max_rho > rho_cut && jcut < 0.) { // rho1 was assigned max_rho from row j-1. // j1 was assigned max_rho from row j-1. rho2 = max_rho; imax2 = imax; j2 = j; // Linear interpolation of jcut: jcut = j1 + ((j2-j1)/(rho2-rho1))*( rho_cut - rho1); } if( j>=jbase) { if( max_rho >= rho_cut){ height++;} width_temp=0; icut_left = -1; icut_right = -1; for( i=0; i<get_LX(lattice); i++) { rho = get_rho(lattice,i,j,/*subs=*/0); if( rho > rho_cut) { if( icut_left < 0. ) { // i1 and rho1 were set at i-1. rho2 = rho; i2 = i; // Linear interpolation of icut_left: icut_left = i1 + ((i2-i1)/(rho2-rho1))*( rho_cut - rho1); } else { rho1 = rho; i1 = i; /*save for interp of icut_right*/} width_temp++; } else { if( icut_left < 0.) { i1 = i; rho1 = rho; /*save for interp of icut_left*/ } else { if( icut_right < 0.) { // i1 and rho1 were set at i-1. rho2 = rho; i2 = i; // Linear interpolation of icut_right: icut_right = i1 + ((i2-i1)/(rho2-rho1))*( rho_cut - rho1); } } } } if( width_temp > 0) { width = width_temp; if( max_width < width) { max_width = width; max_width_j = j;} } } } else { rho1 = max_rho; // save rho1 to use for interpolation of jcut. imax1 = imax; j1 = j; } } //for( i=0; i<get_LX( lattice); i++) //{ // printf("%f ",get_rho(lattice,i,/*j=*/max_width_j,/*subs=*/0)); //} if(/*verbose*/0) { printf("\n"); printf("jbase = %d\n", jbase); printf("width=%d, height=%d, ", width, height); printf("width/height=%f, ", (double)width/(double)height); printf("max_width=%d at j=%d, ", max_width, max_width_j); theta = theta_of_height_width( jcut-jbase, icut_right-icut_left); printf("%f = %f^o ", theta, theta*(180./PI)); theta = theta_of_height_width( height-1, width+1); printf("theta_low = %f = %f^o, ", theta, theta*(180./PI)); theta = theta_of_height_width( height, width); printf("theta = %f = %f^o, ", theta, theta*(180./PI)); theta = theta_of_height_width( height+1, width-1); printf("theta_high = %f = %f^o, ", theta, theta*(180./PI)); theta = acos( ( ( psi_v - Gads/G) - ( Gads/G - psi_l) )/(psi_v-psi_l)); printf("theta_predicted_youngs = %f = %f^o ", theta, theta*(180./PI)); //theta = PI*( ( Gads/G - psi_l) / ( psi_v - psi_l)); //printf("theta_predicted_combination = %f = %f^o ", theta, theta*(180./PI)); printf("\n"); printf("rho_cut = %f\n", rho_cut); printf("(icut_left,icut_right,jcut) = ( %9.6f, %9.6f, %9.6f); " "(imax1,imax2)=(%d,%d); (icut_left+icut_right)/2 = %9.6f\n", icut_left, icut_right, jcut, imax1, imax2,(icut_left+icut_right)/2.); printf("psi(rho_cut) = %f\n", 4.*exp(-200./rho_cut)); printf("psi(rho_v) = %f\n", 4.*exp(-200./85.7042)); printf("psi(rho_l) = %f\n", 4.*exp(-200./524.3905)); printf("psi((rho_l+rho_v)/2.) = %f\n", 4.*exp(-200./((85.7042+524.3905)/2.))); printf("(psi(rho_v)+psi(rho_l))/2. = %f\n", (4.*exp(-200./85.7042)+4.*exp(-200./524.3905))/2.); rho = 212.36; printf("psi(%f) = %f\n", rho, 4.*exp(-200./rho)); } else { if( header) { printf("\n"); printf( " DROP " " jbase" " rho_cut" " width" " height" " theta pixelated" " theta interpolated" " theta predicted" "\n"); printf( " DROP " " ---------------------" " ---------------------" " ---------------------" " ---------------------" " ---------------------" " ---------------------" " ---------------------" "\n"); } printf(" DROP "); printf(" %21.17f", (double)jbase); printf(" %21.17f", rho_cut); printf(" %21.17f", icut_right-icut_left); printf(" %21.17f", jcut - jbase); theta = theta_of_height_width( height, width); printf(" %21.17f", theta*(180/PI)); theta = theta_of_height_width( jcut-jbase, icut_right-icut_left); printf(" %21.17f", theta*(180/PI)); theta = acos( ( ( psi_v - Gads/G) - ( Gads/G - psi_l) )/(psi_v-psi_l)); printf(" %21.17f", theta*(180/PI)); printf("\n"); } if( output_to_file) { FILE *o; o = fopen( "compute_drop.dat", "a+"); fprintf( o, "%d ", get_NumFrames( lattice)); fprintf( o, "%d ", get_FrameRate( lattice)); fprintf( o, "%8.4f ", get_G( lattice)); fprintf( o, "%8.4f ", get_Gads( lattice, /*subs*/0)); fprintf( o, "%d ", jbase); fprintf( o, "%d ", width); fprintf( o, "%d ", height); theta = theta_of_height_width( jcut-jbase, icut_right-icut_left); fprintf( o, "%20.17f ", theta*(180./PI)); theta = theta_of_height_width( height-1, width+1); fprintf( o, "%20.17f ", theta*(180./PI)); theta = theta_of_height_width( height, width); fprintf( o, "%20.17f ", theta*(180./PI)); theta = theta_of_height_width( height+1, width-1); fprintf( o, "%20.17f ", theta*(180./PI)); theta = acos( ( ( psi_v - Gads/G) - ( Gads/G - psi_l) )/(psi_v-psi_l)); //fprintf( o, "acos(%20.17f) = ", ( ( psi_v - Gads/G) - ( Gads/G - psi_l) )/(psi_v-psi_l)); fprintf( o, "%20.17f ", theta*(180./PI)); //theta = PI*( ( Gads/G - psi_l) / ( psi_v - psi_l)); //fprintf( o, "%20.17f ", theta*(180./PI)); fprintf( o, "\n"); fclose(o); } //4.*exp(-200/524.3905) //4.*exp(-200/85.7042) } /* void compute_drop( lattice_ptr lattice, bool output_to_file) */
int dlsch_encoding(unsigned char *a, LTE_DL_FRAME_PARMS *frame_parms, u8 num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch, u8 subframe) { unsigned short offset; unsigned int G; unsigned int crc=1; unsigned short iind; unsigned short nb_rb = dlsch->nb_rb; unsigned char harq_pid = dlsch->current_harq_pid; unsigned int A; unsigned char mod_order; unsigned int Kr,Kr_bytes,r,r_offset=0; A = dlsch->harq_processes[harq_pid]->TBS; mod_order = get_Qm(dlsch->harq_processes[harq_pid]->mcs); G = get_G(frame_parms,nb_rb,dlsch->rb_alloc,mod_order,num_pdcch_symbols,subframe); if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet /* printf("dlsch (tx): \n"); for (i=0;i<4;i++) printf("%x ",a[i]); printf("\n"); */ // Add 24-bit crc (polynomial A) to payload crc = crc24a(a, A)>>8; a[A>>3] = ((u8*)&crc)[2]; a[1+(A>>3)] = ((u8*)&crc)[1]; a[2+(A>>3)] = ((u8*)&crc)[0]; dlsch->harq_processes[harq_pid]->B = A+24; dlsch->harq_processes[harq_pid]->b = a; lte_segmentation(dlsch->harq_processes[harq_pid]->b, dlsch->harq_processes[harq_pid]->c, dlsch->harq_processes[harq_pid]->B, &dlsch->harq_processes[harq_pid]->C, &dlsch->harq_processes[harq_pid]->Cplus, &dlsch->harq_processes[harq_pid]->Cminus, &dlsch->harq_processes[harq_pid]->Kplus, &dlsch->harq_processes[harq_pid]->Kminus, &dlsch->harq_processes[harq_pid]->F); for (r=0;r<dlsch->harq_processes[harq_pid]->C;r++) { if (r<dlsch->harq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; else Kr = dlsch->harq_processes[harq_pid]->Kplus; Kr_bytes = Kr>>3; // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) if (Kr_bytes<=64) iind = (Kr_bytes-5); else if (Kr_bytes <=128) iind = 59 + ((Kr_bytes-64)>>1); else if (Kr_bytes <= 256) iind = 91 + ((Kr_bytes-128)>>2); else if (Kr_bytes <= 768)
/** RX_PDSCH Decoding Thread */ static void * rx_pdsch_thread(void *param) { //unsigned long cpuid; uint8_t rx_pdsch_thread_index = 0; uint8_t dlsch_thread_index = 0; uint8_t pilot1,pilot2,pilot3,harq_pid,subframe; // uint8_t last_slot; uint8_t dual_stream_UE = 0; uint8_t i_mod = 0; RTIME time_in,time_out; #ifdef RTAI RT_TASK *task; #endif int m,eNB_id = 0; int eNB_id_i = 1; PHY_VARS_UE *UE = PHY_vars_UE_g[0]; #ifdef RTAI task = rt_task_init_schmod(nam2num("RX_PDSCH_THREAD"), 0, 0, 0, SCHED_FIFO, 0xF); if (task==NULL) { LOG_E(PHY,"[SCHED][RX_PDSCH] Problem starting rx_pdsch thread!!!!\n"); return 0; } else { LOG_I(PHY,"[SCHED][RX_PDSCH] rx_pdsch_thread started for with id %p\n",task); } #endif mlockall(MCL_CURRENT | MCL_FUTURE); //rt_set_runnable_on_cpuid(task,1); //cpuid = rtai_cpuid(); #ifdef HARD_RT rt_make_hard_real_time(); #endif if (UE->lte_frame_parms.Ncp == 0) { // normal prefix pilot1 = 4; pilot2 = 7; pilot3 = 11; } else { // extended prefix pilot1 = 3; pilot2 = 6; pilot3 = 9; } while (!oai_exit){ vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_THREAD, 0); if (pthread_mutex_lock(&rx_pdsch_mutex) != 0) { LOG_E(PHY,"[SCHED][RX_PDSCH] error locking mutex.\n"); } else { while (rx_pdsch_instance_cnt < 0) { pthread_cond_wait(&rx_pdsch_cond,&rx_pdsch_mutex); } if (pthread_mutex_unlock(&rx_pdsch_mutex) != 0) { LOG_E(PHY,"[SCHED][RX_PDSCH] error unlocking mutex.\n"); } } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_THREAD, 1); // last_slot = rx_pdsch_slot; subframe = UE->slot_rx>>1; // Important! assumption that PDCCH procedure of next SF is not called yet harq_pid = UE->dlsch_ue[eNB_id][0]->current_harq_pid; UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->G = get_G(&UE->lte_frame_parms, UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->nb_rb, UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->rb_alloc, get_Qm(UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs), UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->Nl, UE->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols, UE->frame_rx,subframe); if ((UE->transmission_mode[eNB_id] == 5) && (UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->dl_power_off==0) && (openair_daq_vars.use_ia_receiver > 0)) { dual_stream_UE = 1; eNB_id_i = UE->n_connected_eNB; if (openair_daq_vars.use_ia_receiver == 2) { i_mod = get_Qm(((UE->frame_rx%1024)/3)%28); } else { i_mod = get_Qm(UE->dlsch_ue[eNB_id][0]->harq_processes[harq_pid]->mcs); } } else { dual_stream_UE = 0; eNB_id_i = eNB_id+1; i_mod = 0; } if (oai_exit) break; LOG_D(PHY,"[SCHED][RX_PDSCH] Frame %d, slot %d: Calling rx_pdsch_decoding with harq_pid %d\n",UE->frame_rx,UE->slot_rx,harq_pid); time_in = rt_get_time_ns(); // Check if we are in even or odd slot if (UE->slot_rx%2) { // odd slots // measure time //time0 = rt_get_time_ns(); // rt_printk("[SCHED][RX_PDSCH][before rx_pdsch] Frame %d, slot %d, time %llu\n",UE->frame,last_slot,rt_get_time_ns()); for (m=pilot2;m<UE->lte_frame_parms.symbols_per_tti;m++) { rx_pdsch(UE, PDSCH, eNB_id, eNB_id_i, subframe, m, 0, dual_stream_UE, i_mod, harq_pid); } // time1 = rt_get_time_ns(); // rt_printk("[SCHED][RX_PDSCH] Frame %d, slot %d, start %llu, end %llu, proc time: %llu ns\n",UE->frame_rx,last_slot,time0,time1,(time1-time0)); dlsch_thread_index = harq_pid; if (pthread_mutex_lock (&dlsch_mutex[dlsch_thread_index]) != 0) { // Signal MAC_PHY Scheduler LOG_E(PHY,"[UE %d] ERROR pthread_mutex_lock\n",UE->Mod_id); // lock before accessing shared resource // vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); //return(-1); } dlsch_instance_cnt[dlsch_thread_index]++; dlsch_subframe[dlsch_thread_index] = subframe; pthread_mutex_unlock (&dlsch_mutex[dlsch_thread_index]); if (dlsch_instance_cnt[dlsch_thread_index] == 0) { if (pthread_cond_signal(&dlsch_cond[dlsch_thread_index]) != 0) { LOG_E(PHY,"[UE %d] ERROR pthread_cond_signal for dlsch_cond[%d]\n",UE->Mod_id,dlsch_thread_index); // vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); //return(-1); } } else { LOG_W(PHY,"[UE %d] DLSCH thread for dlsch_thread_index %d busy!!!\n",UE->Mod_id,dlsch_thread_index); // vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); //return(-1); } } else { // even slots for (m=UE->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols;m<pilot2;m++) { rx_pdsch(UE, PDSCH, eNB_id, eNB_id_i, subframe, m, (m==UE->lte_ue_pdcch_vars[eNB_id]->num_pdcch_symbols)?1:0, // first_symbol_flag dual_stream_UE, i_mod, harq_pid); } } time_out = rt_get_time_ns(); if (pthread_mutex_lock(&rx_pdsch_mutex) != 0) { msg("[openair][SCHED][RX_PDSCH] error locking mutex.\n"); } else { rx_pdsch_instance_cnt--; if (pthread_mutex_unlock(&rx_pdsch_mutex) != 0) { msg("[openair][SCHED][RX_PDSCH] error unlocking mutex.\n"); } } } #ifdef HARD_RT rt_make_soft_real_time(); #endif LOG_D(PHY,"[openair][SCHED][RX_PDSCH] RX_PDSCH thread exiting\n"); return 0; }
void mexFunction( int mlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { /* Declare */ short *dlsch_llr; unsigned char mcs; unsigned int *ret; unsigned char mod_order; unsigned char num_pdcch_symbols; unsigned char harq_pid; unsigned char subframe; unsigned char Kmimo; unsigned char Mdlharq; unsigned char abstraction_flag; LTE_UE_DLSCH_t* dlsch; LTE_DL_FRAME_PARMS *frame_parms; PHY_VARS_UE *phy_vars_ue; extern int *pi2tab16[188],*pi5tab16[188],*pi4tab16[188],*pi6tab16[188]; unsigned long *ptr_td; //Specific Modification for 64bit int *tmp[1]; /* Allocate input */ dlsch_llr = (short*) mxGetData(prhs[0]); /* Create new dlsch */ Kmimo = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Kmimo")); Mdlharq = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Mdlharq")); abstraction_flag = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"abstraction_flag")); mcs = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"mcs")); #ifdef DEBUG_DLSCH_DECODING mexPrintf("Kmimo %d\n",Kmimo); mexPrintf("Mdlharq %d\n",Mdlharq); mexPrintf("abstraction_flag %d\n",abstraction_flag); mexPrintf("mcs %d\n",mcs); #endif /* Create new dlsch */ dlsch = new_ue_dlsch(Kmimo,Mdlharq,8,25,abstraction_flag); // Init CRC tables crcTableInit(); // init_td(); // copy the pointers to memory allocated in dlsch_decoding_init ptr_td = (unsigned int*) mxGetData(mxGetField(prhs[1],0,"ptr_td")); #ifdef DEBUG_DLSCH_DECODING mexPrintf("ptr_td0 %p\n",ptr_td[0]); mexPrintf("ptr_td1 %p\n",ptr_td[1]); mexPrintf("ptr_td2 %p\n",ptr_td[2]); mexPrintf("ptr_td3 %p\n",ptr_td[3]); #endif memcpy(&tmp[0], &ptr_td[0], sizeof(ptr_td[0])); memcpy(&pi2tab16[0], tmp[0], 188*sizeof(pi2tab16[0])); memcpy(&tmp[0], &ptr_td[1], sizeof(ptr_td[1])); memcpy(&pi4tab16[0], tmp[0], 188*sizeof(pi4tab16[0])); memcpy(&tmp[0], &ptr_td[2], sizeof(ptr_td[2])); memcpy(&pi5tab16[0], tmp[0], 188*sizeof(pi5tab16[0])); memcpy(&tmp[0], &ptr_td[3], sizeof(ptr_td[3])); memcpy(&pi6tab16[0], tmp[0], 188*sizeof(pi6tab16[0])); harq_pid = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"harq_pid")); dlsch->current_harq_pid = harq_pid; dlsch->harq_processes[harq_pid]->rvidx = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"rvidx")); dlsch->harq_processes[harq_pid]->Nl = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Nl")); //dlsch->harq_processes[harq_pid]->Ndi = (unsigned char) mxGetScalar(mxGetField(prhs[2],0,"Ndi")); dlsch->harq_processes[harq_pid]->mcs = mcs; dlsch->harq_processes[harq_pid]->rb_alloc[0] = (unsigned int) mxGetScalar(mxGetField(prhs[1],0,"rb_alloc")); dlsch->harq_processes[harq_pid]->nb_rb = (unsigned short) mxGetScalar(mxGetField(prhs[1],0,"nb_rb")); dlsch->harq_processes[harq_pid]->TBS = dlsch_tbs25[get_I_TBS(mcs)][dlsch->harq_processes[harq_pid]->nb_rb-1]; num_pdcch_symbols = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"num_pdcch_symbols")); subframe = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"subframe")); phy_vars_ue = calloc(1,sizeof(PHY_VARS_UE)); // Create a LTE_DL_FRAME_PARMS structure and assign required params frame_parms = calloc(1,sizeof(LTE_DL_FRAME_PARMS)); frame_parms->N_RB_DL = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"nb_rb")); frame_parms->frame_type = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"frame_type")); frame_parms->mode1_flag = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"mode1_flag")); frame_parms->Ncp = (unsigned char) mxGetScalar(mxGetField(prhs[1],0,"Ncp")); mod_order = get_Qm(dlsch->harq_processes[harq_pid]->mcs); dlsch->harq_processes[harq_pid]->G = get_G(frame_parms,dlsch->harq_processes[harq_pid]->nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,0,subframe); #ifdef DEBUG_DLSCH_DECODING mexPrintf("TBS %d\n",dlsch->harq_processes[harq_pid]->TBS); mexPrintf("nb_rb %d\n",dlsch->harq_processes[harq_pid]->nb_rb); mexPrintf("ncs %d\n",dlsch->harq_processes[harq_pid]->mcs); mexPrintf("num_pdcch_symbols %d\n",num_pdcch_symbols); mexPrintf("subframe %d\n",subframe); mexPrintf("G %d\n",dlsch->harq_processes[harq_pid]->G); #endif if (dlsch->harq_processes[harq_pid]->G != mxGetM(prhs[0])) { free_ue_dlsch(dlsch); free(frame_parms); free(phy_vars_ue); mexErrMsgTxt("Length of the LLR vector is incorrect."); } /* Allocate Output */ plhs[0] = mxCreateNumericMatrix(1, 1, mxUINT32_CLASS, mxREAL); ret = (unsigned int*) mxGetPr(plhs[0]); /* Algo */ *ret = dlsch_decoding(phy_vars_ue, dlsch_llr, frame_parms, dlsch, dlsch->harq_processes[harq_pid], subframe, dlsch->current_harq_pid, 1,0); /* free dlsch */ free_ue_dlsch(dlsch); free(frame_parms); free(phy_vars_ue); // free_td(); }
bool IASIAM::Run_CHM(IAResult* r) //output { this->r = r; N = r->iagrid->get_N(); iagrid = r->iagrid; epsilon = 0; printf(" ------- IASIAM for CHM: n=%.3f, U=%.3f, T=%.3f, epsilon=%.3f -------\n", r->n, U, T, epsilon); //----------------- CALCULATION ----------------------// if (PHSymmetricCase) { mu0 = 0.0; get_G0(); } else { complex<double>* V = new complex<double>[1]; //------initial guess---------// V[0] = r->mu0; //initial guess is always the last mu0. in first DMFT iteration it is 0 //---------------------------// printf(" IASIAM: about to calc mu0. at the moment: mu0 = %.3f mu=%.3f\n",r->mu0, r->mu); double initGuesses [] = {-1.0, 1.0, 0.3, -0.3, 0.1, -0.1, -0.8, 0.8, -0.6, 0.6, -0.7, 0.7, -3.0, 3.0, 0.9, -0.9, 0.05, -0.05, 0.5, -0.5, 0.2, -0.2, 2.0, -2.0}; bool converged = false; int i; for (i=0; ( (i<sizeof(initGuesses)/sizeof(double)) and (i<max_tries) ); i++) { printf("------ IASIAM: trying with init guess: %f\n",real(V[0])); converged = UseBroyden<IASIAM>(1, 50, 1e-8, &IASIAM::get_G0, this, V); if (converged) break; else V[0] = initGuesses[i]; } if ((i==max_tries)and(!converged)) { V[0] = initGuesses[0]; Amoeba(Accr, V, &IASIAM::get_G0); } delete [] V; } r->mu0 = mu0; //PrintFunc("G0", N, r->G0, r->omega); printf(" mu0 = %f\n", mu0); fft->FtoT(r->G0, r->G0_tau); get_SOCSigma_tau(); fft->TtoF(r->SOCSigma_tau, r->SOCSigma); if (PHSymmetricCase) { r->mu = 0.5*U; r->n=0.5; get_G(); } else { complex<double>* V = new complex<double>[1]; V[0] = r->mu; double initGuesses [] = {-1.0, 1.0, -0.8, 0.8, -0.6, 0.6, 0.2, -0.2, 2.0, -2.0}; bool converged = false; int i; for (i=0; ( (i<sizeof(initGuesses)/sizeof(double)) and (i<max_tries) ); i++) { printf("------ IASIAM: trying with init guess: %f\n",real(V[0])); converged = UseBroyden<IASIAM>(1, MAX_ITS, 1e-8, &IASIAM::get_G, this, V); if (converged){ break; } else V[0] = initGuesses[i]; } if ((i==max_tries)and(!converged)) { V[0] = initGuesses[0]; Amoeba(Accr, V, &IASIAM::get_G); } delete [] V; } printf(" mu = %f\n", r->mu); //-----------------------------------------------------// return false; }
int dlsch_encoding(unsigned char *a, LTE_DL_FRAME_PARMS *frame_parms, uint8_t num_pdcch_symbols, LTE_eNB_DLSCH_t *dlsch, int frame, uint8_t subframe, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *i_stats) { unsigned int G; unsigned int crc=1; unsigned short iind; unsigned char harq_pid = dlsch->current_harq_pid; unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; unsigned int A; unsigned char mod_order; unsigned int Kr=0,Kr_bytes,r,r_offset=0; unsigned short m=dlsch->harq_processes[harq_pid]->mcs; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); A = dlsch->harq_processes[harq_pid]->TBS; //6228 // printf("Encoder: A: %d\n",A); mod_order = get_Qm(dlsch->harq_processes[harq_pid]->mcs); G = get_G(frame_parms,nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,frame,subframe); // if (dlsch->harq_processes[harq_pid]->Ndi == 1) { // this is a new packet if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet /* int i; printf("dlsch (tx): \n"); for (i=0;i<(A>>3);i++) printf("%02x.",a[i]); printf("\n"); */ // Add 24-bit crc (polynomial A) to payload crc = crc24a(a, A)>>8; a[A>>3] = ((uint8_t*)&crc)[2]; a[1+(A>>3)] = ((uint8_t*)&crc)[1]; a[2+(A>>3)] = ((uint8_t*)&crc)[0]; // printf("CRC %x (A %d)\n",crc,A); dlsch->harq_processes[harq_pid]->B = A+24; // dlsch->harq_processes[harq_pid]->b = a; memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, dlsch->harq_processes[harq_pid]->c, dlsch->harq_processes[harq_pid]->B, &dlsch->harq_processes[harq_pid]->C, &dlsch->harq_processes[harq_pid]->Cplus, &dlsch->harq_processes[harq_pid]->Cminus, &dlsch->harq_processes[harq_pid]->Kplus, &dlsch->harq_processes[harq_pid]->Kminus, &dlsch->harq_processes[harq_pid]->F)<0) return(-1); for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { if (r<dlsch->harq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; else Kr = dlsch->harq_processes[harq_pid]->Kplus; Kr_bytes = Kr>>3; // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) if (Kr_bytes<=64) iind = (Kr_bytes-5); else if (Kr_bytes <=128) iind = 59 + ((Kr_bytes-64)>>1); else if (Kr_bytes <= 256) iind = 91 + ((Kr_bytes-128)>>2); else if (Kr_bytes <= 768)
bool SIAM::Run_CHM(double n, complex<double>* Delta, //input complex<double>* G_out, complex<double>* Sigma_out, double &mu_out) //output { if (!Initialized) exit(1); Clipped = false; for (int i=0; i<N; i++) if (ClipOff(Delta[i])) Clipped = true; if (Clipped) printf(" !!! Clipping Delta !!!\n"); this->n = n; this->Delta = Delta; //PrintFunc("DeltaSiam",N,Delta,omega); this->epsilon = 0; if (n==0.5) HalfFilling = true; else HalfFilling = false; printf(" ------- SIAM for CHM: n=%.3f, U=%.3f, T=%.3f, epsilon=%.3f -------\n", n, U, T, epsilon); if (HalfFilling) { mu = 0.5*U; mu0 = 0.0; MPT_B = 0.0; MPT_B0 = 0.0; SymmetricCase = true; } //------initial guess---------// complex<double>* V = new complex<double>[1]; V[0] = mu0; //initial guess is always the last mu0. in first DMFT iteration it is 0 //---------------------------// printf(" MPT: B = %fe, B0 = %fe\n", MPT_B, MPT_B0); //----------------- CALCULATION ----------------------// if (HalfFilling)//and (SymmetricCase)) get_G0(); else UseBroyden<SIAM>(1, MAX_ITS, Accr, &SIAM::get_G0, this, V); printf(" mu0 = %f\n", mu0); printf("Integral G0: %.6f\n",imag(TrapezIntegral(N,G0,omega))); get_As(); get_Ps(); get_SOCSigma(); V[0] = mu; if (HalfFilling)//and (SymmetricCase)) { if (IsBethe) { get_Sigma(); get_G(); //get_G() !!!! samo proba // printf(" Integral G = %.6f\n",imag(TrapezIntegral(N,G,omega))); } else get_G_CHM(); } else { if (IsBethe) UseBroyden<SIAM>(1, MAX_ITS, Accr, &SIAM::get_G, this, V); else UseBroyden<SIAM>(1, MAX_ITS, Accr, &SIAM::get_G_CHM, this, V); } MPT_B = get_MPT_B(); MPT_B0 = get_MPT_B0(); printf(" mu = %f\n", mu); delete [] V; //-----------------------------------------------------// //output spectral weight if optioned if (CheckSpectralWeight) { printf(" Spectral weight G: %fe\n", -imag(TrapezIntegral(N,G,omega))/pi); printf(" Spectral weight G0: %fe\n", -imag(TrapezIntegral(N,G0,omega))/pi); } //-------- OUTPUT ---------// for (int i=0; i<N; i++) { G_out[i] = G[i]; Sigma_out[i] = Sigma[i]; } mu_out = mu; //-------------------------// // printf(" PROVERA: n = %f, U = %f \n",n, U); return Clipped; }
int main(int argc, char *argv[]) { int ret,ret2; unsigned int errors,uerrors,errors2,crc_misses,iterations,trials,trials2,block_length,errors3,trials3; double SNR,sigma,rate=.5; unsigned char qbits,mcs; char done0=0; char done1=1; char done2=1; unsigned int coded_bits; unsigned char NB_RB=25; int num_pdcch_symbols = 1; int subframe = 6; randominit(0); logInit(); lte_param_init(1,1,1,0,0,3); PHY_vars_eNB->dlsch_eNB[0][0] = new_eNB_dlsch(1,8,NB_RB,0); PHY_vars_UE->dlsch_ue[0][0] = new_ue_dlsch(1,8,4,NB_RB,0); PHY_vars_eNB->dlsch_eNB[0][1] = new_eNB_dlsch(1,8,NB_RB,0); PHY_vars_UE->dlsch_ue[0][1] = new_ue_dlsch(1,8,4,NB_RB,0); if (argc>1) mcs = atoi(argv[1]); else mcs = 0; printf("NB_RB %d\n",NB_RB); DLSCH_alloc_pdu.rah = 0; DLSCH_alloc_pdu.rballoc = DLSCH_RB_ALLOC; DLSCH_alloc_pdu.TPC = 0; DLSCH_alloc_pdu.dai = 0; DLSCH_alloc_pdu.harq_pid = 0; //DLSCH_alloc_pdu2.tb_swap = 0; DLSCH_alloc_pdu.mcs = mcs; DLSCH_alloc_pdu.ndi = 1; DLSCH_alloc_pdu.rv = 0; if (argc>2) qbits = atoi(argv[2]); else qbits = 4; printf("Quantization bits %d\n",qbits); generate_eNB_dlsch_params_from_dci(subframe, &DLSCH_alloc_pdu, 0x1234, format1, PHY_vars_eNB->dlsch_eNB[0], &PHY_vars_eNB->lte_frame_parms, PHY_vars_eNB->pdsch_config_dedicated, SI_RNTI, 0, P_RNTI, 0); //change this later generate_ue_dlsch_params_from_dci(subframe, &DLSCH_alloc_pdu, C_RNTI, format1, PHY_vars_UE->dlsch_ue[0], &PHY_vars_UE->lte_frame_parms, PHY_vars_UE->pdsch_config_dedicated, SI_RNTI, 0, P_RNTI); coded_bits = get_G(&PHY_vars_eNB->lte_frame_parms, PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->nb_rb, PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->rb_alloc, get_Qm(mcs), 1, num_pdcch_symbols, 0, subframe); printf("Coded_bits (G) = %d\n",coded_bits); block_length = dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1]>>3; printf("Block_length = %d bytes (%d bits, rate %f), mcs %d, I_TBS %d, F %d, NB_RB %d\n",block_length, dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1],(double)dlsch_tbs25[get_I_TBS(mcs)][NB_RB-1]/coded_bits, mcs,get_I_TBS(mcs),PHY_vars_eNB->dlsch_eNB[0][0]->harq_processes[0]->F,NB_RB); for (SNR=-5; SNR<15; SNR+=.1) { sigma = pow(10.0,-.05*SNR); printf("\n\nSNR %f dB => sigma %f\n",SNR,sigma); errors=0; crc_misses=0; errors2=0; errors3=0; iterations=0; if (done0 == 0) { ret = test_logmap8(PHY_vars_eNB->dlsch_eNB[0][0], PHY_vars_UE->dlsch_ue[0][0], coded_bits, NB_RB, sigma, // noise standard deviation qbits, block_length, // block length bytes NTRIALS, &errors, &trials, &uerrors, &crc_misses, &iterations, num_pdcch_symbols, subframe); if (ret>=0) printf("%f,%f,%f,%f\n",SNR,(double)errors/trials,(double)crc_misses/trials,(double)iterations/trials); if (((double)errors/trials) < 1e-2) done0=1; } if ((done0==1) && (done1==1) && (done2==1)) { printf("done\n"); break; } } return(0); }
bool SIAM::Run_CHM(Result* r) //output { this->r = r; N = r->grid->get_N(); grid = r->grid; get_fermi(); Clipped = false; epsilon = 0; if (r->n==0.5) HalfFilling = true; else HalfFilling = false; printf(" ------- SIAM for CHM: n=%.3f, U=%.3f, T=%.3f, epsilon=%.3f -------\n", r->n, U, T, epsilon); if (HalfFilling) { r->mu = 0.5*U; mu0 = 0.0; MPT_B = 0.0; MPT_B0 = 0.0; SymmetricCase = true; } //------initial guess---------// complex<double>* V = new complex<double>[1]; V[0] = mu0; //initial guess is always the last mu0. in first DMFT iteration it is 0 //---------------------------// printf(" MPT: B = %fe, B0 = %fe\n", MPT_B, MPT_B0); //----------------- CALCULATION ----------------------// if (HalfFilling)//and (SymmetricCase)) get_G0(); else UseBroyden<SIAM>(1, MAX_ITS, Accr, &SIAM::get_G0, this, V); printf(" mu0 = %f\n", mu0); get_As(); get_Ps(); get_SOCSigma(); V[0] = r->mu; if (HalfFilling)//and (SymmetricCase)) { if (isBethe) { get_Sigma(); get_G(); } else get_G_CHM(); } else { if (isBethe) UseBroyden<SIAM>(1, MAX_ITS, Accr, &SIAM::get_G, this, V); else UseBroyden<SIAM>(1, MAX_ITS, Accr, &SIAM::get_G_CHM, this, V); } MPT_B = get_MPT_B(); MPT_B0 = get_MPT_B0(); printf(" mu = %f\n", r->mu); delete [] V; //-----------------------------------------------------// //output spectral weight if optioned if (CheckSpectralWeight) { printf(" n0: %.6f\n", get_n(r->G0)); printf(" n: %.6f\n", get_n(r->G)); } // fill in DOS #pragma omp parallel for for (int i=0; i<N; i++) r->DOS[i] = - imag(r->G[i]) / pi; r->mu0 = mu0; return false; }