13 #include <itpp/itbase.h>
39 return "\033[1;31m"+str+
"\033[0m";
44 return "\033[1;34m"+str+
"\033[0m";
55 auto now = std::chrono::system_clock::now();
57 auto value = now.time_since_epoch();
58 long duration = value.count();
60 const int DIGIT=1000000000;
63 t = ( duration / 100000000 ) % DIGIT ;
66 t = (duration / 100000) % DIGIT;
79 if (G_x.row_rank()+G_z.row_rank() < G_x.cols()){
80 if ( (G_x*G_z.transpose()).is_zero()){
83 std::cout<<
"Not a quantum code:pertation relation is not satisfied."<<std::endl;
86 std::cout<<
"Not a quantum code: zero rank for codeword space."<<std::endl;
92 if (!(Gx*Gz.transpose()).is_zero()){
93 std::cout<<
"(Gx*Gz.transpose()) is not zero"<<std::endl;
97 if (!(Gx*Cz.transpose()).is_zero()){
99 std::cout<<
"(Gx*Cz.transpose()) is not zero"<<std::endl;
return false;
101 if (!(Gz*Cx.transpose()).is_zero()){
103 std::cout<<
"(Gz*Cx.transpose()) is not zero"<<std::endl;
return false;
105 int rank_of_Gx=Gx.row_rank();
106 int rank_of_Gz=Gz.row_rank();
107 int rank_of_Cx=Cx.row_rank();
108 int rank_of_Cz=Cz.row_rank();
110 if (rank_of_Gx+rank_of_Gz+rank_of_Cx != n){
111 std::cout<<
"(rank_of_Gx+rank_of_Gz+rank_of_Cx != n)"<<std::endl;
114 if(rank_of_Cx != rank_of_Cz){
115 std::cout<<
"(rank_of_Cx != rank_of_Cz)"<<std::endl;
return false;
125 itpp::GF2mat thin, T,U;
127 int rank = fat.T_fact(T,U,P);
128 if (rank == fat.rows()){
131 thin = U.get_submatrix(0,0,rank-1,U.cols()-1);
132 thin.permute_cols(P,
true);
147 std::cout<<
"GF2mat "<<name<<
", size = ("<<G.rows()<<
","<<G.cols()<<
"), density = "
148 <<G.density()<<std::endl;
155 std::cout<<
"mat "<<name<<
", size = ("<<G.rows()<<
","<<G.cols()<<
")"<<std::endl;
173 itpp::GF2mat G(1,1+A.cols()*B.cols());
174 itpp::GF2mat zero(A.rows(),A.cols());
175 for (
int i=0;i<B.rows();i++){
176 itpp::GF2mat G_row(A.rows(),1);
177 for (
int j=0;j<B.cols();j++){
180 G_row = G_row.concatenate_horizontal(A);
182 G_row = G_row.concatenate_horizontal(zero);
186 G = G.concatenate_vertical(G_row);
190 G=G.get_submatrix(1,1,G.rows()-1,G.cols()-1);
197 std::ostringstream o;
205 G.set_size(G.rows()+1,G.cols(),
true);
206 G.set_row(G.rows()-1,b);
212 sprintf(filename,
"%s%s",filename_prefix,filename_suffix);
218 char filename_full[255];
219 sprintf(filename_full,
"%s/%s/%s",parent_folder, folder, filename);
231 w=E.get_submatrix(1,0,E.rows()-1,E.cols()-1).density();
241 fout =fopen(filename.c_str(),
"w");
242 fprintf(fout,
"%s\n",header.c_str());
243 int row=data.rows(), col=data.cols();
244 for (
int i =0;i<row;i++){
245 for (
int j=0;j<col;j++){
246 fprintf(fout,
"%f\t",data.get(i,j));