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

Function test_angle_encoding

test/QAlg/Encode.test.cpp:7–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5using namespace std;
6
7static bool test_angle_encoding()
8{
9 auto qvm = new CPUQVM();
10 qvm->init();
11 //std::vector<double>data{ 0.4737709042140123,0.5287790950369405,0.2157088373614705,0.023769834145903144,0.4019987624599187,0.057654140832877024,0.5150212867886899,0.1366183026575457 };
12 std::vector<double>data{ PI,PI,PI };
13 QProg prog;
14 auto q = qvm->qAllocMany((int)data.size());
15 Encode encode_b;
16 encode_b.angle_encode(q, data);
17 prog << encode_b.get_circuit();
18std:; cout << prog << std::endl;
19 auto result = qvm->probRunDict(prog, q, -1);
20 for (auto &val : result) {
21 std::cout << val.first << ":" << val.second << std::endl;
22 }
23 destroyQuantumMachine(qvm);
24 return true;
25}
26static bool test_basic_encoding()
27{
28 auto qvm = new CPUQVM();

Callers 1

TESTFunction · 0.85

Calls 6

initMethod · 0.45
qAllocManyMethod · 0.45
sizeMethod · 0.45
angle_encodeMethod · 0.45
get_circuitMethod · 0.45
probRunDictMethod · 0.45

Tested by

no test coverage detected