CSS product code  0.1
C++ library to estimate distance of CSS codes. Some particular construction of CSS codes are implemented.
product_lib.h
Go to the documentation of this file.
1 //#ifndef CONCATENATION_LIB_H
2 //#define CONCATENATION_LIB_H
3 #ifndef PRODUCT_LIB_H
4 #define PRODUCT_LIB_H
5 
6 #include "dist.h"
7 #include <itpp/itbase.h>
8 //#include <itpp/itcomm.h>
9 //#include <stdio.h>
10 #include "weilei_lib.h"
11 
12 
13 const int MAX_M=6;//maximum of the length of the complex chain
14 //const int INF=999;//infinity distance
15 
16 
21 public:
22  itpp::GF2mat G;
23  itpp::GF2mat H;
24  int n;
25  int k
26  int d;
27  int is_defined=0;
28 
29  //constructor
30  ClassicalCode();
31  ClassicalCode(itpp::GF2mat G, itpp::GF2mat H);
32 
33  //distance estimator
34  int dist();
35  int min_weight_dist();
36  int rand_dist();
37 
38 
39  //function
40  void info();
43  void full_rank();
44 
45  //generate sample code
46  void get_repetition_code();
47  void get_743_code();
48  void get_734_code();
49 };
50 
51 
52 
54 class CSSCode{
55 public:
56  itpp::GF2mat Gx; /* X type parity check matrix */
57  itpp::GF2mat Gz;
58  itpp::GF2mat Cx;
59  itpp::GF2mat Cz;
60  itpp::bvec min_weight_codeword;
61  int n;
62  int Gx_row, Gz_row;
63  int id_Gx, id_Gz;
65  int dx,dz;
67 
68  //constructor
69  CSSCode();
74  CSSCode(int na, int Gax_row, int id_Gax, int Gaz_row, int id_Gaz);
75 
76  //generating code
77  int generate_by_id(int debug);
78  int getRandomCode();
79  int getGoodCode(int debug);
80 
81  //sanity check
82  bool is_valid();
83 
84  //distance estimation
86  void dist();
87  int min_weight_dist_x();
88  int min_weight_dist_z();
89  int rand_dist_x();
90  int rand_dist_z();
91 
92  //decoding
93 
94  //generate sample code
96  void get_713_code();
97 };
98 
99 class ProductCSSCode: public CSSCode{
100 public:
103  ProductCSSCode(CSSCode codeA_temp, CSSCode codeB_temp);
104 };
105 
106 
109 public:
110  // string title_str, string note, int mode, int sub_mode_A, int sub_mode_B, //general info
111  // int n_low, int n_high, int k_low, int k_high, int debug, //for random simulation
112  // int na;
113  // int Gax_row; int id_Gax; int Gaz_row; int id_Gaz; //for enumarating all cases
114  // int Gbx_row; int id_Gbx; int Gbz_row; int id_Gbz; //for enumarating all cases
115  // int is_defined=0;
116 
117  // CSSCode codeA, codeB;
118  // SubsystemProductCode();
120  SubsystemProductCSSCode(CSSCode codeA_temp, CSSCode codeB_temp){
121  codeA=codeA_temp;
122  codeB=codeB_temp;
123  // std::cout<<" get codeA with codeA.n = "<< codeA_temp.n<<std::endl;
124  if ( codeA.is_defined && codeB.is_defined ){
125  // std::cout<<"both code A and code B are defined"<<std::endl;
126  is_defined=1;
127  }
128  }
129 };
130 
131 
132 
133 
134 
135 int getRandomQuantumCode(int n,int Gx_row,int Gz_row, itpp::GF2mat &Gx,itpp::GF2mat &Gz, itpp::GF2mat &Cx,itpp::GF2mat &Cz);
136 
137 int getGoodQuantumCode(int n,int Gx_row,int Gz_row, itpp::GF2mat &Gx,itpp::GF2mat &Gz, itpp::GF2mat &Cx,itpp::GF2mat &Cz, int debug);
138 
139 void set_submatrix(itpp::GF2mat & G, itpp::GF2mat sub, int row, int col);
140 
143 int generate_code(itpp::GF2mat & Gax, itpp::GF2mat & Gaz, int na, int Gax_row, int id_Gax, int Gaz_row, int id_Gaz, int debug);
144 //moved here cause it is used in CSSCode
145 
146 
148 int generate_code(CSSCode & code, int debug);
149 // return generate_code(code.Gx, code.Gz, code.n, code.Gx_row, code.id_Gx, code.Gz_row, code.id_Gz, debug);
150 //*/
151 
152 
153 
154 
155 
156 //files used in concatenated codes and product codes.
157 
158 //int reduce(itpp::GF2mat Gax, itpp::GF2mat Gaz, itpp::GF2mat Gbx, itpp::GF2mat Gbz,int ddax,int ddaz,int ddbx,int ddbz);
159 //int concatenate(itpp::GF2mat Gax, itpp::GF2mat Gaz, itpp::GF2mat Gbx, itpp::GF2mat Gbz,int ddax,int ddaz,int ddbx,int ddbz);
160 
161 
162 
163 // a version include both reduce and concatenation
164 // mode=1 for reduce/subsystem product
165 // mode=2 for concatenation
166 //only dz is checked cause dx is known to be tight
167 int product(itpp::GF2mat Gax, itpp::GF2mat Gaz, itpp::GF2mat Gbx, itpp::GF2mat Gbz,int ddax,int ddaz,int ddbx,int ddbz, int debug, int mode);
168 
169 
170 
171 
172 #endif //PRODUCT_LIB_H
ClassicalCode::H
itpp::GF2mat H
parity check matrix
Definition: product_lib.h:23
ClassicalCode
Definition: product_lib.h:20
CSSCode::get_713_code
void get_713_code()
Definition: product_lib.cpp:120
CSSCode::is_C_defined
int is_C_defined
Definition: product_lib.h:66
CSSCode::min_weight_dist_x
int min_weight_dist_x()
Definition: product_lib.cpp:106
CSSCode::Gz
itpp::GF2mat Gz
Definition: product_lib.h:57
SubsystemProductCSSCode::SubsystemProductCSSCode
SubsystemProductCSSCode()
Definition: product_lib.h:119
ClassicalCode::info
void info()
Definition: product_lib.cpp:39
SubsystemProductCSSCode
Definition: product_lib.h:108
CSSCode::id_Gz
int id_Gz
Definition: product_lib.h:63
CSSCode::Gx
itpp::GF2mat Gx
Definition: product_lib.h:56
MAX_M
const int MAX_M
Definition: product_lib.h:13
ClassicalCode::dual
ClassicalCode dual()
Definition: product_lib.cpp:45
CSSCode::is_defined
int is_defined
Definition: product_lib.h:66
weilei_lib.h
this file links all other headfiles in this folder.
CSSCode::dist
void dist()
Definition: product_lib.cpp:100
set_submatrix
void set_submatrix(itpp::GF2mat &G, itpp::GF2mat sub, int row, int col)
Definition: product_lib.cpp:226
CSSCode::CSSCode
CSSCode()
Definition: product_lib.cpp:74
dist.h
distance related functions, defined within namespace common
getGoodQuantumCode
int getGoodQuantumCode(int n, int Gx_row, int Gz_row, itpp::GF2mat &Gx, itpp::GF2mat &Gz, itpp::GF2mat &Cx, itpp::GF2mat &Cz, int debug)
Definition: product_lib.cpp:184
CSSCode::rand_dist_x
int rand_dist_x()
Definition: product_lib.cpp:113
ClassicalCode::full_rank
void full_rank()
Definition: product_lib.cpp:50
CSSCode::generate_by_id
int generate_by_id(int debug)
Definition: product_lib.cpp:80
generate_code
int generate_code(itpp::GF2mat &Gax, itpp::GF2mat &Gaz, int na, int Gax_row, int id_Gax, int Gaz_row, int id_Gaz, int debug)
Definition: product_lib.cpp:278
ClassicalCode::dist
int dist()
Definition: product_lib.cpp:26
CSSCode::dz
int dz
Definition: product_lib.h:65
ClassicalCode::n
int n
Number of bits.
Definition: product_lib.h:24
ProductCSSCode::ProductCSSCode
ProductCSSCode(CSSCode codeA_temp, CSSCode codeB_temp)
CSSCode::getRandomCode
int getRandomCode()
Definition: product_lib.cpp:85
ProductCSSCode::codeB
CSSCode codeB
Definition: product_lib.h:101
CSSCode::n
int n
Definition: product_lib.h:61
ClassicalCode::rand_dist
int rand_dist()
Definition: product_lib.cpp:32
ClassicalCode::get_734_code
void get_734_code()
Definition: product_lib.cpp:66
getRandomQuantumCode
int getRandomQuantumCode(int n, int Gx_row, int Gz_row, itpp::GF2mat &Gx, itpp::GF2mat &Gz, itpp::GF2mat &Cx, itpp::GF2mat &Cz)
Definition: product_lib.cpp:158
CSSCode::Cx
itpp::GF2mat Cx
Definition: product_lib.h:58
ClassicalCode::is_defined
int is_defined
if G and H has been defined
Definition: product_lib.h:27
ClassicalCode::min_weight_dist
int min_weight_dist()
Definition: product_lib.cpp:29
CSSCode::Gx_row
int Gx_row
Definition: product_lib.h:62
product
int product(itpp::GF2mat Gax, itpp::GF2mat Gaz, itpp::GF2mat Gbx, itpp::GF2mat Gbz, int ddax, int ddaz, int ddbx, int ddbz, int debug, int mode)
Definition: product_lib.cpp:404
ProductCSSCode
Definition: product_lib.h:99
CSSCode::rand_dist_z
int rand_dist_z()
Definition: product_lib.cpp:116
ProductCSSCode::ProductCSSCode
ProductCSSCode()
Definition: product_lib.h:102
ClassicalCode::get_743_code
void get_743_code()
Definition: product_lib.cpp:61
CSSCode::is_valid
bool is_valid()
Definition: product_lib.cpp:93
CSSCode::dx
int dx
Definition: product_lib.h:65
SubsystemProductCSSCode::SubsystemProductCSSCode
SubsystemProductCSSCode(CSSCode codeA_temp, CSSCode codeB_temp)
Definition: product_lib.h:120
ProductCSSCode::codeA
CSSCode codeA
Definition: product_lib.h:101
ClassicalCode::G
itpp::GF2mat G
codeword generating matrix
Definition: product_lib.h:22
CSSCode::min_weight_codeword
itpp::bvec min_weight_codeword
Definition: product_lib.h:60
CSSCode::Cz
itpp::GF2mat Cz
Definition: product_lib.h:59
CSSCode::min_weight_dist_z
int min_weight_dist_z()
Definition: product_lib.cpp:109
CSSCode::Gz_row
int Gz_row
Definition: product_lib.h:62
ClassicalCode::get_repetition_code
void get_repetition_code()
Definition: product_lib.cpp:56
CSSCode::id_Gx
int id_Gx
Definition: product_lib.h:63
ClassicalCode::d
int k int d
< number of encoded bits
Definition: product_lib.h:26
CSSCode::getGoodCode
int getGoodCode(int debug)
Definition: product_lib.cpp:89
CSSCode
Definition: product_lib.h:54
ClassicalCode::ClassicalCode
ClassicalCode()
Definition: product_lib.cpp:18