量子计算及量子计算的模拟(5)

shor_encode(reg);
    cout << "x bit corruption on bit 8"<< endl;
    (x,i,i,i,i,i,i,i,i).apply_gate_to(reg); // mess up the high order bit
    shor_decode(reg); // try to decode the register

cout << "state: "<< trans(reg.state_vector());

shor_encode(reg);
    cout << "x bit corruption on bit 1"<< endl;
    (i,i,i,i,i,i,i,x,i).apply_gate_to(reg);
    shor_decode(reg);

cout << "state: "<< trans(reg.state_vector());

shor_encode(reg);
    cout << "z bit corruption on bit 8"<< endl;
    (z,i,i,i,i,i,i,i,i).apply_gate_to(reg);
    shor_decode(reg);

cout << "state: "<< trans(reg.state_vector());

cout << "\nThe state of the input qubit survived all the corruptions in tact so the code works."<< endl;

}

编译的方法如下:
Ubuntu:

g++ -std=c++11 -O3 -o quantum_computing_ex quantum_computing_ex.cpp -l dlib -l cblas

macOS:

g++ -std=c++11 -O3 -o quantum_computing_ex quantum_computing_ex.cpp (pkg-config --cflags --libs dlib-1) -l cblas

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/13556.html