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

Function test_dc_Amplitude_encoding

test/QAlg/Encode.test.cpp:220–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218 return true;
219}
220static bool test_dc_Amplitude_encoding()
221{
222 auto qvm = new CPUQVM();
223 qvm->init();
224 //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 };
225 std::vector<double>data{ 0.15311858100051695,-0.0961350374871273,0.3859320687001368,-0.5634457467385428,0.1474901012487757,-0.45185782723129864,0.32284355187278985,-0.4132085412578166 };
226 QProg prog;
227 auto q = qvm->qAllocMany(15);
228 Encode encode_b;
229 encode_b.dc_amplitude_encode(q, data);
230 prog << encode_b.get_circuit() << BARRIER(q);
231 QVec out_qubits = encode_b.get_out_qubits();
232 auto result = qvm->probRunDict(prog, out_qubits, -1);
233 int k = 0;
234 //auto normalization_constant = encode_b.get_normalization_constant();
235 for (auto &val : result)
236 {
237 double temp = k >= (int)data.size() ? 0 : data[k];
238 std::cout << val.second << endl;
239 std::cout << val.first << ":" << val.second << std::endl;
240 ++k;
241 }
242 destroyQuantumMachine(qvm);
243 return true;
244}
245static bool test_schmidt_encoding()
246{
247 auto qvm = new CPUQVM();

Callers 1

TESTFunction · 0.85

Calls 8

BARRIERClass · 0.85
initMethod · 0.45
qAllocManyMethod · 0.45
dc_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