CSS product code  0.1
C++ library to estimate distance of CSS codes. Some particular construction of CSS codes are implemented.
common Namespace Reference

common function shared by many program More...

Functions

int min_wt_decoding (itpp::GF2mat C)
 
int min_wt_decoding (itpp::GF2mat C, itpp::GF2mat G)
 
int save_dist (int d, char *filename)
 
int rand_dist (itpp::GF2mat C, int perm_try=10)
 
int classical_dist (itpp::GF2mat G)
 
itpp::GF2mat nullSpace (itpp::GF2mat G)
 
itpp::GF2mat getC (itpp::GF2mat G_x, itpp::GF2mat G_z, int flip=0)
 
int quantum_dist_v2 (itpp::GF2mat G_x, itpp::GF2mat G_z, int flip=0)
 
int quantum_dist (itpp::GF2mat G_x, itpp::GF2mat G_z, int dist_expected, int debug, int flip=0)
 
int hypergraph_dist (itpp::GF2mat Aj, itpp::GF2mat Ajplus, int dist_expected, int flip=0)
 
int draw_toric_x_error (itpp::bvec error_bits)
 
int draw_toric_x_error (itpp::bvec error_bits, std::string header)
 
itpp::bvec find_error (itpp::bvec e_in, itpp::GF2mat H)
 
itpp::GF2mat get_check_code734 (int L)
 
itpp::GF2mat get_check_code743 (int L)
 
itpp::GF2mat get_check_rept (int L)
 
itpp::GF2mat get_check (int generator_flag, int L)
 
itpp::LDPC_Code GF2mat_to_LDPC_Code (itpp::GF2mat G)
 
itpp::LDPC_Code MM_to_LDPC_Code (char *filename)
 
std::string color_text (std::string str)
 
std::string red_text (std::string str)
 
std::string blue_text (std::string str)
 
int get_time (int mode=1)
 
bool is_quantum_code (itpp::GF2mat &G_x, itpp::GF2mat &G_z)
 
bool is_quantum_code (itpp::GF2mat &Gx, itpp::GF2mat &Gz, itpp::GF2mat &Cx, itpp::GF2mat &Cz)
 
itpp::GF2mat make_it_full_rank (itpp::GF2mat fat)
 
int GF2matPrint (itpp::GF2mat &G, std::string name)
 
int matPrint (itpp::mat G, char *name=(char *) " ")
 
itpp::GF2mat kron (itpp::GF2mat A, itpp::GF2mat B)
 
std::string NumberToString (int pNumber)
 
itpp::GF2mat append_vector (itpp::GF2mat G, itpp::bvec b)
 
itpp::GF2mat get_GF2mat (char *filename_prefix, char *filename_suffix)
 
itpp::GF2mat get_GF2mat (char *parent_folder, char *folder, char *filename)
 
double get_error_density (itpp::GF2mat E)
 
int mat2gnudata (itpp::mat data, std::string filename, std::string header)
 

Variables

const int INF =999
 

Detailed Description

common function shared by many program

Function Documentation

◆ append_vector()

itpp::GF2mat common::append_vector ( itpp::GF2mat  G,
itpp::bvec  b 
)

< append row vectors to an itpp::GF2mat

Warning
This is super ineffcient, and should not be used this way

Definition at line 202 of file lib.cpp.

◆ blue_text()

std::string common::blue_text ( std::string  str)

return blue std::string

Definition at line 42 of file lib.cpp.

◆ classical_dist()

int common::classical_dist ( itpp::GF2mat  G)

use random window decoder to find distance of a classical code with parity check patrix G

Parameters
Gparity check matrix \(GC^T=0\) min_wt_decoding is used when C.rows()<7 perm_try=10 always. No interface is given to change it yet.

Definition at line 114 of file dist.cpp.

◆ color_text()

std::string common::color_text ( std::string  str)

return text in red color for printing

currently return red color as default; more color to be implemented

foreground background
black 30 40
red 31 41
green 32 42
yellow 33 43
blue 34 44
magenta 35 45
cyan 36 46
white 37 47

Definition at line 32 of file lib.cpp.

◆ draw_toric_x_error() [1/2]

int common::draw_toric_x_error ( itpp::bvec  error_bits)

draw the lattice, with error bond in red

Definition at line 389 of file dist.cpp.

◆ draw_toric_x_error() [2/2]

int common::draw_toric_x_error ( itpp::bvec  error_bits,
std::string  header 
)

a wrapper of draw_toric_x_error, with an extra header

Definition at line 439 of file dist.cpp.

◆ find_error()

itpp::bvec common::find_error ( itpp::bvec  e_in,
itpp::GF2mat  H 
)

find error with same syndrome for a classical code, can be used for CSS codes as well

Parameters
e_inoriginal error
Hparity check matrix
Returns
an error with same syndrome (It is not necessarily an equivalent error) for principle, see random window decoder

Definition at line 446 of file dist.cpp.

◆ get_check()

itpp::GF2mat common::get_check ( int  generator_flag,
int  L 
)

return check matrix

Parameters
Lsize of the code switch(generator_flag){ case 1: return get_check_rept(L);break; case 2: return get_check_code734(L);break; case 3: return get_check_code743(L);break;

Definition at line 524 of file dist.cpp.

◆ get_check_code734()

itpp::GF2mat common::get_check_code734 ( int  L)

return check matrix code code [7,3,4], find definition in research note.pdf

Parameters
Lsize of the code, must be a multiple of 7

Definition at line 471 of file dist.cpp.

◆ get_check_code743()

itpp::GF2mat common::get_check_code743 ( int  L)

return check matrix code code [7,4,3], find definition in research note.pdf

Parameters
Lsize of the code, must be a multiple of 7

Definition at line 490 of file dist.cpp.

◆ get_check_rept()

itpp::GF2mat common::get_check_rept ( int  L)

return circulant check matrix for repetition code of length L

Definition at line 513 of file dist.cpp.

◆ get_error_density()

double common::get_error_density ( itpp::GF2mat  E)

return density of a matrix whose first row is zero remove first row and return density of the remained submatrix

Definition at line 224 of file lib.cpp.

◆ get_GF2mat() [1/2]

itpp::GF2mat common::get_GF2mat ( char *  filename_prefix,
char *  filename_suffix 
)

getitpp::GF2mat from filename with given pattern full name = filename_prefix+filename_suffix

Definition at line 210 of file lib.cpp.

◆ get_GF2mat() [2/2]

itpp::GF2mat common::get_GF2mat ( char *  parent_folder,
char *  folder,
char *  filename 
)

getitpp::GF2mat from filename with given pattern full name = parent_folder/folder/filename

Definition at line 217 of file lib.cpp.

◆ get_time()

int common::get_time ( int  mode = 1)

return time in secs, milliseconds, or ...

Parameters
mode=1secs (default)
mode=2millisecs, \( 10 ^{-3} \)
mode=310 nano secs = \(10^{-8}\) sec

Definition at line 53 of file lib.cpp.

◆ getC()

itpp::GF2mat common::getC ( itpp::GF2mat  G_x,
itpp::GF2mat  G_z,
int  flip = 0 
)

get codeword generating matrix for CSS codes

Parameters
G_xX type party check matrix
G_zZ type party check matrix
flip=0whether flipping or nor
Returns
C_x when flip=0
C_z when flip=1

Definition at line 143 of file dist.cpp.

◆ GF2mat_to_LDPC_Code()

itpp::LDPC_Code common::GF2mat_to_LDPC_Code ( itpp::GF2mat  G)

Definition at line 550 of file dist.cpp.

◆ GF2matPrint()

int common::GF2matPrint ( itpp::GF2mat &  G,
std::string  name 
)

print brief information of G: name, size, density

Parameters
G
namename of the matrix

Definition at line 144 of file lib.cpp.

◆ hypergraph_dist()

int common::hypergraph_dist ( itpp::GF2mat  Aj,
itpp::GF2mat  Ajplus,
int  dist_expected,
int  flip = 0 
)

get estimated distance of a CSS code generated from a chain complex \( A_jA_{j+1}=0 \)

Parameters
Aj
Ajplus
dist_expecteduse expected distance to control number of trials
flip=0(default) or 1, flip left and right if flip=1
Returns
left distance of CSS code (Aj,Ajplus^T)

left distance of (Aj,Ajplus^T), right distance of (G_x,G_z), flip left and right if flip = 1, TODO::This should be implemented as a wrapper of quantum_dist()

Definition at line 292 of file dist.cpp.

◆ is_quantum_code() [1/2]

bool common::is_quantum_code ( itpp::GF2mat &  G_x,
itpp::GF2mat &  G_z 
)

check if it is a quantum CSS code

Parameters
G_xX type parity check matrix
G_zZ type parity check matrix

Definition at line 77 of file lib.cpp.

◆ is_quantum_code() [2/2]

bool common::is_quantum_code ( itpp::GF2mat &  Gx,
itpp::GF2mat &  Gz,
itpp::GF2mat &  Cx,
itpp::GF2mat &  Cz 
)

check if it is a quantum CSS code

Parameters
G_xX type parity check matrix
G_zZ type parity check matrix
C_xX type codeword generating matrix
C_zZ type codeword generating matrix

Definition at line 91 of file lib.cpp.

◆ kron()

itpp::GF2mat common::kron ( itpp::GF2mat  A,
itpp::GF2mat  B 
)

Kronecker product of A and B

Parameters
Athe outer matrix
Bthe inner matrix
Warning
: The implementation is confusing, but should works as the conventional Kronecker product defined in the wikipedia page

Definition at line 162 of file lib.cpp.

◆ make_it_full_rank()

itpp::GF2mat common::make_it_full_rank ( itpp::GF2mat  fat)

reduce a fat matrix with degenerate rows to a thin matrix with full rank; remove the dependent rows

Parameters
fata GF2mat not necessary full rank
Returns
thin: a full rank GF2mat matrix

Definition at line 123 of file lib.cpp.

◆ mat2gnudata()

int common::mat2gnudata ( itpp::mat  data,
std::string  filename,
std::string  header 
)

save mat into gnuplot data file, with a custom comment as header

Definition at line 237 of file lib.cpp.

◆ matPrint()

int common::matPrint ( itpp::mat  G,
char *  name = (char *) " " 
)

print brief information of G: name, size, density

Parameters
G
namename of the matrix

should change char to string

Definition at line 153 of file lib.cpp.

◆ min_wt_decoding() [1/2]

int common::min_wt_decoding ( itpp::GF2mat  C)

min weight decoder for classical code

Parameters
Ccodeword generating matrix
Returns
min weight of all codewords (any combination of rows in the generating matrix)

Definition at line 12 of file dist.cpp.

◆ min_wt_decoding() [2/2]

int common::min_wt_decoding ( itpp::GF2mat  C,
itpp::GF2mat  G 
)

min weight decoder for CSS code distance The distance between \( y=ax^2+b \)

Parameters
Ccodeword generating matrix
Ggauge matrix
Returns
\( d_{\text{min}} = \text{min}_{\alpha \neq 0, \beta} \text{wgt} (\alpha C+ \beta G), \alpha \neq 0 \)

Definition at line 44 of file dist.cpp.

◆ MM_to_LDPC_Code()

itpp::LDPC_Code common::MM_to_LDPC_Code ( char *  filename)

convert GF2mat saved in .mm file to LDPC_Code

Definition at line 559 of file dist.cpp.

◆ nullSpace()

itpp::GF2mat common::nullSpace ( itpp::GF2mat  G)
Returns
H such that \(GH^T = 0\), and rank G + rank H = n = full rank

Definition at line 133 of file dist.cpp.

◆ NumberToString()

std::string common::NumberToString ( int  pNumber)

convert int to string

Warning
not used anywhere, should be replaced by build-in function to_string()

Definition at line 195 of file lib.cpp.

◆ quantum_dist()

int common::quantum_dist ( itpp::GF2mat  G_x,
itpp::GF2mat  G_z,
int  dist_expected,
int  debug,
int  flip = 0 
)

get estimated distance for CSS codes

Parameters
G_xX type party check matrix
G_zZ type party check matrix
flip=0whether flipping or nor
dist_expecteduse expected distance to control number of trials
Returns
d_x when flip=0
d_z when flip=1

Definition at line 228 of file dist.cpp.

◆ quantum_dist_v2()

int common::quantum_dist_v2 ( itpp::GF2mat  G_x,
itpp::GF2mat  G_z,
int  flip = 0 
)

get estimated distance for CSS codes

Parameters
G_xX type party check matrix
G_zZ type party check matrix
flip=0whether flipping or nor
Returns
d_x when flip=0
d_z when flip=1

Definition at line 179 of file dist.cpp.

◆ rand_dist()

int common::rand_dist ( itpp::GF2mat  C,
int  perm_try = 10 
)

use random window decoder to find min wt of rows in C. min_wt_decoding is used when C.rows()<7

Parameters
Ccodeword generating matrix
perm_try=10number of random trials

Definition at line 82 of file dist.cpp.

◆ red_text()

std::string common::red_text ( std::string  str)

return red std::string

Definition at line 37 of file lib.cpp.

◆ save_dist()

int common::save_dist ( int  d,
char *  filename 
)

save distance to a file, as a single-element itpp::mat

Definition at line 73 of file dist.cpp.

Variable Documentation

◆ INF

const int common::INF =999

Infinite distance in random window decoder

Definition at line 19 of file dist.h.