Skip to content

Method for resetting Quantum State #29

Open
@marco-lewis

Description

@marco-lewis

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)·|⟩.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions