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

Method control

python/cudaq/kernel/kernel_builder.py:1351–1387  ·  view source on GitHub ↗

Apply the `target` kernel as a controlled operation in-place to `self`. Uses the provided `control` as control qubit/s for the operation. Args: target (:class:`Kernel`): The kernel to apply as a controlled operation in-place to self. control (:c

(self, target, control, *target_arguments)

Source from the content-addressed store, hash-verified

1349 return
1350
1351 def control(self, target, control, *target_arguments):
1352 """
1353 Apply the `target` kernel as a controlled operation in-place to `self`.
1354 Uses the provided `control` as control qubit/s for the operation.
1355
1356 Args:
1357 target (:class:`Kernel`): The kernel to apply as a controlled
1358 operation in-place to self.
1359 control (:class:`QuakeValue`): The control qubit or register to
1360 use when applying `target`.
1361 *target_arguments (Optional[:class:`QuakeValue`]): The arguments to the
1362 `target` kernel. Leave empty if the `target` kernel doesn't accept
1363 any arguments.
1364
1365 Raises:
1366 RuntimeError: if the `*target_arguments` passed to the control
1367 call don't match the argument signature of `target`.
1368
1369 ```python
1370 # Example:
1371 # Create a `Kernel` that accepts a qubit as an argument.
1372 # Apply an X-gate on that qubit.
1373 target_kernel, qubit = cudaq.make_kernel(cudaq.qubit)
1374 target_kernel.x(qubit)
1375 # Create another `Kernel` that will apply `target_kernel`
1376 # as a controlled operation.
1377 kernel = cudaq.make_kernel()
1378 control_qubit = kernel.qalloc()
1379 target_qubit = kernel.qalloc()
1380 # In this case, `control` performs the equivalent of a
1381 # controlled-X gate between `control_qubit` and `target_qubit`.
1382 kernel.control(target_kernel, control_qubit, target_qubit))
1383 ```
1384 """
1385 self.__applyControlOrAdjoint(target, False, [control.mlirValue],
1386 *target_arguments)
1387 return
1388
1389 def apply_call(self, target, *target_arguments):
1390 """

Callers 15

kernelFunction · 0.45
kernel_ancilla_exp_pauliFunction · 0.45
kernel_ancilla_rotationFunction · 0.45
bellFunction · 0.45

Calls 1

Tested by 15

kernelFunction · 0.36
callUCCSDFunction · 0.36
test_drawFunction · 0.36
toffoliFunction · 0.36
kernelFunction · 0.36