New answers tagged

1

You specified a matrix whose size is consistent with a four qubit gate, not a three qubit gate. Also, the matrix isn't unitary (it has columns containing nothing but zeros). The matrix' size must be consistent with the number of qubits that the gate applies to. Do this: def _unitary_(self): st = np.sin(self.theta) ct = np.cos(self.theta) ...


1

MyTwoQubitGate().on(q1, q2).controlled_by(c) or MyTwoQubitGate().controlled().on(c, q1, q2)


1

You're looking for cirq.resolve_parameters(object, resolver), which returns the object after the parameters have been resolved. For example: import cirq import sympy q = cirq.LineQubit(0) s = sympy.Symbol('s') symbol_op = cirq.X(q)**s resolved_op = cirq.resolve_parameters(symbol_op, {s: 0.25}) print(resolved_op) # X**0.25(0) symbol_circuit = cirq.Circuit(...


Top 50 recent answers are included