|
Dist m4ri 0.0.1.alpha
Computing distance of a classical or quantum CSS code
|
#include <inttypes.h>#include <strings.h>#include <stdlib.h>#include <time.h>#include <stdio.h>#include <limits.h>#include <m4ri/m4ri.h>#include "mmio.h"#include "uthash.h"#include "util_hash.h"#include "util_m4ri.h"

Go to the source code of this file.
Classes | |
| struct | params_t |
Macros | |
| #define | UTIL_IO_H |
| #define | _maybe_unused __attribute__((unused)) |
| #define | MAX_W 100 |
| #define | USAGE |
| #define | BRIEF_HELP "try \"%s -h\" for help" |
Typedefs | |
| typedef struct CW_VEC_T | cw_vec_t |
Functions | |
| void | var_init (int argc, char **argv, params_t *const p) |
| Initialize parameters and load matrices from command line arguments. | |
| void | var_kill (params_t *const p) |
| Clean up and free memory allocated in the params_t structure. | |
| void | read_dem_file (char *fnam, csr_t **p_spaH, csr_t **p_spaL, double pmin, int debug) |
| Read a Detector Error Model (DEM) file and construct H and L matrices. | |
| long long int | nzlist_read (const char fnam[], params_t *p) |
| Read codewords from a .nz list file and add them to the codeword hash. | |
| long long int | nzlist_write (const char fnam[], const char comment[], params_t *p) |
| Write the found codewords from the hash table to a .nz file. | |
| cw_vec_t * | codeword_add_maybe (params_t *const p, const int arr[], int weight) |
| Add a candidate codeword to the hash table if it meets weight limits. | |
Variables | |
| params_t | prm |
Add a candidate codeword to the hash table if it meets weight limits.
Compares the candidate codeword weight with the current minimum weight and dW limit. If it is within the limits, it is added to the hash. If a new strictly smaller minimum weight is found, it updates the global minimum weight and prunes heavier codewords from the hash.
| p | Pointer to the params_t structure. |
| arr | Array of indices representing the support of the codeword. |
| weight | Weight of the codeword (length of arr). |
Definition at line 797 of file util_io.c.
References CW_VEC_T::arr, CW_VEC_T::cnt, params_t::codewords, params_t::dW, ERROR, HASH_ADD, HASH_DEL, HASH_FIND, HASH_ITER, params_t::maxC, params_t::min_w, params_t::num_cws, p, and CW_VEC_T::weight.
Referenced by do_CC_dist(), do_RW_dist(), nzlist_read(), and start_CC_recurs().
| long long int nzlist_read | ( | const char | fnam[], |
| params_t * | p | ||
| ) |
Read codewords from a .nz list file and add them to the codeword hash.
Reads the file, verifies that each codeword satisfies the code requirements (orthogonal to H, not orthogonal to L for quantum codes), and adds valid ones to the hash table in params_t.
| fnam | Path to the .nz file. |
| p | Pointer to the params_t structure containing the code matrices and hash. |
Definition at line 840 of file util_io.c.
References CW_VEC_T::arr, codeword_add_maybe(), params_t::codewords, params_t::debug, ERROR, params_t::maxC, params_t::num_cws, nzlist_r_one(), nzlist_r_open(), params_t::outC, p, params_t::spaH, params_t::spaL, CW_VEC_T::weight, and params_t::wmax.
Referenced by main().
| long long int nzlist_write | ( | const char | fnam[], |
| const char | comment[], | ||
| params_t * | p | ||
| ) |
Write the found codewords from the hash table to a .nz file.
Exports all codewords currently stored in the hash table to a file in NZLIST format.
| fnam | Path to the output .nz file. |
| comment | An optional comment string to include in the file header. |
| p | Pointer to the params_t structure containing the codeword hash. |
Definition at line 893 of file util_io.c.
References params_t::codewords, CW_VEC_T::hh, UT_hash_handle::next, nzlist_w_append(), nzlist_w_new(), and p.
Referenced by main().
Read a Detector Error Model (DEM) file and construct H and L matrices.
Parses a DEM file (e.g. from Stim), filters error events based on pmin, and builds the corresponding sparse check matrix H and logical matrix L.
| fnam | Path to the DEM file. |
| p_spaH | Pointer to store the constructed sparse check matrix H. |
| p_spaL | Pointer to store the constructed sparse logical matrix L. |
| pmin | Minimum error probability threshold to keep an error event. |
| debug | Debug print level bitmap. |
Definition at line 663 of file util_io.c.
References csr_from_pairs(), and ERROR.
Referenced by var_init().
| void var_init | ( | int | argc, |
| char ** | argv, | ||
| params_t *const | p | ||
| ) |
Initialize parameters and load matrices from command line arguments.
Parses command line arguments, sets up the parameter structure, loads matrices from specified files (Matrix Market or DEM), constructs logical matrices if needed, and performs consistency checks.
| argc | Number of command line arguments. |
| argv | Array of command line argument strings. |
| p | Pointer to the params_t structure to initialize. |
debug
finH
< allow space before file name
finL
< allow space before file name
finG degeneracy generator matrix
< allow space before file name
create Lx
WARNING: this does not necessarily have minimal row weights
Definition at line 54 of file util_io.c.
References BRIEF_HELP, params_t::cbeg, params_t::cend, params_t::classical, csr_t::cols, csr_csr_mul_non_zero(), csr_free(), csr_mm_read(), csr_print(), params_t::css, params_t::debug, params_t::dexp, params_t::dmax, params_t::dmin, params_t::dW, ERROR, params_t::fdem, params_t::fin, params_t::finC, params_t::finG, params_t::finH, params_t::finL, Lx_for_CSS_code(), MAX_W, params_t::maxC, params_t::method, params_t::n0, params_t::nchk, params_t::noscan, params_t::nvar, params_t::outC, p, params_t::pmin, read_dem_file(), csr_t::rows, params_t::seed, params_t::smax, params_t::spaG, params_t::spaH, params_t::spaL, params_t::start, params_t::steps, params_t::swei, params_t::threads, params_t::timeout, USAGE, params_t::wmax, and params_t::wmin.
Referenced by main().
| void var_kill | ( | params_t *const | p | ) |
Clean up and free memory allocated in the params_t structure.
Frees sparse matrices (spaH, spaG, spaL) and codeword lists.
| p | Pointer to the params_t structure to clean up. |
Definition at line 473 of file util_io.c.
References params_t::codewords, csr_free(), params_t::fin, params_t::finG, params_t::finH, HASH_DEL, HASH_ITER, p, params_t::spaG, params_t::spaH, and params_t::spaL.
Referenced by main().
|
extern |
Definition at line 7 of file util_io.c.
Referenced by main(), and mzd_generator_from_csr().