qrisp.QuantumCircuit.cnot_count#

QuantumCircuit.cnot_count() int[source]#

Returns the number of two-qubit Pauli-axis controlled gates (CX, CY, CZ) in this QuantumCircuit.

The circuit is fully transpiled before counting, so that any composite gate containing CX/CY/CZ gates is decomposed first.

Returns:
int

The total number of CX, CY, and CZ gates after transpilation.

See also

QuantumCircuit.count_ops

Returns a full breakdown of every gate type in the circuit.

Examples

We build a small circuit and count its two-qubit Pauli controlled gates:

>>> from qrisp import QuantumCircuit
>>> qc = QuantumCircuit(3)
>>> qc.cx(0, 1)
>>> qc.h(1)
>>> qc.cz(1, 2)
>>> qc.cnot_count()
2

The H gate is a single-qubit gate and is not counted; the CX and CZ each contribute 1, giving a total of 2.