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

Method pMeasureDecindex

Extensions/PilotOSMachine/QPilotOSMachine.cpp:429–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427}
428
429double QPilotOSMachine::pMeasureDecindex(QProg& prog, std::string index, int backendID)
430{
431 try
432 {
433 QPanda::QVec qubit_vector;
434 get_all_used_qubits(prog, qubit_vector);
435 auto m_value = std::atoll(index.c_str());
436 if (m_value >= std::pow(2, qubit_vector.size()) || m_value < 0)
437 {
438 throw std::runtime_error("pMeasureDecindex parms error:" + index);
439 }
440 if (m_machine_type == "Pilot")
441 {
442 complex_d result;
443 PilotQVM::ErrorCode err_code;
444 if ((err_code = m_pilot_machine->execute_single_amplitude_task(
445 convert_qprog_to_originir(prog, this), index, result, backendID))
446 != PilotQVM::ErrorCode::NO_ERROR_FOUND)
447 {
448 throw std::runtime_error("pMeasureDecindex run error,please check the parms,error code:"
449 + std::to_string(int(err_code)));
450 }
451 return result.real() * result.real() + result.imag() * result.imag();
452 }
453 QPanda::SingleAmplitudeQVM m_single_amplitude_machine;
454 m_single_amplitude_machine.init();
455 m_single_amplitude_machine.run(prog, qubit_vector);
456 return m_single_amplitude_machine.pMeasureDecindex(index);
457 }
458 catch (const std::exception& e)
459 {
460 PTraceInfo("Catch unknow exception" << e.what());
461 }
462}
463
464std::unordered_map<std::string, std::complex<double>> QPilotOSMachine::pmeasure_subset(QProg& prog,
465 const std::vector<std::string>& amplitude, int backendID)

Callers

nothing calls this directly

Calls 9

powFunction · 0.50
sizeMethod · 0.45
realMethod · 0.45
imagMethod · 0.45
initMethod · 0.45
runMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected