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

Method cu3

python/cudaq/kernel/kernel_builder.py:1030–1055  ·  view source on GitHub ↗

Controlled u3 operation. The controls parameter is expected to be a list of QuakeValue. ```python # Example: kernel = cudaq.make_kernel() qubits = kernel.qalloc(2) kernel.cu3(np.pi, np.pi, np.pi / 2, qubits[0], qubits[1]))

(self, theta, phi, delta, controls, target)

Source from the content-addressed store, hash-verified

1028 self.createInvariantForLoop(size, body)
1029
1030 def cu3(self, theta, phi, delta, controls, target):
1031 """
1032 Controlled u3 operation. The controls parameter is expected to be a
1033 list of QuakeValue.
1034
1035 ```python
1036 # Example:
1037 kernel = cudaq.make_kernel()
1038 qubits = kernel.qalloc(2)
1039 kernel.cu3(np.pi, np.pi, np.pi / 2, qubits[0], qubits[1]))
1040 ```
1041 """
1042 with self.insertPoint, self.loc:
1043 fwdControls = None
1044 if isinstance(controls, list):
1045 fwdControls = [c.mlirValue for c in controls]
1046 elif quake.RefType.isinstance(
1047 controls.mlirValue.type) or quake.VeqType.isinstance(
1048 controls.mlirValue.type):
1049 fwdControls = [controls.mlirValue]
1050 else:
1051 emitFatalError(f"invalid controls type for cu3.")
1052
1053 quake.U3Op(
1054 [], [get_parameter_value(self, p) for p in [theta, phi, delta]],
1055 fwdControls, [target.mlirValue])
1056
1057 def cswap(self, controls, qubitA, qubitB):
1058 """

Callers 2

_emit_cu3Function · 0.80
test_u3_ctrlFunction · 0.80

Calls 2

get_parameter_valueFunction · 0.85
emitFatalErrorFunction · 0.70

Tested by 1

test_u3_ctrlFunction · 0.64