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

Function test_bid_Amplitude_encoding

test/QAlg/Encode.test.cpp:369–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367 return true;
368}
369static bool test_bid_Amplitude_encoding()
370{
371 auto qvm = new CPUQVM();
372 qvm->init();
373 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 };
374 //std::vector<double>data{ 0.15311858100051695,-0.0961350374871273,0.3859320687001368,-0.5634457467385428,0.1474901012487757,-0.45185782723129864,0.32284355187278985,-0.4132085412578166 };
375 //std::vector<double>data{1.5,1.3,1.2,1.11,1.6,1.9,1.7};
376 QProg prog;
377 auto q = qvm->qAllocMany(15);
378 Encode encode_b;
379 encode_b.bid_amplitude_encode(q, data);
380 prog << encode_b.get_circuit() << BARRIER(q);
381 std::cout << prog << std::endl;
382 QVec out_qubits = encode_b.get_out_qubits();
383 auto result = qvm->probRunDict(prog, out_qubits, -1);
384 int k = 0;
385
386 for (auto &val : result)
387 {
388 double temp = k >= (int)data.size() ? 0 : data[k];
389 std::cout << val.first << ":" << val.second << std::endl;
390 ++k;
391 }
392 destroyQuantumMachine(qvm);
393 return true;
394}
395
396static bool test_iqp_Amplitude_encoding()
397{

Callers 1

TESTFunction · 0.85

Calls 8

BARRIERClass · 0.85
initMethod · 0.45
qAllocManyMethod · 0.45
bid_amplitude_encodeMethod · 0.45
get_circuitMethod · 0.45
get_out_qubitsMethod · 0.45
probRunDictMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected