microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.22.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

samples/testing/states/src/StatePrep.qs

18lines · modepreview

/// # Summary
/// Prepares the state 1/2 (|00⟩ + i|01⟩ - |10⟩ - i|11⟩) = |-⟩ ⊗ |i⟩.
operation PrepareStateWithComplexPhases(qs : Qubit[]) : Unit {
    H(qs[0]);
    Z(qs[0]);
    H(qs[1]);
    S(qs[1]);
}

/// # Summary
/// Prepares the state 1/2 (-|00⟩ - i|01⟩ + |10⟩ + i|11⟩) = -(|-⟩ ⊗ |i⟩) = -|-⟩ ⊗ |i⟩.
operation PrepareStateWithGlobalPhase(qs : Qubit[]) : Unit {
    H(qs[0]);
    Z(qs[0]);
    X(qs[0]);
    H(qs[1]);
    S(qs[1]);
}