microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.23.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

library/core/qir.qs

35lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4namespace QIR.Runtime {
5 operation __quantum__rt__qubit_allocate() : Qubit {
6 body intrinsic;
7 }
8
9 operation __quantum__rt__qubit_release(q : Qubit) : Unit {
10 body intrinsic;
11 }
12
13 operation AllocateQubitArray(size : Int) : Qubit[] {
14 if size < 0 {
15 fail "Cannot allocate qubit array with a negative length";
16 }
17 mutable qs = [];
18 for _ in 0..size - 1 {
19 set qs += [__quantum__rt__qubit_allocate()];
20 }
21 qs
22 }
23
24 operation ReleaseQubitArray(qs : Qubit[]) : Unit {
25 for q in qs {
26 __quantum__rt__qubit_release(q);
27 }
28 }
29
30 function __quantum__rt__read_loss(r : Result) : Bool {
31 body intrinsic;
32 }
33
34 export __quantum__rt__qubit_allocate, __quantum__rt__qubit_release, AllocateQubitArray, ReleaseQubitArray, __quantum__rt__read_loss;
35}
36