CSS product code  0.1
C++ library to estimate distance of CSS codes. Some particular construction of CSS codes are implemented.
dist.cpp
Go to the documentation of this file.
1 //Weilei Zeng, April 28
2 //return min weight of rows in C, which is the distance of the code
3 //random window method is applied with default number of permutation 10.
4 
5 //#include "weilei_lib/my_lib.h"
6 #include "dist.h"
7 #include "lib.h"
8 #include "mm_read.h"
9 #include "mm_write.h"
10 
11 
12 int common::min_wt_decoding(itpp::GF2mat C){
13  // std::cout<<C<<endl;
14  //when C is not so large, we can apply the true min weight decoding
15  // int rowC=C.rows();
16  // std::cout<<"rowC = "<<rowC<<endl;
17  itpp::bvec alpha(C.rows());//a binary vector for linear combination of codeword
18  itpp::GF2mat alphaM(1,C.rows());
19  int max = pow(2,C.rows());
20  itpp::bvec codeword(C.cols());
21  int wt, min_wt=C.cols();
22  itpp::bvec zero = itpp::zeros_b(C.cols());
23  // std::cout<<"min_wt_decodnig"<<endl;
24  // std::cout<<"max = "<<max<<endl<<C.rows()<<endl;
25  // itpp::bvec min_codeword=zero;
26  for ( int i =1;i<max;i++){
27  // itpp::dec2bin(i,alpha);
28  alpha = itpp::dec2bin(C.rows(),i);
29  alphaM.set_row(0,alpha);
30  //std::cout<<i<<std::endl;
31  // std::cout<<"alpha = "<<alpha<<std::endl;
32  codeword=(alphaM*C).get_row(0);
33  wt = itpp::BERC::count_errors(zero,codeword);
34  // if ( wt < min_wt ) min_codeword=codeword;
35  min_wt = (wt<min_wt)? wt : min_wt;
36  if ( min_wt == 1) return 1;
37  }
38  // std::cout<<"min wt codeword: "<<min_codeword<<std::endl;
39  return min_wt;
40 }
41 
42 //G for gauge operators, and C for bare logical operators
43 //code word c = alpha_C*C+alpha_G*G, where alpha_C \neq 0
44 int common::min_wt_decoding(itpp::GF2mat C,itpp::GF2mat G){
45  // std::cout<<"call min_wt_decoding"<<std::endl;
46  // make sure G and C are full rank before calling this function. Otherwise it is a waste of computing power.
47  int C_rows=C.rows(), G_rows=G.rows();
48  int dec_C=(int) pow(2, C_rows);
49  int dec_G=(int) pow(2, G_rows);
50  int N=C.cols();
51  itpp::bvec bvec_C;
52  itpp::bvec bvec_zero=itpp::zeros_b(N);
53  itpp::GF2mat alpha_C(1,C_rows), alpha_G(1,G_rows);
54  int wt=N, min_wt=N;
55  //I should save a static copy of this alpha matrix, instead of generate it in two for loops every time.
56  for ( int i = 1; i < dec_C ; i++){
57  alpha_C.set_row(0,itpp::dec2bin(C_rows,i));
58  for ( int j = 0; j < dec_G; j++){
59  alpha_G.set_row(0,itpp::dec2bin(G_rows,j));
60  bvec_C = (alpha_C * C + alpha_G * G).get_row(0);
61  // std::cout<<bvec_C<<std::endl;
62  wt = itpp::BERC::count_errors(bvec_zero,bvec_C);
63  // if ( wt < min_wt ) min_codeword=codeword;
64  min_wt = (wt<min_wt)? wt : min_wt;
65  if ( min_wt == 1 ) return 1;
66  }
67  }
68  // std::cout<<" finish min_wt_decoding"<<std::endl;
69  return min_wt;
70 }
71 
72 
73 int common::save_dist(int d,char * filename){
74  itpp::mat mat_d(1,1);
75  mat_d.set(0,0,d);
76  mat_to_MM(mat_d,filename);
77  return 0;
78 }
79 
80 
81 
82 int common::rand_dist(itpp::GF2mat C, int perm_try){//default perm_try=10
83  // return min wt of rows in C
84  if (C.rows()<7){ //for small codes, use true min wt decoding
85  return min_wt_decoding(C);
86  }
87  //use random window decoder to find min wt of C
88  // RNG_randomize(); do not use it here. run it in the main program
89  itpp::bvec row_vec,zero=itpp::zeros_b(C.cols());
90  int wt,min_wt=C.cols();
91  itpp::ivec perm;
92  itpp::GF2mat T,U;
93  itpp::ivec P;
94  for (int j=0;j<perm_try;j++){
95  perm = sort_index( itpp::randu(C.cols()) );
96  C.permute_cols(perm,false);
97  //no need to permute back; can also permute the rows
98  //permute rows also
99  perm = sort_index( itpp::randu(C.rows()) );
100  C.permute_rows(perm,false);
101  C.T_fact(T,U,P);
102  for (int i = 0;i<C.rows();i++){
103  row_vec = C.get_row(i);
104  wt = itpp::BERC::count_errors(zero,row_vec);
105  if (wt < min_wt){
106  min_wt = wt;
107  // std::cout<<row_vec<<std::endl;
108  }
109  }
110  }
111  return min_wt;
112 }
113 
114 int common::classical_dist(itpp::GF2mat G){
115  //return distance of a classical code GH^t=0
116  //G is parity check matrix
117  itpp::GF2mat T,U;
118  itpp::ivec P;
119  int rank_of_G = G.transpose().T_fact(T,U,P);
120  if ( rank_of_G == G.cols() ){
121  return INF;//999;//999 for infinity
122  }
123  itpp::GF2mat H = T.get_submatrix(rank_of_G,0,G.cols()-1,G.cols()-1);
124  if (H.rows()<7){//use true min wt decoding for small codes.
125  return min_wt_decoding(H);
126  }
127  int min_wt = rand_dist(H);//default permutation = 10
128  return min_wt;
129 }
130 
131 
132 //return H such that GH^T = 0, and rank G + rank H = n = full rank
133 itpp::GF2mat common::nullSpace(itpp::GF2mat G){
134  itpp::GF2mat T,U; itpp::ivec P;
135  int n=G.cols();
136  int rank_of_G = G.transpose().T_fact(T,U,P);
137  // itpp::GF2matPrint(T,"T");
138  itpp::GF2mat Q=T.get_submatrix(rank_of_G,0,n-1,n-1);
139  return Q;
140 }
141 
142 
143 itpp::GF2mat common::getC(itpp::GF2mat G_x,itpp::GF2mat G_z,int flip){
144  //return C_x
145  //flip=1 to get C_z
146  if (flip==1){
147  itpp::GF2mat temp=G_x;
148  G_x=G_z;
149  G_z=temp;
150  }
151  itpp::GF2mat T,U;
152  itpp::ivec P;
153  int rank_of_G_z = G_z.transpose().T_fact(T,U,P);
154  itpp::GF2mat Q=T.get_submatrix(rank_of_G_z,0,G_z.cols()-1,G_z.cols()-1);//Q include G_x and C_x/L_x
155  itpp::GF2mat GQ=G_x.concatenate_vertical(Q);
156 
157  GQ.T_fact(T,U,P);
158  int rank_of_G_x = G_x.row_rank();
159  int rank_of_Q = Q.rows();
160  if (rank_of_G_x == rank_of_Q){
161  std::cout<<"getC(): It is not a quantum code:zero rank for codeword space"<<std::endl;
162  // return;
163  }
164  if ( G_x.cols()-rank_of_G_z-rank_of_G_x < 1){
165  std::cout<<"empty code space"<<std::endl;
166  throw "empty code space";
167  }
168  // itpp::GF2matPrint(G_x,"G_x");
169  // itpp::GF2matPrint(U,"U");
170  itpp::GF2mat C = U.get_submatrix(rank_of_G_x,0,rank_of_Q-1,G_x.cols()-1 );
171 
172  C.permute_cols(P,true);//codewords/logical group
173  //check if ((G_z*C.transpose()).is_zero() ){ std::cout<<"GOOD C"<<std::endl; }
174  // std::cout<<"get C"<<std::endl;
175  return C;
176 }
177 
178 
179 int common::quantum_dist_v2(itpp::GF2mat G_x, itpp::GF2mat G_z, int flip){//without expected value
180  //right or x distance of (G_x,G_z)
181  //flip left and right if flip = 1;
182  int trialQ=500;//100 is good for not so big codes;permute GQ this max amount of time
183  // int trialQflag=1;//a falg to control the max amout of permutation
184 
185  if (flip==1){//flip G_x and G_z
186  itpp::GF2mat temp=G_x; G_x=G_z; G_z=temp;
187  }
188 
189 
190 
191  itpp::GF2mat T,U; itpp::ivec P;
192  int rank_of_G_z = G_z.transpose().T_fact(T,U,P);
193 
194  // for small code, use min_wt_decoding to return X distance
195  if (G_z.cols() - rank_of_G_z < 11){
196  return min_wt_decoding(getC(G_x, G_z), G_x);
197  }
198 
199 
200  itpp::GF2mat Q=T.get_submatrix(rank_of_G_z,0,G_z.cols()-1,G_z.cols()-1);//Q include G_x and C_x/L_x
201  itpp::GF2mat GQ=G_x.concatenate_vertical(Q);
202  int min_wt=GQ.cols(),wt;
203 
204  for ( int iq=0;iq<trialQ;iq++){
205  itpp::ivec perm = sort_index( itpp::randu( GQ.cols() ));//random permutation
206  GQ.permute_cols(perm,false);
207  GQ.T_fact(T,U,P);
208  int rank_of_G_x = G_x.row_rank();
209  int rank_of_Q = Q.rows();
210 
211  if (rank_of_G_x == rank_of_Q){
212  return INF;//999 for infinity
213  }
214  itpp::GF2mat C = U.get_submatrix(rank_of_G_x,0,rank_of_Q-1,G_x.cols()-1 );
215  C.permute_cols(P,true);//codewords/logical group //not necessary to permute it back here
216 
217  wt = rand_dist(C);//defauylt permutation = 10
218  trialQ=(wt<min_wt)? ( (10*iq > trialQ)? 10*iq : trialQ ):trialQ;//make sure this is the true min weight
219  min_wt=(wt<min_wt)? wt:min_wt;
220  if (min_wt ==1) return 1;
221 
222  // std::cout<<"iq = "<<iq<<", [wt="<<wt<<"] "<<std::endl;;
223  // std::cout<<"got min wt of logical operator C = "<<min_wt<<std::endl;
224  //save_dist(min_wt,filename_dist);
225  }
226  return min_wt;
227 }
228 int common::quantum_dist(itpp::GF2mat G_x, itpp::GF2mat G_z, int dist_expected, int debug, int flip){
229  //right or x distance of (G_x,G_z)
230  //flip left and right if flip = 1;
231  int trialQ=50000;//1000;permute GQ this max amount of time
232  if ( dist_expected > 10 ) trialQ = trialQ*2;
233  int trialQflag=1;//a flag to adjust the max amount of permutation
234 
235  if (flip==1){//flip G_x and G_z
236  itpp::GF2mat temp=G_x; G_x=G_z; G_z=temp;
237  }
238 
239  itpp::GF2mat T,U; itpp::ivec P;
240  int rank_of_G_z = G_z.transpose().T_fact(T,U,P);
241  itpp::GF2mat Q=T.get_submatrix(rank_of_G_z,0,G_z.cols()-1,G_z.cols()-1);//Q include G_x and C_x/L_x
242 
243  // std::cout<<Q.row_rank()<<","<<G_z.row_rank()<<","<<G_z.cols()<<std::endl;
244 
245  itpp::GF2mat GQ=G_x.concatenate_vertical(Q);
246  int min_wt=GQ.cols(),wt;
247 
248  for ( int iq=0;iq<trialQ;iq++){
249  itpp::ivec perm = sort_index( itpp::randu( GQ.cols() ));//random permutation
250  GQ.permute_cols(perm,false);
251  GQ.T_fact(T,U,P);
252  int rank_of_G_x = G_x.row_rank();
253  int rank_of_Q = Q.rows();
254 
255  if (rank_of_G_x == rank_of_Q){
256  return INF;//999 for infinity
257  }
258  itpp::GF2mat C = U.get_submatrix(rank_of_G_x,0,rank_of_Q-1,G_x.cols()-1 );
259  C.permute_cols(P,true);//codewords/logical group //not necessary to permute it back here
260  //Question 1: does the row in C include some stabilizer generators which may increase its weight?
261 
262  wt = rand_dist(C);//defauylt permutation = 10
263  min_wt=(wt<min_wt)? wt:min_wt;
264  //std::cout<<"iq = "<<iq<<", [wt="<<wt<<"] "<<std::endl;;
265  // std::cout<<"got min wt of logical operator C = "<<min_wt<<std::endl;
266  //save_dist(min_wt,filename_dist);
267  int max_trial = 0;//no need to run C again, always get the same result
268  for (int i =0;i<max_trial;i++){
269  wt=rand_dist(C);
270  min_wt=(wt<min_wt)? wt:min_wt;
271  }
272  if (trialQflag) {//adjust the max number of permutation, only do this once
273  if (min_wt <= dist_expected){
274  trialQflag=0;
275  trialQ = 10*iq;
276  // continue to run to see if smaller distance can be achieved.
277  trialQ=(trialQ<1000)? 1000:trialQ;
278  if (debug) std::cout<<"quantum_dist: reach min distance when iq = "<<iq<<", continue to run with trialQ = "<<trialQ<<std::endl;
279  }
280  }
281  }
282  return min_wt;
283 }
284 
292 int common::hypergraph_dist(itpp::GF2mat Aj, itpp::GF2mat Ajplus,int dist_expected,int flip){
293 
294  itpp::GF2mat G_z = Aj;
295  itpp::GF2mat G_x = Ajplus.transpose();
296  //check commutation
297  /* if ( (Aj*Ajplus).is_zero()){
298  //pass
299  }else{
300  std::cout<<"It is not a CSS code!"<<std::endl;
301  }*/
302 
303  if (flip==1){
304  itpp::GF2mat temp=G_x;
305  G_x=G_z;
306  G_z=temp;
307  }
308 
309  /* char * filename_G_x = argv[1];
310  char * filename_G_z = argv[2];
311  char * filename_C_x = argv[3];
312  char * filename_dist = argv[4];
313  */
314  // itpp::GF2mat G_z = MM_to_GF2mat(filename_G_z);
315  itpp::GF2mat T,U;
316  itpp::ivec P;
317  int rank_of_G_z = G_z.transpose().T_fact(T,U,P);
318  itpp::GF2mat Q=T.get_submatrix(rank_of_G_z,0,G_z.cols()-1,G_z.cols()-1);//Q include G_x and C_x/L_x
319 
320  // itpp::GF2mat G_x=MM_to_GF2mat(filename_G_x);
321 
322 
323  itpp::GF2mat GQ=G_x.concatenate_vertical(Q);
324  int min_wt=GQ.cols(),wt;
325  int trialQ=1000;//1000;
326  for ( int iq=0;iq<trialQ;iq++){
327  itpp::ivec perm = sort_index( itpp::randu( GQ.cols() ));
328  GQ.permute_cols(perm,false);
329  GQ.T_fact(T,U,P);
330  int rank_of_G_x = G_x.row_rank();
331  int rank_of_Q = Q.rows();
332 
333  if (rank_of_G_x == rank_of_Q){
334  // std::cout<<"It is not a quantum code!"<<std::endl;
335  if (dist_expected != 999){
336  std::cout<<std::endl<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!NOTICE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!NOTICE!!!!!!!!!!!!!"<<std::endl;
337  std::cout<<"("<<dist_expected<<")";
338  }
339  return 999;//999 for infinity
340  }
341  itpp::GF2mat C = U.get_submatrix(rank_of_G_x,0,rank_of_Q-1,G_x.cols()-1 );
342  C.permute_cols(P,true);//codewords/logical group //not necessary to permute it back here
343 
344  //Question 1: does the row in C include some stabilizer generators which may increase its weight?
345 
346  //itpp::GF2mat_to_MM(C,filename_C_x);
347  wt = rand_dist(C);//defauylt permutation = 10
348  min_wt=(wt<min_wt)? wt:min_wt;
349  // std::cout<<"got min wt of logical operator C = "<<min_wt<<std::endl;
350  //save_dist(min_wt,filename_dist);
351  // std::cout<<"<"<<wt<<">";
352  int max_trial = 0;//no need to run C again, always get the same result
353  for (int i =0;i<max_trial;i++){
354  if (min_wt == dist_expected){
355  //great job! return the result
356  break;
357  }else if (min_wt < dist_expected){
358  // std::cout<<"Damn! how could this happen!"<<std::endl;
359  // std::cout<<"("<<dist_expected<<")";
360  break;
361  }else{
362  //continue another run
363  // std::cout<<"#RUN AGAIN#"<<min_wt;
364  wt=rand_dist(C);
365  min_wt=(wt<min_wt)? wt:min_wt;
366  // std::cout<<"<"<<wt<<">";
367  }
368  }
369 
370  if (min_wt == dist_expected){
371  break;
372  }
373  }
374 
375  //final check
376  if (min_wt != dist_expected){
377  std::cout<<std::endl<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!NOTICE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!NOTICE!!!!!!!!!!!!!"<<std::endl;
378  std::cout<<"("<<dist_expected<<")";
379 
380  }
381 
382 
383  return min_wt;
384 }
385 
386 
387 
388 
389 int common::draw_toric_x_error(itpp::bvec error_bits){
390  // std::cout<<"draw with weight = "<<weight(error_bits)<<std::endl;
391  // if (true) return 0 ;
392 
393  //draw ( but not print) error for the toric code
394  //in stabilizer generating matrix, we have vertex for X and plaquette for Z
395  //use plaquette to check X error and vertex to check Z errors
396  //for indexing, start from the plaqutte in the top left. Its top bond has index one, and then move to the right and then move down. After finishing all horizontal bonds in the lattice, Start from its left bond with index n*n, the move right and move down.
397  int N=error_bits.length(); //size of the code N=2*n*n
398  int n=(int) sqrt(N/2); //size of the lattice
399 
400  //first row of horizontal bonds
401  std::cout<<" ";
402  for ( int j=0; j<n; j++){
403  if (error_bits.get(n*0+j)){
404  std::cout<<color_text("_ ");
405  }else{
406  std::cout<<"_ ";
407  }
408  }
409  std::cout<<std::endl;
410  for (int i=1;i<n;i++){
411  for ( int j=0; j<n; j++){
412  if (error_bits.get(n*(i-1)+n*n+j)){
413  std::cout<<color_text("|");//"1";//for error bits
414  }else{
415  std::cout<<"|";
416  }
417  if (error_bits.get(n*i+j)){
418  std::cout<<color_text("_");
419  //for error bits
420  }else{
421  std::cout<<"_";
422  }
423  }
424  std::cout<<std::endl;
425  }
426  //the last row of vertical bonds
427  for ( int j=0; j<n; j++){
428  if (error_bits.get(n*(n-1)+n*n+j)){
429  // std::std::cout<<"\033[0;32m 1 \033[0m";
430  std::cout<<color_text("| ");
431  }else{
432  std::cout<<"| ";
433  }
434  }
435  std::cout<<std::endl;
436  return 0;
437 }
438 
439 int common::draw_toric_x_error(itpp::bvec error_bits, std::string header){
440  std::cout<<header.c_str()<<std::endl;
441  draw_toric_x_error(error_bits);
442  return 0;
443 
444 }
445 
446 itpp::bvec common::find_error(itpp::bvec e_in, itpp::GF2mat H){
447  //input: original error and parity check matrix
448  //output: an error with same syndrome
449  //for principle, see random window decoder
450 
451 
452  // std::cout<<H.rows()<<" row rank "<< H.row_rank()<<std::endl;
453  H = make_it_full_rank(H); //H may not have full rank
454  itpp::GF2mat H0=H;
455  itpp::bvec e_t = e_in;//change name
456  itpp::bvec s=H*e_t;//syndrome
457 
458  H.set_size(H.rows(),H.cols()+1,true);//H=(H_x,s)
459  H.set_col(H.cols()-1,s);//add syndrome
460 
461  itpp::GF2mat T,U;
462  itpp::ivec P;
463  H.transpose().T_fact(T,U,P);
464  itpp::GF2mat Q=T.get_submatrix(H.rows(),0,H.cols()-1,H.cols()-1);
465  itpp::bvec X_t=Q.get_row(Q.rows()-1);//the error detected, X_t=(X_z,X_x,1)
466  X_t.set_size(X_t.size()-1,true);
467  return X_t;
468 }
469 
470 
471 itpp::GF2mat common::get_check_code734(int L){//L=7n
472  //return check matrix code code [7,3,4], find definition in research note.pdf
473  itpp::GF2mat G(L,L);
474  for ( int i=0;i<L;i++){
475  G.set(i,i,1);
476  if (i+2>L-1) {
477  G.set(i,i+2-L,1);
478  } else {
479  G.set(i,i+2,1);
480  }
481  if (i+3>L-1) {
482  G.set(i,i+3-L,1);
483  }else{
484  G.set(i,i+3,1);
485  }
486  }
487  return G;
488 }
489 
490 itpp::GF2mat common::get_check_code743(int L){//L=7n
491  //return check matrix code code [7,4,3], find definition in research note.pdf
492  itpp::GF2mat G(L,L);
493  for ( int i=0;i<L;i++){
494  G.set(i,i,1);
495  if (i+2>L-1) {
496  G.set(i,i+2-L,1);
497  } else {
498  G.set(i,i+2,1);
499  }
500  if (i+3>L-1) {
501  G.set(i,i+3-L,1);
502  }else{
503  G.set(i,i+3,1);
504  }
505  if (i+4>L-1) {
506  G.set(i,i+4-L,1);
507  }else{
508  G.set(i,i+4,1);
509  }
510  }
511  return G;
512 }
513 itpp::GF2mat common::get_check_rept(int L){//return circulant check matrix for repetition code of length L
514  itpp::GF2mat a(L,L);
515  for (int i=0;i<L-1;i++){//construct a : circulant check matrix for repetition code
516  a.set(i,i,1);
517  a.set(i,i+1,1);
518  }
519  a.set(L-1,L-1,1);
520  a.set(L-1,0,1);
521  //std::cout<<"circulant check matrix for repetition code : a = "<<a<<std::endl;
522  return a;
523 }
524 itpp::GF2mat common::get_check(int generator_flag, int L){
525  //return check matric a for generating toric code, cubic code and hypercubic code.
526  switch(generator_flag){
527  case 1: return get_check_rept(L);break;
528  case 2: return get_check_code734(L);break;
529  case 3: return get_check_code743(L);break;
530  }
531  //default
532  return get_check_rept(L);
533  // return get_check_734(L);//code [7,3,4]
534  // return get_check_743(L);//code [7,4,3]
535  // return get_check_rept(L); //circulant check matrix for repetition code.
536 }
537 /*
538 itpp::LDPC_Code get_test_LDPC_Code(){
539  //convert itpp::GF2mat saved in .mm file to LDPC_Code
540  // itpp::GF2mat G=MM_to_GF2mat(filename);
541  itpp::GF2mat G = get_check_code734(7*2);
542  GF2mat_sparse Gs=G.sparsify();
543  itpp::GF2mat_sparse_alist Gsa;
544  Gsa.from_sparse(Gs);
545  itpp::LDPC_Parity H(Gsa);
546  itpp::LDPC_Code C(&H);
547  return C;
548  }*/
549 
550 itpp::LDPC_Code common::GF2mat_to_LDPC_Code(itpp::GF2mat G){
551  itpp::GF2mat_sparse Gs=G.sparsify();
552  itpp::GF2mat_sparse_alist Gsa;
553  Gsa.from_sparse(Gs);
554  itpp::LDPC_Parity H(Gsa);
555  itpp::LDPC_Code C(&H);
556  return C;
557 }
558 
559 itpp::LDPC_Code common::MM_to_LDPC_Code(char * filename){
560  //convert itpp::GF2mat saved in .mm file to itpp::LDPC_Code
561  itpp::GF2mat G=MM_to_GF2mat(filename);
562  return GF2mat_to_LDPC_Code(G);
563  /*
564 
565  itpp::GF2mat_sparse Gs=G.sparsify();
566  itpp::GF2mat_sparse_alist Gsa;
567  Gsa.from_sparse(Gs);
568  itpp::LDPC_Parity H(Gsa);
569  itpp::LDPC_Code C(&H);
570  return C;*/
571 }
572 
lib.h
lib for general functions, defined within namespace common
get_check_code734
GF2mat get_check_code734(int L)
Definition: concatenation.c:43
common::classical_dist
int classical_dist(itpp::GF2mat G)
Definition: dist.cpp:114
common::get_check
itpp::GF2mat get_check(int generator_flag, int L)
Definition: dist.cpp:524
common::nullSpace
itpp::GF2mat nullSpace(itpp::GF2mat G)
Definition: dist.cpp:133
common::get_check_code734
itpp::GF2mat get_check_code734(int L)
Definition: dist.cpp:471
common::GF2mat_to_LDPC_Code
itpp::LDPC_Code GF2mat_to_LDPC_Code(itpp::GF2mat G)
Definition: dist.cpp:550
MM_to_GF2mat
itpp::GF2mat MM_to_GF2mat(std::string file_name)
Definition: mm_read.cpp:36
get_check_code743
GF2mat get_check_code743(int L)
Definition: concatenation.c:61
common::find_error
itpp::bvec find_error(itpp::bvec e_in, itpp::GF2mat H)
Definition: dist.cpp:446
dist.h
distance related functions, defined within namespace common
mm_write.h
common::INF
const int INF
Definition: dist.h:19
common::quantum_dist_v2
int quantum_dist_v2(itpp::GF2mat G_x, itpp::GF2mat G_z, int flip=0)
Definition: dist.cpp:179
mat_to_MM
int mat_to_MM(itpp::mat G, char *filename)
Definition: mm_write.cpp:75
common::make_it_full_rank
itpp::GF2mat make_it_full_rank(itpp::GF2mat fat)
Definition: lib.cpp:123
common::save_dist
int save_dist(int d, char *filename)
Definition: dist.cpp:73
get_check_rept
GF2mat get_check_rept(int L)
Definition: concatenation.c:85
common::hypergraph_dist
int hypergraph_dist(itpp::GF2mat Aj, itpp::GF2mat Ajplus, int dist_expected, int flip=0)
Definition: dist.cpp:292
common::rand_dist
int rand_dist(itpp::GF2mat C, int perm_try=10)
Definition: dist.cpp:82
common::get_check_code743
itpp::GF2mat get_check_code743(int L)
Definition: dist.cpp:490
common::get_check_rept
itpp::GF2mat get_check_rept(int L)
Definition: dist.cpp:513
common::draw_toric_x_error
int draw_toric_x_error(itpp::bvec error_bits)
Definition: dist.cpp:389
mm_read.h
common::MM_to_LDPC_Code
itpp::LDPC_Code MM_to_LDPC_Code(char *filename)
Definition: dist.cpp:559
common::color_text
std::string color_text(std::string str)
Definition: lib.cpp:32
common::quantum_dist
int quantum_dist(itpp::GF2mat G_x, itpp::GF2mat G_z, int dist_expected, int debug, int flip=0)
Definition: dist.cpp:228
common::getC
itpp::GF2mat getC(itpp::GF2mat G_x, itpp::GF2mat G_z, int flip=0)
Definition: dist.cpp:143
common::min_wt_decoding
int min_wt_decoding(itpp::GF2mat C)
Definition: dist.cpp:12