| 392 | } |
| 393 | |
| 394 | double QPilotOSMachine::pMeasureBinindex(QProg& prog, std::string index, int backendID) |
| 395 | { |
| 396 | try |
| 397 | { |
| 398 | QPanda::QVec qubit_vector; |
| 399 | get_all_used_qubits(prog, qubit_vector); |
| 400 | if (index.size() > qubit_vector.size()) |
| 401 | { |
| 402 | throw std::runtime_error("pMeasureBinindex parms error:" + index); |
| 403 | } |
| 404 | if (m_machine_type == "Pilot") |
| 405 | { |
| 406 | PilotQVM::ErrorCode err_code; |
| 407 | complex_d result; |
| 408 | if ((err_code = m_pilot_machine->execute_single_amplitude_task( |
| 409 | convert_qprog_to_originir(prog, this), |
| 410 | binary_to_inter(index), result, backendID)) |
| 411 | != PilotQVM::ErrorCode::NO_ERROR_FOUND) |
| 412 | { |
| 413 | throw std::runtime_error("pMeasureBinindex run error,please check the parms,error code:" |
| 414 | + std::to_string(int(err_code))); |
| 415 | } |
| 416 | return result.real() * result.real() + result.imag() * result.imag(); |
| 417 | } |
| 418 | QPanda::SingleAmplitudeQVM m_single_amplitude_machine; |
| 419 | m_single_amplitude_machine.init(); |
| 420 | m_single_amplitude_machine.run(prog, qubit_vector); |
| 421 | return m_single_amplitude_machine.pMeasureBinindex(index); |
| 422 | } |
| 423 | catch (const std::exception& e) |
| 424 | { |
| 425 | PTraceInfo("Catch unknow exception" << e.what()); |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | double QPilotOSMachine::pMeasureDecindex(QProg& prog, std::string index, int backendID) |
| 430 | { |
nothing calls this directly
no test coverage detected