Is there a method for resetting the global state if there are no quantum variables? I am considering some code that requires a repeat until success loop and the quantum state needs to be reset at the start of the loop.
Example with a minimal program:
def main(){
loop := true:!B;
while (loop){
q := 0:B;
q := rotY(1,q);
q := rotZ(0.5,q);
loop = measure(q);
}
return loop;
}
On the first iteration, the quantum state is (1+0i)·|⟩ or (1+0i)·|0⟩ up to the rotation statements.
Once the rotations are done the quantum state is (0.850301-0.217117i)·|0⟩₂+(0.464521+0.118612i)·|1⟩₂.
Now if the measurement is 1 the quantum state becomes (0.968912+0.247404i)·|⟩, which leaks into the redefinition of q in the next iteration. The state is therefore (0.968912+0.247404i)·|0⟩ rather than (1+0i)·|0⟩.
Basically, I would be looking for something like:
def main(){
loop := true:!B;
while (loop){
q := 0:B;
q := rotY(1,q);
q := rotZ(0.5,q);
loop = measure(q);
reset();
}
return loop;
}
where reset() changes an empty quantum state back to (1+0i)·|⟩.
Is there a method for resetting the global state if there are no quantum variables? I am considering some code that requires a repeat until success loop and the quantum state needs to be reset at the start of the loop.
Example with a minimal program:
On the first iteration, the quantum state is
(1+0i)·|⟩or(1+0i)·|0⟩up to the rotation statements.Once the rotations are done the quantum state is
(0.850301-0.217117i)·|0⟩₂+(0.464521+0.118612i)·|1⟩₂.Now if the measurement is
1the quantum state becomes(0.968912+0.247404i)·|⟩, which leaks into the redefinition ofqin the next iteration. The state is therefore(0.968912+0.247404i)·|0⟩rather than(1+0i)·|0⟩.Basically, I would be looking for something like:
where
reset()changes an empty quantum state back to(1+0i)·|⟩.