MCPcopy
hub / github.com/Qiskit/qiskit / _get_ucrz

Function _get_ucrz

qiskit/synthesis/unitary/qsd.py:377–396  ·  view source on GitHub ↗

This function synthesizes UCRZ without the final CX gate, unless _vw_type = ``all``.

(nqubits, angles, _vw_type=None)

Source from the content-addressed store, hash-verified

375
376
377def _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
399def _apply_a2(circ):

Callers 1

_demultiplexFunction · 0.85

Calls 4

rzMethod · 0.95
cxMethod · 0.95
QuantumCircuitClass · 0.90
_dec_uc_rotationsMethod · 0.80

Tested by

no test coverage detected