MCPcopy Create free account
hub / github.com/OriginQ/QPanda-2 / test_ds_quantum_state_preparation_encoding

Function test_ds_quantum_state_preparation_encoding

test/QAlg/Encode.test.cpp:67–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65 return true;
66}
67static bool test_ds_quantum_state_preparation_encoding()
68{
69 auto qvm = new CPUQVM();
70 qvm->init();
71 //std::vector<double>data{ -0.33164128327780906,-0.23433373435840027,-0.00022877626650846954,0.3466895582845477,0.36968371696590785,-0.21966111818142703,-0.28122454968118343,0.2954805505078439,0.2060812114310625,0.28816304973225565,0.13470785340813266,0.06207383012753573,-0.14157790059772607,0.15044744783305566,-0.28050173370498876,-0.3077795693383025 };
72 std::vector<double>data{ 0.15311858100051695,-0.0961350374871273,0.3859320687001368,-0.5634457467385428,0.1474901012487757,-0.45185782723129864,0.32284355187278985,-0.4132085412578166 };
73 QProg prog;
74 auto q = qvm->qAllocMany(15);
75 Encode encode_b;
76 std::map<std::string, double>mp;
77 std::map<std::string, std::complex<double>>mp1;
78 mp["000"] = -0.4012058758884066;
79 mp["001"] = 0.9121413556170931;
80 mp["111"] = 0.08385697660676902;
81 mp1["000"].real(0.37126468505062743);
82 mp1["000"].imag(0.44434564717341857);
83 mp1["001"].real(0.19987861562923684);
84 mp1["001"].imag(0.3401208369570892);
85 mp1["010"].real(0.5299242678696047);
86 mp1["010"].imag(0.25498511099003784);
87 mp1["100"].real(0.19536627105888826);
88 mp1["100"].imag(0.3536675252024842);
89 encode_b.ds_quantum_state_preparation(q, data);
90 prog << encode_b.get_circuit() << BARRIER(q);
91 QVec out_qubits = encode_b.get_out_qubits();
92 std::cout << prog << std::endl;
93 auto result = qvm->probRunDict(prog, out_qubits, -1);
94 //double normalization_constant = encode_b.get_normalization_constant();
95 for (auto &val : result)
96 {
97 std::cout << val.first << ":" << val.second << std::endl;
98 }
99 destroyQuantumMachine(qvm);
100 return true;
101}
102static bool test_sparse_isometry_encoding()
103{
104 auto qvm = new CPUQVM();

Callers 1

TESTFunction · 0.85

Calls 9

BARRIERClass · 0.85
initMethod · 0.45
qAllocManyMethod · 0.45
realMethod · 0.45
imagMethod · 0.45
get_circuitMethod · 0.45
get_out_qubitsMethod · 0.45
probRunDictMethod · 0.45

Tested by

no test coverage detected