Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

# Tag Info

0

cirq.Ry is a method that, given an angle, returns a gate. You then apply the gate to a qubit: cirq.Ry(angle).on(qubit) or, equivalently but a bit more confusingly: cirq.Ry(angle)(qubit)

3

If you call initialize in this case, you will be specifying a general state in $\mathbb{C}^8$. However what you have is more specialized. For example only having 4 nonzero amplitudes. So the call to initialize won't know this a priori. So it won't realize the initialization circuit can be decomposed easily. Or at least it will need to do some extra ...

2

You can initialize a quantum state by using the QuantumCircuit.initialize() function. For example, to initialize a circuit into the state |1>, we can perform the initialization as follows : vector = [0,1] qr = QuantumRegister(1) qc = QuantumCircuit(qr) qc.initialize(vector, [qr[0]]) There is more detail about how to use it in this tutorial

Top 50 recent answers are included