// Perform LTE ratematching for convolutionally encoded bits d to fit // an e vector of length n_e. cvec lte_conv_ratematch( const cmat & d, const uint32 & n_e ) { const uint8 n_c=32; const uint32 n_r=ceil((double)d.cols()/n_c); ASSERT(d.rows()==3); // Subblock interleaving const static int perm_pattern_c[]={1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31,0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30}; const ivec perm_pattern(perm_pattern_c,32); cmat v(3,n_r*n_c); #ifndef NDEBUG v=NAN; #endif for (uint8 t=0;t<3;t++) { cvec temp_row=d.get_row(t); cvec temp_nan(n_r*n_c-d.cols()); temp_nan=NAN; temp_row=concat(temp_nan,temp_row); cmat y=transpose(reshape(temp_row,n_c,n_r)); // Permute the columns cmat y_perm(n_r,n_c); #ifndef NDEBUG y_perm=NAN; #endif for (uint8 k=0;k<32;k++) { y_perm.set_col(k,y.get_col(perm_pattern(k))); } // Assign v.set_row(t,cvectorize(y_perm)); } // Bit collection cvec w=cvectorize(transpose(v)); // Selection cvec e(n_e); #ifndef NDEBUG e=NAN; #endif uint32 k=0; uint32 j=0; while (k<n_e) { if (isfinite(w(j).real())) { e(k)=w(j); k++; } j=mod(j+1,3*n_r*n_c); } return e; }