CSS product code  0.1
C++ library to estimate distance of CSS codes. Some particular construction of CSS codes are implemented.
product.cpp
Go to the documentation of this file.
1 //Weilei Zeng, Nov 26 2018
8 #include <itpp/itbase.h>
9 #include <ctime> //to get current time
10 using namespace itpp;
11 using namespace std;
12 using namespace common;
13 
14 //int simulate(string title_str, string note, int mode, int sub_mode_A, int sub_mode_B, int n_low, int n_high, int k_low, int k_high, int debug);
15 
16 
28 int simulate(string title_str, string note, int mode, int sub_mode_A, int sub_mode_B,
29  int n_low, int n_high, int k_low, int k_high, int debug,
30  // int na_input, int Gax_row_input, int id_Gax, int Gaz_row_input, int id_Gaz,
32  );
33 
34 int main(int args, char ** argv){
35  itpp::Parser parser;
36  parser.init(args,argv);
37  parser.set_silentmode(true);
38  int num_cores; parser.get(num_cores,"num_cores");
39  int mode = -1; parser.get(mode,"mode"); //default values are illegal, to make sure there is an input value
40  int sub_mode_A = -1; parser.get(sub_mode_A,"sub_mode_A");
41  int sub_mode_B = -1; parser.get(sub_mode_B,"sub_mode_B");
42  std::string title_str="no-title"; parser.get(title_str,"title");
43  std::string note="no-note"; parser.get(note,"note");
44  int debug; //default debug on
45  parser.get(debug,"debug");
46  int seed; parser.get(seed,"seed");
47  // std::cout<<"\t seed:"<<seed;
48  if (debug) std::cout<<"input seed: "<<seed<<" --> ";
49  seed = seed+get_time(3);
50  itpp::RNG_reset(seed);
51  if (debug) std::cout<<"converted seed:"<<seed;
52 
53  //parameters for random simulation
54  int na_input; parser.get(na_input,"na_input");
55  int n_low; parser.get(n_low,"n_low");
56  int n_high; parser.get(n_high,"n_high");
57  int k_low; parser.get(k_low,"k_low");
58  int k_high; parser.get(k_high,"k_high");
59  int max_trial; parser.get(max_trial,"max_trial");
60 
61  Real_Timer timer; timer.tic();
62 
63  //the maximum number of cases to be evaluated is 1 million. Duplicated cases and distance 1 cases are not saved here.
64  const int id_list_max=100000;
65  int id_list[id_list_max][5];
66  // save five number for the input of CSSCode codeA(na,Gax_row,id_Gax,Gaz_row,id_Gaz);
67 
68  switch (mode){
69  case 1:
70  //actually I can run all random simulation here. and let openmp control the threads. Insted of running it one by one
71  //run a random simulation
72  {
73  //allow mode = 1, sub_mode_A = 1; sub_mode_B=1,2,3
74  cout<<"max_trial = "<<max_trial<<endl;
75  int count=0;
76 #pragma omp parallel for schedule(guided) num_threads(num_cores)
77  for ( int i =0; i< max_trial; i++){
78  SubsystemProductCSSCode code_temp;
79  // simulate(title_str, note, mode, sub_mode_A, sub_mode_B, n_low, n_high, k_low, k_high, debug,0,0,0,0,0, code_temp);
80  string title_str_trial = title_str +"-" +to_string(i);
81  simulate(title_str_trial, note, mode, sub_mode_A, sub_mode_B, n_low, n_high, k_low, k_high, debug, code_temp);
82 #pragma omp critical
83  {
84  count++;
85  if ( count % 10 == 0 )
86  cout<<"count="<<count<<endl;
87  }
88  }
89  }
90  break;
91  case 2:
92  {
93  //check a specific case
94  //allow mode = 2, sub_mode_A = 1; sub_mode_B=1,2,3
95  SubsystemProductCSSCode code_temp;
96  // simulate(title_str, note, mode, sub_mode_A, sub_mode_B, 0, 0,0,0, debug,0,0,0,0,0, code_temp);
97  simulate(title_str, note, mode, sub_mode_A, sub_mode_B, 0, 0,0,0, debug, code_temp);
98  }
99  break;
100  case 3: //enumerate all cases with size na
101  {
102  //statistic counts
103  int total_trials=0, calculated_trials=0;//, distance_2_trials=0;
104  int na=na_input;
105  for ( int Gax_row = 1; Gax_row< na-1; Gax_row++){ //loop through Gax_row
106  const int id_Gax_MAX = (int) pow(2, Gax_row * (na-Gax_row) ) -1 ; //maximun when all bits are one
107 #pragma omp parallel for schedule(guided) num_threads(num_cores)
108  for ( int id_Gax = 1; id_Gax < id_Gax_MAX+1 ; id_Gax++){
109  if ( id_Gax % 1000 == 0 )
110  cout<<"start: id_Gax="<<id_Gax<<",\t id_Gax_MAX="<<id_Gax_MAX<<",\t Gax_row="<<Gax_row<<endl;
111  for ( int Gaz_row = 1; Gaz_row< min(Gax_row +1,na-Gax_row); Gaz_row ++){ //check
112  const int id_Gaz_MAX = (int) pow(2, Gaz_row*(na - Gax_row)) - 1; //maximum when all bits are 1
113  for ( int id_Gaz = 1; id_Gaz < id_Gaz_MAX+1 ; id_Gaz++){
114  total_trials++;
115 
116  //run the program. symmetric, reverse symmetric.
117  if (debug) cout<<"Gax_row="<<Gax_row<<",Gaz_row="<<Gaz_row<<endl;
118 
119  //use data wrapper class
120  CSSCode codeA(na,Gax_row,id_Gax,Gaz_row,id_Gaz);
122 
123  //note: to enumerate one CSS code, run it here. to simulate two codes, generate all code here, then run it later.
124  // if (sub_mode_B ==4){ //enumerate code B as well.
125  // if ( generate_code(Gax, Gaz, na, Gax_row, id_Gax, Gaz_row, id_Gaz, debug) ==2 ){
126 
127  if ( codeA.generate_by_id(debug) == 2){
128  if (debug) cout<<"duplicated case, return 2"<<endl;
129  // cout<<"*";
130  // return 2;
131  }else{
132  //it is valid code, save it for running later
133 
134  int id[5] = {na,Gax_row,id_Gax,Gaz_row,id_Gaz};
135  //cout<<"save id when calculated_trials = "<<calculated_trials<<endl;
136 #pragma omp critical
137  {
138  for ( int i_id = 0; i_id < 5; i_id ++) id_list[calculated_trials][i_id] = id[i_id];
139  calculated_trials++;
140  // cout<<calculated_trials<<"/"<<( total_trials/1000000 )<<"M"<<endl;
141  }
142  }
143  // }
144 
145  // sub_mode_A=2;//enumerate all cases
146  // sub_mode_B=2;//reverse identical code A and B
147  // cout<<title_str.c_str()<<endl;
148  string title_str_trial=title_str+"-na"+to_string(na)+"-Gax_row"+to_string(Gax_row)+"-id_Gax"+to_string(id_Gax)
149  +"-Gaz_row"+to_string(Gaz_row)+"-id_Gaz"+to_string(id_Gaz);
150  }
151  }
152  }
153  }
154 
155  // cout<<calculated_trials<<"/"<<( total_trials/1000000 )<<"M"<<endl;
156  cout<<"start calculating for "<< calculated_trials<<" cases out of "<<total_trials<<" trials."<<endl;
157  cout<<"time used: "<<timer.toc()<< " sec"<<endl;
158  timer.tic();
159 
160  if ( sub_mode_A != 2)
161  cout<<"wrong input or no input for sub_mode_A. It should be 2"<<endl;
162 
163  sub_mode_A=2;//enumerate all cases. must be 2 at this point
164  // sub_mode_B=2;//reverse identical code A and B
165  switch ( sub_mode_B ){
166  case 2:
167 
168  {
169  int count=0;
170 #pragma omp parallel for schedule(guided) num_threads(num_cores)
171  for (int iAB = 0; iAB <calculated_trials; iAB++){
172 #pragma omp critical
173  {
174  count ++;
175  if ( count % 10 == 0){
176  cout<<count*100/calculated_trials<<"% finished. total: "<<calculated_trials
177  <<", remaining time:"<<timer.toc()/count*(calculated_trials-count)/60<<" min"
178  <<endl;
179  }
180  }
181  int iA = iAB ;
182  // int iB = iAB ;
183  // if ( iA > iB ) continue; //remove duplicate
184 
185  CSSCode codeA(id_list[iA][0],id_list[iA][1],id_list[iA][2],id_list[iA][3],id_list[iA][4]);
186  // CSSCode codeB(id_list[iB][0],id_list[iB][1],id_list[iB][2],id_list[iB][3],id_list[iB][4]);
187  CSSCode codeB; //codeB will be the same as codeA, or reverse symmetric codeA
188  SubsystemProductCSSCode codeC(codeA,codeB);
189  //string title_str_trial=title_str+"-test";
190  string title_str_trial=title_str+"-na"+to_string(codeA.n)+"-Gax_row"+to_string(codeA.Gx_row)+"-id_Gax"+to_string(codeA.id_Gx)
191  +"-Gaz_row"+to_string(codeA.Gz_row)+"-id_Gaz"+to_string(codeA.id_Gz);
192  // if (simulate(title_str_trial, note, mode, sub_mode_A, sub_mode_B, 0, 0, 0, 0, debug, na, Gax_row, id_Gax, Gaz_row, id_Gaz, codeC)==2){
193  // simulate(title_str_trial, note, mode, sub_mode_A, sub_mode_B, 0, 0, 0, 0, debug, 0,0,0,0,0, codeC);
194  // simulate(title_str_trial, note, mode, sub_mode_A, 3, 0, 0, 0, 0, debug, 0,0,0,0,0, codeC);
195 
196  simulate(title_str_trial, note, mode, sub_mode_A, sub_mode_B, 0, 0, 0, 0, debug, codeC);
197  simulate(title_str_trial, note, mode, sub_mode_A, 3, 0, 0, 0, 0, debug, codeC);
198  }
199  }
200  break;// sub_mode_B = 2; // include 3
201  case 4:
202  {
203  int count=0;
204  const int total = calculated_trials*calculated_trials;
205  const int chunk_size_max = 10000; //chunk to display progress
206  const int chunk_size = ( total/100 < chunk_size_max ) ? total/100:chunk_size_max ;
207  // count = total/10*7; // start from some point, 50%, 70%, ...
208  // cout<<"start from count = "<<count<<endl;
209  //guided for better speed
210 #pragma omp parallel for schedule(guided) num_threads(num_cores)
211  //
212  //#pragma omp parallel for schedule(dynamical,1) num_threads(num_cores)
213  for (int iAB = count; iAB <total; iAB++){
214 #pragma omp critical
215  {
216  //display progress information
217  count++;
218  if (count % chunk_size == 0){
219  cout<<count<<", "<<(int) (count*1.0/total*100)<<"% finished. total: "<<total
220  <<", remaining time:"<<timer.toc()/count*(total-count)/60<<" min"
221  <<endl;
222  }
223  }
224  int iA = iAB / calculated_trials;
225  int iB = iAB % calculated_trials;
226  if ( iA < iB ) continue; //remove duplicate
227  // cout<<"iA="<<iA<<", iB = "<<iB<<endl;
228  CSSCode codeA(id_list[iA][0],id_list[iA][1],id_list[iA][2],id_list[iA][3],id_list[iA][4]);
229  CSSCode codeB(id_list[iB][0],id_list[iB][1],id_list[iB][2],id_list[iB][3],id_list[iB][4]);
230  SubsystemProductCSSCode codeC(codeA,codeB);
231  // string title_str_trial=title_str+"-test";
232  string title_str_trial=title_str
233  +"-A-"+to_string(codeA.n)+"-"+to_string(codeA.Gx_row)+"-"+to_string(codeA.id_Gx)
234  +"-"+to_string(codeA.Gz_row)+"-"+to_string(codeA.id_Gz)
235  +"-B-"+to_string(codeB.n)+"-"+to_string(codeB.Gx_row)+"-"+to_string(codeB.id_Gx)
236  +"-"+to_string(codeB.Gz_row)+"-"+to_string(codeB.id_Gz);
237 
238  // string title_str_trial=title_str+"-na"+to_string(na)+"-Gax_row"+to_string(Gax_row)+"-id_Gax"+to_string(id_Gax)
239  // +"-Gaz_row"+to_string(Gaz_row)+"-id_Gaz"+to_string(id_Gaz);
240  // if (simulate(title_str_trial, note, mode, sub_mode_A, sub_mode_B, 0, 0, 0, 0, debug, na, Gax_row, id_Gax, Gaz_row, id_Gaz, codeC)==2){
241  // simulate(title_str_trial, note, mode, sub_mode_A, sub_mode_B, 0, 0, 0, 0, debug, 0,0,0,0,0, codeC)
242  simulate(title_str_trial, note, mode, sub_mode_A, sub_mode_B, 0, 0, 0, 0, debug, codeC);
243 
244  }
245  }
246  break;//sub_mode_B=4
247  default:
248  cout<<"main(): illegal sub_mode_B value"<<sub_mode_B<<endl;
249  throw 2;
250  }//switch (sub_mode_B)
251 }// mode=3
252 
253  break;
254  default:
255  cout<<"main(): illegal mode value"<<endl;
256  throw 2;
257  }
258  return 0;
259 }
260 
261 int simulate(string title_str, string note, int mode, int sub_mode_A, int sub_mode_B, //general info
262  int n_low, int n_high, int k_low, int k_high, int debug, //for random simulation
263  //int na_input, int Gax_row_input, int id_Gax, int Gaz_row_input, int id_Gaz, //for enumarating all cases
265  ){
266  //return 2 when the code is duplicate, or either dax = 1 or daz = 1
267  if ( mode == 3) mode =1; //mode 3 do some preprocessing in main()
268 
269  Real_Timer timer; timer.tic();
270  GF2mat Gax,Gaz,Cax,Caz;
271  GF2mat Gbx,Gbz,Cbx,Cbz;
272  int na,ka, Gax_row,Gaz_row;//k is not necessary number of qubits
273  int nb,kb, Gbx_row,Gbz_row;
274  int id_Gbx, id_Gbz;
275  // int flag_save_matrices=0; // use flag_chain_complex
276 
277  //only save for cases
278  const char * title = title_str.c_str();
279  char filename_Gax[256];char filename_Gaz[256];char filename_Gbx[256];char filename_Gbz[256];
280  sprintf(filename_Gax,"%sGax.mm",title); sprintf(filename_Gaz,"%sGaz.mm",title); sprintf(filename_Gbx,"%sGbx.mm",title); sprintf(filename_Gbz,"%sGbz.mm",title);
281 
282  // int sub_mode_A=1;
283  if (debug) cout<<mode<<endl<<title<<endl;
284  switch( mode ){
285  case 1://generate random codes and save
286  switch ( sub_mode_A ){//sub mode for code A
287  case 1: //generate a random CSS code with distance > 1
288  na=randi(n_low,n_high); ka = randi(k_low,k_high);Gax_row=randi(1,na-ka-1); Gaz_row=na-ka-Gax_row;
289  getGoodQuantumCode(na,Gax_row,Gaz_row,Gax,Gaz,Cax,Caz,debug);
290  //getRandomQuantumCode(na,Gax_row,Gaz_row,Gax,Gaz,Cax,Caz);
291  break;
292  case 2://enumerate all codes with size na
293  //input: na, Gax_row, ...
294  {
295  // na=na_input; Gax_row=Gax_row_input; Gaz_row=Gaz_row_input;
296 
297 
298  // cout<<"debug"<<endl;
299  if ( code.codeA.is_defined == 0 )
300  cout<<"code A is not defined,"<<endl;
301 
302  na = code.codeA.n;
303  Gax_row = code.codeA.Gx_row;
304  Gaz_row = code.codeA.Gz_row;
305 
306  // cout<<"code.codeA.n = "<<code.codeA.n<<endl;
307  //debug=1;
308  if ( code.codeA.generate_by_id(debug) == 2){
309  if (debug) cout<<"duplicated case, return 2"<<endl;
310  return 2;
311  }
312  Gax = code.codeA.Gx;
313  Gaz = code.codeA.Gz;
314  // cout<<Gax<<endl;
315 
316  /* if ( generate_code(Gax, Gaz, na, Gax_row, id_Gax, Gaz_row, id_Gaz, debug) ==2 ){
317  if (debug) cout<<"duplicated case, return 2"<<endl;
318  return 2;
319  }*/
320  Cax=getC(Gax,Gaz);
321  Caz=getC(Gax,Gaz,1);
322  }
323  break;
324  default:
325  cout<<"simulate(): illegal sub_mode_A value"<<endl;
326  throw 2;
327  break;
328  }
329 
330  switch ( sub_mode_B ){
331  case 1: //two random codes
332 
333  //random code B
334  nb=randi(n_low,n_high); kb = randi(k_low,k_high);Gbx_row=randi(1,nb-kb-1); Gbz_row=nb-kb-Gbx_row;
335  getGoodQuantumCode(nb,Gbx_row,Gbz_row,Gbx,Gbz,Cbx,Cbz,debug);
336  break;
337  case 2: // use identical reverse code A for code B
338  //reverse X and Z of code A for code B
339  kb=ka;
340  nb=na;
341  Gbx_row=Gaz_row;
342  Gbz_row=Gax_row;
343  Gbx=Gaz;
344  Gbz=Gax;
345  Cbx=Caz;
346  Cbz=Cax;
347  break;
348  case 3: //use identical code A for code B
349  kb=ka;
350  nb=na;
351  Gbx_row=Gax_row;
352  Gbz_row=Gaz_row;
353  Gbx=Gax;
354  Gbz=Gaz;
355  Cbx=Cax;
356  Cbz=Caz;
357  break;
358  case 4: //enumerate all codes with size nb=na
359  //input: na, Gax_row, ...
360  {
361  // cout<<"running sub_mode_B =4"<<endl;
362  if ( code.codeB.generate_by_id(debug) == 2){
363  if (debug) cout<<"duplicated case, return 2"<<endl;
364  return 2;
365  }
366  // na=na_input; Gax_row=Gax_row_input; Gaz_row=Gaz_row_input;
367  nb=code.codeB.n; Gbx_row=code.codeB.Gx_row; Gbz_row=code.codeB.Gz_row;
368  id_Gbx=code.codeB.id_Gx; id_Gbz=code.codeB.id_Gz;
369  /*
370  if ( generate_code(Gbx, Gbz, nb, Gbx_row, id_Gbx, Gbz_row, id_Gbz, debug) ==2 ){
371  if (debug) cout<<"duplicated case, return 2"<<endl;
372  // cout<<"*";
373  return 2;
374  }*/
375  Gbx=code.codeB.Gx;
376  Gbz=code.codeB.Gz;
377 
378  Cbx=getC(Gbx,Gbz);
379  Cbz=getC(Gbx,Gbz,1);
380  }
381  break;
382 
383  default:
384  cout<<"simulate(): illegal sub_mode_A value"<<endl;
385  throw 2;
386  break;
387 
388  }
389  // cout<<"got two good quantum code"<<endl;
390  break;
391  case 2: //from given input. This is to manually double check some result
392  if (debug) cout<<"check "<<title<<endl;
393  Gax=MM_to_GF2mat(filename_Gax); Gaz=MM_to_GF2mat(filename_Gaz);
394  Gbx=MM_to_GF2mat(filename_Gbx); Gbz=MM_to_GF2mat(filename_Gbz);
395  na=Gax.cols();
396  nb=Gbx.cols();
397 
398  Cax=getC(Gax,Gaz);
399  Caz=getC(Gax,Gaz,1);
400  Cbx=getC(Gbx,Gbz);
401  Cbz=getC(Gbx,Gbz,1);
402 
403  //manually change code B for a quick check, because submode_B=2 is not saved in file, onl submode_B=3
404  if (false){
405  kb=ka;
406  nb=na;
407  Gbx_row=Gaz_row;
408  Gbz_row=Gax_row;
409  Gbx=Gaz;
410  Gbz=Gax;
411  Cbx=Caz;
412  Cbz=Cax;
413  }
414 
415 
416  if (debug) {cout<<"Gax "<<Gax<<endl; cout<<"Gaz "<<Gaz<<endl; cout<<"Cax "<<Cax<<endl; cout<<"Caz "<<Caz<<endl;}
417  if (debug) { cout<<"Gbx "<<Gbx<<endl; cout<<"Gbz "<<Gbz<<endl; cout<<"Cbx "<<Cbx<<endl; cout<<"Cbz "<<Cbz<<endl;}
418  // cout<<"debug"<<endl;
419  break;
420  }
421 
422 
423 
424 
425  // cout<<"check code A"<<endl;
426  if (! is_quantum_code(Gax,Gaz,Cax,Caz)) throw "invalid code";
427 
428  int dax = quantum_dist_v2(Gax,Gaz);
429  int daz = quantum_dist_v2(Gax,Gaz,1);
430 
431  //there is no valid reason to discard this case. For test purpose, this make the program much faster and should not miss a real case
432  /* if ( dax ==2 && daz == 2){
433  // cout<<"=";
434  return 2;
435  }*/
436 
437  // cout<<"sub_mode_B="<<sub_mode_B<<",na="<<na<<",Gax_row="<<Gax_row<<",id_Gax="<<id_Gax<<",Gaz_row="<<Gaz_row<<", id_Gaz="<<id_Gaz;
438  // cout<<",dax="<<dax<<",daz="<<daz;
439  // cout<<endl;
440 
441  // cout<<"check code B"<<endl;
442  if ( ! is_quantum_code(Gbx,Gbz,Cbx,Cbz)) throw "invalid code";
443  // cout<<"Gbx "<<Gbx<<endl; cout<<"Gbz "<<Gbz<<endl; cout<<"Cbx "<<Cbx<<endl; cout<<"Cbz "<<Cbz<<endl;
444  int dbx = quantum_dist_v2(Gbx,Gbz);
445  int dbz = quantum_dist_v2(Gbx,Gbz,1);//1 to flip X and Z
446 
447 
448  /*if ( debug) {
449  cout<<"[Code A] na = "<<na<<", ";
450  cout<<"dax = "<<dax<<", daz = "<<daz<<endl;
451  cout<<"[Code B] nb = "<<nb<<", ";
452  cout<<"dbx = "<<dbx<<", dbz = "<<dbz<<endl;
453  }*/
454 
455  // reduce(Gax,Gaz,Gbx,Gbz,dax,daz,dbx,dbz);
456  //concatenate(Gax,Gaz,Gbx,Gbz,dax,daz,dbx,dbz);
457  int flag_chain_complex=0; //run if 1
458  //0 for reduce/subsystem, distance x
459  if (product(Gax,Gaz,Gbx,Gbz,dax,daz,dbx,dbz,debug,0) == 2) {
460  std::cout<<title<<","<<note<<", time:"<<timer.toc()<<std::endl;
461  flag_chain_complex=1;
462  }
463  //1 for reduce/subsystem, distance z
464  if (product(Gax,Gaz,Gbx,Gbz,dax,daz,dbx,dbz,debug,1) == 2){
465  std::cout<<title<<","<<note<<", time:"<<timer.toc()<<std::endl;
466  // std::cout<<title<<","<<note<<std::endl;
467  // std::cout<<title<<","<<note<<", sub_mode:"<<sub_mode<<std::endl;
468  // std::cout<<title<<std::endl;
469  flag_chain_complex=1;
470  }
471  //2 for concatenate
472  // if ( product(Gax,Gaz,Gbx,Gbz,dax,daz,dbx,dbz,debug,2) == 2) std::cout<<title<<std::endl;
473  // flag_chain_complex=1; //force estimate the chain complex code
474  if ( flag_chain_complex ){
475  //save code A B
476  if ( mode ==1 ){
477  GF2mat_to_MM(Gax,filename_Gax); GF2mat_to_MM(Gaz,filename_Gaz);
478  GF2mat_to_MM(Gbx,filename_Gbx); GF2mat_to_MM(Gbz,filename_Gbz);
479  }
480 
481 
482  // 3 for chain complex with two length-3, z distance
483  // 4 for chain complex with two length-3, x distance
484  // cout<<"mode 3 4"<<endl;
485  if (product(Gax,Gaz,Gbx,Gbz,dax,daz,dbx,dbz,debug,3) == 2)
486  std::cout<<title<<","<<note<<", time:"<<timer.toc()<<std::endl;
487 
488  // if ( mode == 1 && sub_mode_A == 2 && sub_mode_B == 4){ // this cannot be used because it was removed when generating the code by saying Gx_row <= Gz_row
489  //pass
490  //no need to calculate it because all codes will be enumerated, hence include a symmetry between X and Z
491 
492  if (product(Gax,Gaz,Gbx,Gbz,dax,daz,dbx,dbz,debug,4) == 2)
493  std::cout<<title<<","<<note<<", time:"<<timer.toc()<<std::endl;
494 
495 
496  //check rank
497  /*
498  if (Gax.row_rank() < Gax.rows())
499  cout<<common::red_text("Gax not full rank")<<endl;
500  if (Gaz.row_rank() < Gaz.rows())
501  cout<<common::red_text("Gaz not full rank")<<endl;
502  if (Gbx.row_rank() < Gbx.rows())
503  cout<<common::red_text("Gbx not full rank")<<endl;
504  if (Gbz.row_rank() < Gbz.rows())
505  cout<<common::red_text("Gbz not full rank")<<endl;
506  */
507 
508  }
509 
510  if ( debug ) timer.toc_print();
511  return 0;
512 }
CSSCode::Gz
itpp::GF2mat Gz
Definition: product_lib.h:57
common::get_time
int get_time(int mode=1)
Definition: lib.cpp:53
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
MM_to_GF2mat
itpp::GF2mat MM_to_GF2mat(std::string file_name)
Definition: mm_read.cpp:36
CSSCode::is_defined
int is_defined
Definition: product_lib.h:66
weilei_lib.h
this file links all other headfiles in this folder.
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
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
GF2mat_to_MM
int GF2mat_to_MM(itpp::GF2mat G, char *file_name, int debug)
Definition: mm_write.cpp:18
CSSCode::generate_by_id
int generate_by_id(int debug)
Definition: product_lib.cpp:80
common::quantum_dist_v2
int quantum_dist_v2(itpp::GF2mat G_x, itpp::GF2mat G_z, int flip=0)
Definition: dist.cpp:179
main
int main(int args, char **argv)
Definition: product.cpp:34
ProductCSSCode::codeB
CSSCode codeB
Definition: product_lib.h:101
CSSCode::n
int n
Definition: product_lib.h:61
simulate
int simulate(string title_str, string note, int mode, int sub_mode_A, int sub_mode_B, int n_low, int n_high, int k_low, int k_high, int debug, SubsystemProductCSSCode code)
Definition: product.cpp:261
CSSCode::Gx_row
int Gx_row
Definition: product_lib.h:62
ProductCSSCode::codeA
CSSCode codeA
Definition: product_lib.h:101
CSSCode::Gz_row
int Gz_row
Definition: product_lib.h:62
common::getC
itpp::GF2mat getC(itpp::GF2mat G_x, itpp::GF2mat G_z, int flip=0)
Definition: dist.cpp:143
CSSCode::id_Gx
int id_Gx
Definition: product_lib.h:63
common
common function shared by many program
Definition: dist.h:15
CSSCode
Definition: product_lib.h:54
common::is_quantum_code
bool is_quantum_code(itpp::GF2mat &G_x, itpp::GF2mat &G_z)
Definition: lib.cpp:77