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

Function test_Amplitude_encoding3

test/QAlg/Encode.test.cpp:483–510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481 return true;
482}
483static bool test_Amplitude_encoding3()
484{
485 auto qvm = initQuantumMachine(QMachineType::CPU);
486 auto q = qvm->allocateQubits(2);
487 auto c = qvm->allocateCBits(2);
488
489
490 QStat test_qstat{ qcomplex_t(0.406270160898181, 0.0749820103002614),
491 qcomplex_t(0.195605655043143, 0.486587726445213),
492 qcomplex_t(0.241952125812726, 0.455619712343811),
493 qcomplex_t(0.31466450344542, 0.434912822865699) };
494
495 QCircuit test_cir = amplitude_encode(q, test_qstat);
496
497 auto prog = QProg();
498 prog << test_cir;
499 qvm->directlyRun(prog);
500 auto stat = qvm->getQState();
501 std::cout << "target_stat:\n" << stat << std::endl;
502
503 destroyQuantumMachine(qvm);
504
505 if (0 == mat_compare(stat, test_qstat, MAX_COMPARE_PRECISION)) {
506 return true;
507 }
508
509 return false;
510}
511static bool test_Amplitude_encoding4()
512{
513 auto qvm = initQuantumMachine(QMachineType::CPU);

Callers 1

TESTFunction · 0.85

Calls 6

allocateCBitsMethod · 0.80
amplitude_encodeFunction · 0.50
QProgClass · 0.50
allocateQubitsMethod · 0.45
directlyRunMethod · 0.45
getQStateMethod · 0.45

Tested by

no test coverage detected