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

Function test_basic_encoding

test/QAlg/Encode.test.cpp:26–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24 return true;
25}
26static bool test_basic_encoding()
27{
28 auto qvm = new CPUQVM();
29 qvm->init();
30 //std::vector<double>data{ 0.4737709042140123,0.5287790950369405,0.2157088373614705,0.023769834145903144,0.4019987624599187,0.057654140832877024,0.5150212867886899,0.1366183026575457 };
31 //std::vector<double>data{ 1,0,1,1 };
32 string data = "1011";
33 QProg prog;
34 auto q = qvm->qAllocMany((int)data.size());
35 Encode encode_b;
36 encode_b.basic_encode(q, data);
37 prog << encode_b.get_circuit();
38 qvm->directlyRun(prog);
39 auto result = qvm->probRunDict(prog, encode_b.get_out_qubits(), -1);
40 for (auto val : result) {
41 std::cout << val.first << ',' << val.second << std::endl;
42 }
43 destroyQuantumMachine(qvm);
44 return true;
45}
46static bool test_dense_encoding()
47{
48 auto qvm = new CPUQVM();

Callers 1

TESTFunction · 0.85

Calls 8

initMethod · 0.45
qAllocManyMethod · 0.45
sizeMethod · 0.45
basic_encodeMethod · 0.45
get_circuitMethod · 0.45
directlyRunMethod · 0.45
probRunDictMethod · 0.45
get_out_qubitsMethod · 0.45

Tested by

no test coverage detected