gr_constellation_decoder_bc


※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

int
gr_constellation_decoder_cb::work(int noutput_items,
                                 gr_vector_const_void_star &input_items,
                                 gr_vector_void_star &output_items)
{
 gr_complex const *in = (const gr_complex *) input_items[0];
 unsigned char *out = (unsigned char *) output_items[0];
 unsigned int table_size = d_sym_value_out.size();
 unsigned int min_index = 0;
 float min_euclid_dist = 0;
 float euclid_dist = 0;
 double total_error = 0;

 for(int i = 0; i < noutput_items; i++){
   min_euclid_dist = norm(in[i] - d_sym_position[0]);
   min_index = 0;
   for (unsigned int j = 1; j < table_size; j++){
     euclid_dist = norm(in[i] - d_sym_position[j]);
     if (euclid_dist < min_euclid_dist){
       min_euclid_dist = euclid_dist;
       min_index = j;
     }
   }

   out[i] = d_sym_value_out[min_index];

   if (compute_EVM)
     total_error += sqrtf(min_euclid_dist);
 }

 if (compute_EVM){
   double mean = total_error / noutput_items;
   double rms = sqrt(mean * mean);
   fprintf(stderr, "EVM = %8.4f\n", rms);
 }

 return noutput_items;
}