Gates

MicroQuantum’s gate set is implemented from scratch as complex NumPy matrices. Every gate is an Operator; 1-qubit gates are 2x2 unitaries, 2-qubit gates 4x4 unitaries, in the big-endian convention (qubit 0 = most significant).

Single-qubit gates

  • Clifford: Operator.X, Operator.Y, Operator.Z, Operator.H, Operator.S / Sdg, Operator.T / Tdg.

  • Rotations: Operator.Rx, Operator.Ry, Operator.Rz — accept a float angle or a symbolic ParameterExpression.

Two-qubit gates

  • Operator.CNOT (alias cx) — control/target two-qubit X.

  • Operator.CZ — controlled Z.

  • Operator.SWAP — swap two qubits.

Circuit shortcuts

The circuit API mirrors these as methods; QuantumCircuit.append(op, targets) accepts any Operator:

from microquantum import QuantumCircuit, Operator

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)                 # controlled-X
qc.append(Operator.SWAP(), [0, 1])
qc.append(Operator.Rz(1.5), [0])

Unitary check and application

  • apply_gate() applies a unitary to a state vector.

  • expand_operator() embeds a small unitary onto a larger register (target + controls).

  • tensor() builds Kronecker products of operators/states.

  • expectation_value() computes <psi|O|psi>.

Custom gates

Any unitary NumPy matrix can be wrapped as an Operator and appended, so custom gates compose with the built-ins without any registry registration.