microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/fix-wasm-logging-issue

Branches

Tags

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

Clone

HTTPS

Download ZIP

samples/testing/operations/src/BellState.qs

32lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4/// # Summary
5/// Operation that generates all bell states for testing with `dump_operation.py`.
6///
7/// # Input
8/// ## qs
9/// Input qubit register
10///
11/// ## choice
12/// Bell state to construct.
13/// 0: |Φ+〉(PhiPlus)
14/// 1: |Φ-〉(PhiMinus)
15/// 2: |Ψ+〉(PsiPlus)
16/// 3: |Ψ-〉(PsiMinus)
17operation AllBellStates(qs : Qubit[], choice : Int) : Unit is Ctl + Adj {
18 import Std.Convert.*;
19
20 H(qs[0]);
21 CNOT(qs[0], qs[1]);
22
23 let bitmask = IntAsBoolArray(choice, 2);
24 if bitmask[1] {
25 X(qs[1]);
26 }
27
28 if bitmask[0] {
29 Z(qs[0]);
30 }
31
32}
33