cxGate
Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.
Description
applies a controlled X gate to a target qubit based on the state of a control qubit and
returns a g
= cxGate(controlQubit
,targetQubit
)quantum.gate.SimpleGate
object. If the control qubit is in the state, then this gate does nothing. If the control qubit is in the state, then this gate applies a Pauli X gate (xGate
) to
the target qubit. This gate is also known as the controlled NOT gate, and
cxGate
is equivalent to the cnotGate
.
If
controlQubit
andtargetQubit
are vectors of the same length,cxGate
returns a column vector of gates, whereg(i)
represents a controlled X gate applied to a control qubit with indexcontrolQubit(i)
and a target qubit with indextargetQubit(i)
.If either
controlQubit
ortargetQubit
is a scalar, and the other input is a vector, then MATLAB® expands the scalar to match the size of the vector input.The qubit indices in each element pair of
controlQubit
andtargetQubit
must not be the same.
Examples
Input Arguments
More About
Version History
Introduced in R2023a
See Also
quantumCircuit
| quantum.gate.SimpleGate
| xGate
| cnotGate
| cyGate
| czGate
| ccxGate
| getMatrix