This function synthesizes UCRZ without the final CX gate, unless _vw_type = ``all``.
(nqubits, angles, _vw_type=None)
| 375 | |
| 376 | |
| 377 | def _get_ucrz(nqubits, angles, _vw_type=None): |
| 378 | """This function synthesizes UCRZ without the final CX gate, |
| 379 | unless _vw_type = ``all``.""" |
| 380 | circuit = QuantumCircuit(nqubits) |
| 381 | q_controls = circuit.qubits[1:] |
| 382 | q_target = circuit.qubits[0] |
| 383 | |
| 384 | UCPauliRotGate._dec_uc_rotations(angles, 0, len(angles), False) |
| 385 | for i, angle in enumerate(angles): |
| 386 | if np.abs(angle) > _EPS: |
| 387 | circuit.rz(angle, q_target) |
| 388 | if not i == len(angles) - 1: |
| 389 | binary_rep = np.binary_repr(i + 1) |
| 390 | q_contr_index = len(binary_rep) - len(binary_rep.rstrip("0")) |
| 391 | circuit.cx(q_controls[q_contr_index], q_target) |
| 392 | elif _vw_type == "all": |
| 393 | q_contr_index = len(q_controls) - 1 |
| 394 | circuit.cx(q_controls[q_contr_index], q_target) |
| 395 | |
| 396 | return circuit |
| 397 | |
| 398 | |
| 399 | def _apply_a2(circ): |
no test coverage detected