MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / swap

Method swap

python/cudaq/kernel/kernel_builder.py:1088–1104  ·  view source on GitHub ↗

Swap the states of the provided qubits. ```python # Example: kernel = cudaq.make_kernel() # Allocate qubit/s to the `kernel`. qubits = kernel.qalloc(2) # Place the 0th qubit in the 1-state. kernel.x(qubits[0])

(self, qubitA, qubitB)

Source from the content-addressed store, hash-verified

1086 [qubitA.mlirValue, qubitB.mlirValue])
1087
1088 def swap(self, qubitA, qubitB):
1089 """
1090 Swap the states of the provided qubits.
1091
1092 ```python
1093 # Example:
1094 kernel = cudaq.make_kernel()
1095 # Allocate qubit/s to the `kernel`.
1096 qubits = kernel.qalloc(2)
1097 # Place the 0th qubit in the 1-state.
1098 kernel.x(qubits[0])
1099 # Swap their states.
1100 kernel.swap(qubits[0], qubits[1]))
1101 ```
1102 """
1103 with self.insertPoint, self.loc:
1104 quake.SwapOp([], [], [], [qubitA.mlirValue, qubitB.mlirValue])
1105
1106 def reset(self, target):
1107 """

Callers 12

test_swap_gateMethod · 0.45
test_swap_2qFunction · 0.45
test_swap_decompositionFunction · 0.45
test_drawFunction · 0.45
test_swap_2qFunction · 0.45
deallocateAncillasMethod · 0.45
growMatrixMethod · 0.45
CUDAQ_TESTFunction · 0.45
CUDAQ_TESTFunction · 0.45
swapFunction · 0.45

Calls

no outgoing calls

Tested by 9

test_swap_gateMethod · 0.36
test_swap_2qFunction · 0.36
test_swap_decompositionFunction · 0.36
test_drawFunction · 0.36
test_swap_2qFunction · 0.36
CUDAQ_TESTFunction · 0.36
CUDAQ_TESTFunction · 0.36