swapGate
Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.
Description
applies a swap gate that swaps the states of two target qubits and returns a g
= swapGate(targetQubit1
,targetQubit2
)quantum.gate.SimpleGate
object.
If
targetQubit1
andtargetQubit2
are vectors of the same length, thenswapGate
returns a column vector of gates, whereg(i)
represents a swap gate applied to two target qubits with indicestargetQubit1(i)
andtargetQubit2(i)
.If either
targetQubit1
ortargetQubit2
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
targetQubit1
andtargetQubit2
must not be the same.
Examples
Input Arguments
More About
Version History
Introduced in R2023a