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

Method u3

python/cudaq/kernel/kernel_builder.py:997–1028  ·  view source on GitHub ↗

Apply the universal three-parameters operator to target qubit. The three parameters are Euler angles - θ, φ, and λ. ```python # Example kernel = cudaq.make_kernel() q = cudaq.qubit() kernel.u3(np.pi, np.pi, np.pi / 2, q)

(self, theta, phi, delta, target)

Source from the content-addressed store, hash-verified

995 emitFatalError("from_state not implemented.")
996
997 def u3(self, theta, phi, delta, target):
998 """
999 Apply the universal three-parameters operator to target qubit. The
1000 three parameters are Euler angles - θ, φ, and λ.
1001
1002 ```python
1003 # Example
1004 kernel = cudaq.make_kernel()
1005 q = cudaq.qubit()
1006 kernel.u3(np.pi, np.pi, np.pi / 2, q)
1007 ```
1008 """
1009 with self.ctx, self.insertPoint, self.loc:
1010 parameters = [
1011 get_parameter_value(self, p) for p in [theta, phi, delta]
1012 ]
1013
1014 if quake.RefType.isinstance(target.mlirValue.type):
1015 quake.U3Op([], parameters, [], [target.mlirValue])
1016 return
1017
1018 # Must be a `veq`, get the size
1019 size = quake.VeqSizeOp(self.getIntegerType(), target.mlirValue)
1020
1021 def body(idx):
1022 extracted = quake.ExtractRefOp(quake.RefType.get(),
1023 target.mlirValue,
1024 -1,
1025 index=idx).result
1026 quake.U3Op([], parameters, [], [extracted])
1027
1028 self.createInvariantForLoop(size, body)
1029
1030 def cu3(self, theta, phi, delta, controls, target):
1031 """

Callers 7

_emit_u3Function · 0.45
_emit_u2Function · 0.45
test_u3_opFunction · 0.45
test_u3_ctrlFunction · 0.45
test_noise_u3Function · 0.45
CUDAQ_TESTFunction · 0.45
CUDAQ_TESTFunction · 0.45

Calls 3

getIntegerTypeMethod · 0.95
get_parameter_valueFunction · 0.85

Tested by 5

test_u3_opFunction · 0.36
test_u3_ctrlFunction · 0.36
test_noise_u3Function · 0.36
CUDAQ_TESTFunction · 0.36
CUDAQ_TESTFunction · 0.36