microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
logo

Branches

Tags

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

Clone

HTTPS

Download ZIP

source/npm/qsharp/src/data-structures/register.ts

52lines · modeblame

4192f29cMine Starks1 years ago1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT license.
3
4/**
5* Type of register.
6*/
7export enum RegisterType {
8Qubit,
9Classical,
10}
11
12/**
13* Represents a register resource.
14*/
15export interface Register {
16/** Qubit register ID. */
1287d30fScott Carda1 years ago17qubit: number;
18/** Classical register ID. If present, register is classical register. */
19result?: number;
4192f29cMine Starks1 years ago20}
21
32f9dba0Scott Carda1 years ago22/**
23* Runtime check: is this a valid Register?
24*/
25export function isRegister(obj: any): obj is Register {
26return (
27obj &&
28typeof obj === "object" &&
29typeof obj.qubit === "number" &&
30// result is optional, but if present must be a number
31(obj.result === undefined || typeof obj.result === "number")
32);
33}
34
4192f29cMine Starks1 years ago35/**
1693b257Scott Carda1 years ago36* Rendering data for qubit register.
4192f29cMine Starks1 years ago37*/
1693b257Scott Carda1 years ago38export interface RegisterRenderData {
4192f29cMine Starks1 years ago39/** Type of register. */
40type: RegisterType;
41/** y coord of register */
42y: number;
43/** Nested classical registers attached to quantum register. */
1693b257Scott Carda1 years ago44children?: RegisterRenderData[];
4192f29cMine Starks1 years ago45}
46
47/**
1693b257Scott Carda1 years ago48* Mapping from qubit IDs to their register render data.
4192f29cMine Starks1 years ago49*/
50export interface RegisterMap {
1693b257Scott Carda1 years ago51[id: number]: RegisterRenderData;
4192f29cMine Starks1 years ago52}