大家好:Cirq 提供了一种从数组创建单一门的方法。我尝试在 Qiskit 中做同样的事情,但未能完全成功。这是一个示例代码,其中包含到目前为止我可以组合的内容。另外,有没有办法应用从 q[0] 到 q[1] 的单一受控操作?或者为此目的创建一个特定的标记门以在电路中使用?如果是这样,怎么办?多谢!
from qiskit.extensions import *
U2x2 = np.array([[0.998762, -0.049745], [-0.049745, -0.998762]])
# Still not sure how to use this, though it compiles
gate2x2 = UnitaryGate(U2x2)
# The best I could do so far was this:
# Create the quantum circuit
q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q, c)
qc.unitary(U2x2, range(1))
qc.measure(q[0], c[0])
Run Code Online (Sandbox Code Playgroud)