| 44 | |
| 45 | |
| 46 | void QProgExecution::execute(std::shared_ptr<AbstractQGateNode> cur_node, |
| 47 | std::shared_ptr<QNode> parent_node, |
| 48 | TraversalConfig & param, |
| 49 | QPUImpl*& qpu) |
| 50 | { |
| 51 | QPANDA_OP(GateType::BARRIER_GATE == cur_node->getQGate()->getGateType(), return); |
| 52 | |
| 53 | bool dagger = cur_node->isDagger() ^ param.m_is_dagger; |
| 54 | if (cur_node->getTargetQubitNum() <= 0) |
| 55 | { |
| 56 | QCERR("Unknown internal error"); |
| 57 | throw runtime_error("Unknown internal error"); |
| 58 | } |
| 59 | |
| 60 | QVec control_qubit_vector; |
| 61 | for (auto aiter : param.m_control_qubit_vector) |
| 62 | { |
| 63 | control_qubit_vector.push_back(aiter); |
| 64 | } |
| 65 | |
| 66 | cur_node->getControlVector(control_qubit_vector); |
| 67 | |
| 68 | if (control_qubit_vector.size() > 0) |
| 69 | { |
| 70 | sort(control_qubit_vector.begin(), |
| 71 | control_qubit_vector.end(), |
| 72 | compareQubit); |
| 73 | |
| 74 | control_qubit_vector.erase(unique(control_qubit_vector.begin(), |
| 75 | control_qubit_vector.end(), Qubitequal), |
| 76 | control_qubit_vector.end()); |
| 77 | } |
| 78 | |
| 79 | QVec target_qubit; |
| 80 | cur_node->getQuBitVector(target_qubit); |
| 81 | |
| 82 | _check_repetitive_qubit(target_qubit, control_qubit_vector); |
| 83 | |
| 84 | auto qgate = cur_node->getQGate(); |
| 85 | auto aiter = QGateParseMap::getFunction(qgate->getOperationNum()); |
| 86 | |
| 87 | if (nullptr == aiter) |
| 88 | { |
| 89 | stringstream error; |
| 90 | error << "gate operation num error "; |
| 91 | QCERR(error.str()); |
| 92 | throw run_fail(error.str()); |
| 93 | } |
| 94 | |
| 95 | QuantumGate *new_quantum_gate = nullptr; |
| 96 | if (param.m_rotation_angle_error > DBL_EPSILON || |
| 97 | param.m_rotation_angle_error < -DBL_EPSILON) |
| 98 | { |
| 99 | qgate_set_rotation_angle_error(cur_node, &new_quantum_gate, param.m_rotation_angle_error); |
| 100 | } |
| 101 | |
| 102 | if (nullptr == new_quantum_gate) |
| 103 | { |
nothing calls this directly
no test coverage detected