diff --git a/bp_test.c b/bp_test.c new file mode 100644 index 0000000..25db53f --- /dev/null +++ b/bp_test.c @@ -0,0 +1,334 @@ +//Weilei Apr 5, write a test for bp deocoding, using steane 5 qubit code + + +// copied from my_bp_1.c +#include +#include +#include +#include +#include +#include +#include +#include "my_lib.h" +#include +using namespace std; +using namespace itpp; + + + +// Read the code from files and do BP decoding +//input:source file for stabilzier matrix; error propability p ; + +int decode( GF2mat G, GF2mat H, double p, mat * data, int col_index, int row_index); + + +int main(int argc, char **argv){ + Parser parser; + parser.init(argc,argv); + //p.set_silentmode(true); + string filename_G, filename_H, filename_result; + //parser.get(filename_G,"filename_G"); + //parser.get(filename_H,"filename_H"); + //parser.get(filename_result,"filename_result"); + + vector> pool; + vector>::size_type pool_size=15; + std::chrono::milliseconds span (100); + //change parameter p, code size + //char * filename_result=argv[3];//prefix for the file + double p; + //parser.get(p,"p"); + int sizes[]= {13,11,9,7,5}; + string stabilizer_folder="data/toric/stabilizer"; + //string error_folder="data/toric/bp_decoding4"; + mat data(50,5*5); //return result in a mat, 5 columns for each size. format defines in header + data.zeros(); + int col_index=-5; + for ( int size : sizes){ + // cout<<"size = "< -3;ip-=0.1){ + //cout<<"ip = "<= pool_size ){ + //wait until some of them finish + //break; + for(vector > :: iterator it = pool.begin(); it != pool.end(); ++it){ + //printf("%d", *it); + if ( it->wait_for(span) == future_status::ready){ + cout<<"."<0){ + cout<0){ + break; + } + // usleep(100000); + //cout<<"iteration: "<=0){ + if ( current_iteration < 0 ){ + //cout< +using namespace std; +using namespace itpp; + + + +// Read the code from files and do BP decoding +//input:source file for stabilzier matrix; error propability p ; + +int decode( GF2mat G, GF2mat H, double p, mat * data, int col_index, int row_index); + +int main(int argc, char **argv){ + Parser parser; + parser.init(argc,argv); + //p.set_silentmode(true); + string filename_G, filename_H, filename_result; + //parser.get(filename_G,"filename_G"); + //parser.get(filename_H,"filename_H"); + //parser.get(filename_result,"filename_result"); + + vector> pool; + vector>::size_type pool_size=15; + std::chrono::milliseconds span (100); + //change parameter p, code size + //char * filename_result=argv[3];//prefix for the file + double p; + //parser.get(p,"p"); + int sizes[]= {13,11,9,7,5}; + string stabilizer_folder="data/toric/stabilizer"; + //string error_folder="data/toric/bp_decoding4"; + mat data(50,5*5); //return result in a mat, 5 columns for each size. format defines in header + data.zeros(); + int col_index=-5; + for ( int size : sizes){ + // cout<<"size = "< -3;ip-=0.1){ + //cout<<"ip = "<= pool_size ){ + //wait until some of them finish + //break; + for(vector > :: iterator it = pool.begin(); it != pool.end(); ++it){ + //printf("%d", *it); + if ( it->wait_for(span) == future_status::ready){ + cout<<"."<0){ + cout<0){ + break; + } + // usleep(100000); + //cout<<"iteration: "<=0){ + if ( current_iteration < 0 ){ + //cout<=0){ if ( current_iteration < 0 ){ @@ -320,9 +320,9 @@ cout<<"rec_bits"<set(row_index,col_index,p); data->set(row_index,col_index+1,rate_converge); - data->set(row_index,col_index+2,1.0*counts_weight_zero/cycles); - data->set(row_index,col_index+3,1.0*counts_weight_one/cycles); - data->set(row_index,col_index+4,1.0*counts_weight_two/cycles); + //data->set(row_index,col_index+2,1.0*counts_weight_zero/cycles); + //data->set(row_index,col_index+3,1.0*counts_weight_one/cycles); + //data->set(row_index,col_index+4,1.0*counts_weight_two/cycles); //data->set(row_index,col_index+2,rate_converge); timer.toc_print(); diff --git a/my_bp1.out b/my_bp1.out index 82ae267..eec3906 100755 Binary files a/my_bp1.out and b/my_bp1.out differ diff --git a/temp/async_test.c b/old/async_test.c similarity index 100% rename from temp/async_test.c rename to old/async_test.c diff --git a/temp/async_test.out b/old/async_test.out similarity index 100% rename from temp/async_test.out rename to old/async_test.out diff --git a/temp/makefile b/old/makefile similarity index 100% rename from temp/makefile rename to old/makefile diff --git a/temp/prime_calculator.c b/old/prime_calculator.c similarity index 100% rename from temp/prime_calculator.c rename to old/prime_calculator.c diff --git a/pattern_observer.out b/pattern_observer.out index 141037e..0bfa72e 100755 Binary files a/pattern_observer.out and b/pattern_observer.out differ diff --git a/readme.md b/readme.md index e1bdaf7..dd87beb 100644 --- a/readme.md +++ b/readme.md @@ -10,5 +10,9 @@ - Apr 4 - [x] plot result. - [x] plotted counts for errors with weight 0, 1, 2 respectively. Those counts are smaller than the converged error. Because in large-weight errors, there will be single error as well. Hence these counts are not meaningful. For a meaningful comparison, one should plot the weight of the errors, instead of counts. This comparison has been done before, hence not shown here. For reference see "Weilei Research Note.pdf" - - [ ] replace bp decoding + - [x] check iteration, see improvement about 20-30% in converge rate. no threshold. +- APr 5 + - [x] replace bp decoding using syndrome based and LLR simplied. Passing test with 7 qubit code + - [ ] test repetition code + - [ ] test toric code and check result diff --git a/test.c b/test.c index f8fa815..6cb38f1 100644 --- a/test.c +++ b/test.c @@ -1,9 +1,17 @@ // CPP program to demonstrate multithreading // using three different callables. +#include #include #include +#include +#include +#include "my_lib.h" +#include + using namespace std; +using namespace itpp; + // A dummy function void foo(int Z) @@ -25,7 +33,9 @@ class thread_obj { } }; -int main() +//cannot compile unless it is in main() +/* +int thread_test() { cout << "Threads 1 and 2 and 3 " "operating independently" << endl; @@ -64,3 +74,48 @@ int main() return 0; } +*/ + +int bp_test(){ + cout<<"Test the bp_syndrome_llr function"<