You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the function grove.alpha.arbitrary_state.arbitrary_state(vector, qubits), inserting qubits that will not be used in the qubits option modifies the output program and the results. Only when len(qubits) =ceil(log2(len(vector))) (i.e., only when the number of qubits specified equals the minimum number of qubits for encoding the state) the result is correct. Here is a MWE:
import pyquil.api as api
import pyquil.quil as pq
from pyquil.gates import I
from grove.alpha.arbitrary_state.arbitrary_state import create_arbitrary_state
good = pq.Program()
bad = pq.Program()
qvm = api.QVMConnection()
# To show that the problem is independent of the position of the qubits
for i in range(6):
good.inst(I(i))
bad.inst(I(i))
good.inst(create_arbitrary_state([0,0,0,0,1], [2,3,4]))
print('Good: ', qvm.wavefunction(good))
bad.inst(create_arbitrary_state([0,0,0,0,1], [2,3,4,5]))
print('Bad: ', qvm.wavefunction(bad))
When using the function
grove.alpha.arbitrary_state.arbitrary_state(vector, qubits)
, inserting qubits that will not be used in thequbits
option modifies the output program and the results. Only whenlen(qubits) =ceil(log2(len(vector)))
(i.e., only when the number of qubits specified equals the minimum number of qubits for encoding the state) the result is correct. Here is a MWE:The result being
Good: (1+0j)|010000>
Bad: (0.7071067812+0j)|010000> + (0.3535533906+0j)|100000> + (0.3535533906+0j)|100100> + (0.3535533906+0j)|101000> + (0.3535533906+0j)|101100>
The text was updated successfully, but these errors were encountered: