Utilities Namespace

This namespace contains utility classes that are used throughout the library.

The statistics class keeps track of the important statistics of the reconciliation process. The print class provides functions to print the statistics to the console.

Classes

class statistics

This class is used to store and manage the statistics of the simulation.

Public Functions

statistics(std::size_t blocklength, std::size_t num_of_frames, std::size_t MDR_dim, bool layered_flag, std::size_t crc_length = 32)

Construct a new statistics object and initialize the variables.

Parameters:
  • blocklength – Codeword blocklength

  • num_of_frames – Number of frames to be simulated

  • MDR_dim – Dimension of the MDR

  • layered_flag – Flag to indicate whether the decoder uses layered decoding or not

  • crc_length – CRC length

statistics()

Construct a new statistics object.

statistics operator+(const statistics &rhs) const

Overload the addition operator to add two statistics objects.

Parameters:

rhs – Right-hand side statistics object

Returns:

statistics Sum of the two statistics objects

void set_rate(double rate)

Set the rate of the code.

Parameters:

rate – Rate of the code

void set_num_of_quantum_states(std::size_t total_number_of_states)

Set the total number of quantum states.

Parameters:

total_number_of_states – Total number of quantum states

void set_number_of_unused_states(std::size_t number_of_unused_states)

Set the number of unused quantum states.

Parameters:

number_of_unused_states – Number of unused quantum states

void set_bit_error_count(std::size_t frame_index, double bit_error_count)

Set the bit error count for a given frame index.

Parameters:
  • frame_index – Frame index

  • bit_error_count – Bit error count

void set_frame_error_count(std::size_t frame_index)

Set the frame error count for a given frame index.

Parameters:

frame_index – Frame index

void set_num_of_iterations(std::size_t frame_index, double num_of_iteration)

Set the number of iterations for a given frame index.

Parameters:
  • frame_index – Frame index

  • num_of_iteration – Number of iterations

void mark_codeword_as_wrong(std::size_t frame_index)

Mark a given frame as wrongly decoded codeword.

Parameters:

frame_index – Frame index

void set_count_of_undetectable_error_after_CRC(std::size_t No_undetected_errors)

Set the number of undetected frame errors after CRC check.

Parameters:

No_undetected_errors – Number of undetected errors

void set_count_of_wrong_codewords_detected_by_CRC(std::size_t No_wrong_codewords)

Set the number of wrong codewords detected by CRC.

Parameters:

No_wrong_codewords – Number of wrong codewords

void set_noise_variance(double noise_variance)

Set the noise variance of the channel.

Parameters:

noise_variance – Noise variance of the channel

void start_timing()

Start the timing of the simulation.

void end_timing()

End the timing of the simulation.

int get_count_of_undetectable_error_after_CRC() const

Get the number of undetected frame errors after CRC check.

Returns:

int Number of undetected frame errors

int get_count_of_wrong_codewords_detected_by_CRC() const

Get the number of wrong codewords detected by CRC.

Returns:

int Number of wrong codewords

double get_elapsed_time() const

Get the elapsed time of the simulation.

Returns:

double Elapsed time of the simulation

double get_average_time() const

Get the average decoding duration per frame per thread of the simulation.

Returns:

double Average decoding duration per frame per thread in seconds

double get_bit_error_count(size_t frame_index) const

Get the bit error count for a given frame index.

Parameters:

frame_index – Frame index

Returns:

double Bit error count

int get_frame_error_count(size_t frame_index) const

Get the frame error count for a given frame index.

Parameters:

frame_index – Frame index

Returns:

int Frame error count

double get_num_of_iterations(size_t frame_index) const

Get the number of decoding iterations for a given frame index.

Parameters:

frame_index – Frame index

Returns:

double Number of decoding iterations

double get_bit_error_rate() const

Get the bit error rate.

Returns:

double Bit error rate

double get_frame_error_rate() const

Get the frame error rate.

Returns:

double Frame error rate

double get_average_num_of_iterations() const

Get the average number of decoding iterations.

Returns:

double Average number of decoding iterations

int get_total_frame_error_count() const

Get the total number of frame errors.

Returns:

int Total number of frame errors

int get_num_of_decoding_frames() const

Get the number of decoding frames.

Returns:

int Number of decoding frames

int get_count_of_wrong_codewords() const

Get the number of wrong codewords.

Returns:

int Number of wrong codewords

int get_total_number_of_states() const

Get the total number of quantum states.

Returns:

int Total number of quantum states

int get_number_of_unused_states() const

Get the number of unused quantum states.

Returns:

int Number of unused quantum states

double get_rate() const

Get the rate of the code.

Returns:

double Rate of the code

int get_blocklength() const

Get the blocklength of the codeword.

Returns:

int Blocklength of the codeword

int get_crc_length() const

Get the CRC length.

Returns:

int CRC length

int get_MDR_dim() const

Get the dimension of the multi-dimensional reconciliation.

Returns:

int Dimension of the multi-dimensional reconciliation

double get_noise_variance() const

Get the noise variance of the channel.

Returns:

double Noise variance of the channel

int get_layered_flag() const

Get the layered decoding flag.

Returns:

int Layered decoding flag

std::tuple<double, double, int, int, int, double, double, double> get_average_statistics() const

Get the average statistics of the simulation.

The tuple includes:

  • Frame error rate

  • Bit error rate

  • Total number of frame errors

  • Total number of wrong codewords

  • Total number of frames

  • Average number of iterations

  • Total simulation time

  • Simulation time per frame, per thread

Returns:

std::tuple<double, double, int, int, int, double, double, double> Tuple of average statistics

Private Members

std::vector<double> bit_error_counts

Vector to store the number of bit errors for each frame

std::vector<int> frame_error_counts

Vector to store whether the frame is decoded correctly or not for each frame

std::vector<double> num_of_iterations

Vector to store the number of iterations it takes to decode each frame

std::vector<int> converged_wrong_code

Vector to store whether the decoder converged to a wrong codeword for each frame

std::chrono::system_clock::time_point start_time

Variable to store the start time of the simulation

std::chrono::system_clock::time_point end_time

Variable to store the end time of the simulation

double elapsed_time

Variable to store the elapsed time of the simulation

std::size_t N

Blocklength of the codeword

std::size_t num_of_frames

Number of frames to be simulated

std::size_t total_num_of_frames

Total Number of simulated frames

std::size_t crc_length

CRC length

std::size_t MDR_dim

Dimension of the multi-dimensional reconciliation

double noise_variance

Noise variance of the channel

std::size_t No_undetected_error_after_CRC

Number of undetected frame errors after CRC

std::size_t Wrong_codewords_detected_by_CRC

Number of wrong codewords detected by CRC

std::size_t total_number_of_states

Total number of quantum states

std::size_t number_of_unused_states

Total number of quantum states

double rate

Rate of the code

bool layered_flag

Flag to indicate whether the decoder uses layered decoding or not

class print

This class is used to configure the printing of the simulation.

Public Functions

explicit print(bool flag = true)

Construct a new print object.

Parameters:

flag – true: print the statistics report, false: no printing

void print_statistics_report(statistics stats) const

Print the statistics of the simulation.

Parameters:

stats – Statistics object

Private Functions

template<typename T>
void print_line(const std::string &label, const T &value, const std::string &suffix = "") const

1: print the statistics report, 0: no printing

Print a line with a label and a value.

Template Parameters:

T – Type of the value

Parameters:
  • label – Label of the line

  • value – Value to be printed

  • suffix – Suffix of the line