To initialize a state in Cirq, I created a custom controlled rotation and a custom rotation gate. The effect of applying the custom controlled gates to the qubits doesn't seem to affect the state. Here's the definition of the custom controlled rotation gate:
a00 = 2/np.sqrt(30)
a01 = 4/np.sqrt(30)
a10 = 3/np.sqrt(30)
a11 = 1/np.sqrt(30)
class Con0Gate(cirq.SingleQubitGate):
def unitary(self):
return np.array([
[a00/(np.sqrt((np.abs(a00)2)+(np.abs(a01)2))), a01/(np.sqrt((np.abs(a00)2)+(np.abs(a01)2)))],
[a01/(np.sqrt((np.abs(a00)2)+(np.abs(a01)2))), -a00/(np.sqrt((np.abs(a00)2)+(np.abs(a01)2)))]])
def _circuit_diagram_info_(self, args):
return 'Con0Gate'
And here it is in the circuit (ignore the first "rotation" gate, which works fine)
circuit = cirq.Circuit(
RotationGate(theta).on(cirq.LineQubit(q1)),
Con0Gate().on(cirq.LineQubit(q2)).controlled_by(cirq.LineQubit(q1)))
After running this through a simulator, it looks like the gate isn't controlling on the target, and only applies a rotation to the controlled qubit.