declare module '@qni/common/src/angle-parser' { export function radian(angle: string): number; export function angleDenominator(angle: string): number; export function angleNumerator(angle: string): number; export function isAngleLessThan(angle: string, other: string): boolean; export function isAngleGreaterThan(angle: string, other: string): boolean; export function isValidAngle(angle: string): boolean; export function piCoefficient(angle: string): string; export function reduceAngle(angle: string): string; } declare module '@qni/common/src/anti-control-gate' { export const SerializedAntiControlGateType = "\u25E6"; export type SerializedAntiControlGate = { type: typeof SerializedAntiControlGateType; targets: number[]; }; } declare module '@qni/common/src/bloch-display' { export const SerializedBlochDisplayType = "Bloch"; export type SerializedBlochDisplay = { type: typeof SerializedBlochDisplayType; targets: number[]; }; } declare module '@qni/common/src/circuit-step' { import { SerializedAntiControlGate } from '@qni/common/src/anti-control-gate'; import { SerializedBlochDisplay } from '@qni/common/src/bloch-display'; import { SerializedControlGate } from '@qni/common/src/control-gate'; import { SerializedHGate } from '@qni/common/src/h-gate'; import { SerializedMeasurementGate } from '@qni/common/src/measurement-gate'; import { SerializedPhaseGate } from '@qni/common/src/phase-gate'; import { SerializedQftDaggerGate } from '@qni/common/src/qft-dagger-gate'; import { SerializedQftGate } from '@qni/common/src/qft-gate'; import { SerializedRnotGate } from '@qni/common/src/rnot-gate'; import { SerializedRxGate } from '@qni/common/src/rx-gate'; import { SerializedRyGate } from '@qni/common/src/ry-gate'; import { SerializedRzGate } from '@qni/common/src/rz-gate'; import { SerializedSDaggerGate } from '@qni/common/src/s-dagger-gate'; import { SerializedSGate } from '@qni/common/src/s-gate'; import { SerializedSpacerGate } from '@qni/common/src/spacer-gate'; import { SerializedSwapGate } from '@qni/common/src/swap-gate'; import { SerializedTDaggerGate } from '@qni/common/src/t-dagger-gate'; import { SerializedTGate } from '@qni/common/src/t-gate'; import { SerializedWriteGate } from '@qni/common/src/write-gate'; import { SerializedXGate } from '@qni/common/src/x-gate'; import { SerializedYGate } from '@qni/common/src/y-gate'; import { SerializedZGate } from '@qni/common/src/z-gate'; export type SerializedCircuitStep = Array; } declare module '@qni/common/src/complex' { import { Result } from 'neverthrow'; type FormatOptions = { allowAbbreviation?: boolean; maxAbbreviationError?: number; fixedDigits?: number | undefined; }; export class Complex { /** * Complex { real: 0, imag: 0 } */ static readonly ZERO: Complex; /** * Complex { real: 1, imag: 0 } */ static readonly ONE: Complex; /** * The imaginary unit. */ static readonly I: Complex; /** * The real part of the Complex number. */ real: number; /** * The imaginary part of the Complex number. */ imag: number; /** * Converts the given value to a Complex value. * * @param value - The value to convert to a Complex value */ static from(value: number | Complex): Complex; /** * Returns the real part of a Complex or a number value. * * @param value - The value to get the real part of */ static real(value: number | Complex): number; /** * Returns the imaginary part of a Complex value, or else 0 for number values. * * @param value - The value to get the imaginary part of */ static imag(value: number | Complex): number; /** * Returns a new Complex number with the given magnitude and phase. * * @param magnitude - The magnitude of the Complex number * @param phase - The phase of the Complex number */ static polar(magnitude: number, phase: number): Complex; private static cosAndSin; /** * @param real - The real part of the Complex number * @param imag - The imaginary part of the Complex number */ constructor(real: number, imag: number); /** * Returns true if complex number is equal to other. * * @param other - The other value to compare with */ eq(other: unknown): boolean; isEqualTo: (other: unknown) => boolean; /** * Returns true if the Complex number is close to the value of other. * * @param other - The other value to compare with */ nearlyEq(other: number | Complex | unknown, epsilon: number): boolean; isApproximatelyEqualTo: (other: number | Complex | unknown, epsilon: number) => boolean; /** * Returns the complex conjugate. * * @returns A new Complex representing the complex conjugate of this complex number */ conjugate(): Complex; conj: () => Complex; /** * Returns negation of the value. * * @returns A new Complex representing the negation of this complex number. */ neg(): Complex; /** * Returns the sum of this complex number and value. * * @param value - The addend number. * @returns A new Complex representing the sum of this complex number and value. */ add(value: number | Complex): Complex; plus: (value: number | Complex) => Complex; /** * Returns the subtraction of this complex number and value. * * @param value - The subtrahend number. * @returns A new Complex representing the subtraction of this complex number and value. */ sub(value: number | Complex): Complex; subtract: (value: number | Complex) => Complex; minus: (value: number | Complex) => Complex; /** * Returns the product of this complex number and value. * * @param value - The multiplier number. * @returns A new Complex representing the product of this complex number and value. */ mult(value: number | Complex): Complex; multiply: (value: number | Complex) => Complex; times: (value: number | Complex) => Complex; /** * Returns a complex number divided by value. * If value is zero, returns an error. * * @param value - The divisor number. * @returns A Result object with the result of division or a division-by-zero error. * @example * ``` * const res = new Complex(2, 3).div(2) * if (res.isOk()) { * console.log(res.value) // Complex { real: 1, imag: 1.5 } * } else { * console.error(res.error) * } * ``` */ div(value: number | Complex): Result; dividedBy: (value: number | Complex) => Result; /** * Returns the absolute part of its polar form. * * @returns A number representing the absolute part of its polar form. * @example * ``` * new Complex(-1, 0).abs() // 1 * new Complex(3, 4).abs() // 5 * ``` */ abs(): number; magnitude: () => number; /** * Returns square of the absolute value. * * @returns A number representing the square of the absolute value. * @example * ``` * new Complex(-1, 0).abs2() // 1 * new Complex(3, 4).abs2() // 25 * ``` */ abs2(): number; norm2: () => number; /** * Returns the angle part of its polar form. * * @returns A number representing the angle part of its polar form in radians. */ arg(): number; angle: () => number; phase: () => number; /** * Returns the exponentiation of a complex number. That is c.pow(x) = c^x. * * @param exponent - the exponent number * @returns A number representing base taken to the power of exponent */ pow(exponent: number | Complex): Complex; /** * Returns e raised to the c power. That is c.exp() = e^c. */ exp(): Complex; /** * Returns a string representing this complex number according to the specified format. * * @param options - An object that sets the format options for this complex number. * @returns A string representing this complex number. * @example * ``` * new Complex(1, 2).format() // '1+2i' * new Complex(1, 2).format({ * allowAbbreviation: false, * fixedDigits: 2, * }) // '+1.00+2.00i' * ``` */ format(options?: FormatOptions): string; /** * Returns a compact string representing this Complex number. * * @returns A string representing this complex number. * @example * ``` * new Complex(1, 2).toString() // '1+2i' * new Complex(Math.sqrt(1 / 2), -1 / 3).toString() // '√½-⅓i' * ``` */ toString(): string; private ln; private toStringAllowSingleValue; private toStringBothValues; private canRealPartBeOmitted; private canImagPartBeOmitted; private isImagFactorCloseToOne; private isImagFactorMinusOne; private canImagFactorBeOmitted; } export {}; } declare module '@qni/common/src/config' { export const Config: { readonly MAX_QUBIT_COUNT: 16; }; } declare module '@qni/common/src/control-gate' { export const SerializedControlGateType = "\u2022"; export type SerializedControlGate = { type: typeof SerializedControlGateType; targets: number[]; }; } declare module '@qni/common/src/emit-event' { /** * Emit a custom event * * @param type The event type * @param detail Any details to pass along with the event * @param element The element to attach the event to */ export function emitEvent(type: string, detail?: {}, element?: Node): boolean; } declare module '@qni/common/src/format' { type UnicodeFraction = { character: string; ref: string; value: number; }; /** * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export const UNICODE_FRACTIONS: { character: string; ref: string; expanded: string; value: number; }[]; /** * Stores formatting options, for determining what string output should look * like. */ export class Format { /** * Returns an approximated result, but with the constraint that when it * changes slightly it should "look the same". (It should look good when * varying and animated.) */ static readonly CONSISTENT: Format; /** * Returns an accurate result, but favoring looking nice over being small. */ static readonly EXACT: Format; /** * Returns an accurate result, favoring being small over looking nice. */ static readonly MINIFIED: Format; /** * Returns an approximated result, strongly favoring looking nice. */ static readonly SIMPLIFIED: Format; /** * Parses the given text into a float. Works for text created by * [[formatFloat]]. */ static parseFloat(text: string): number; /** * Corrects a value to a nearby simple fraction or root thereof, such as * sqrt(1/2), so it can be printed compactly. * * @param value The value to round. * @param epsilon The maximum offset error introduced by the rounding. */ static simplifyByRounding(value: number, epsilon: number): number; /** * Returns the first element of an array matching the given predicate, or else * returns undefined. * * @hidden */ static matchUnicodeFraction(predicate: (arrayItem: UnicodeFraction) => boolean): UnicodeFraction | undefined; allowAbbreviation: boolean; maxAbbreviationError: number; fixedDigits: number | undefined; itemSeparator: string; /** * @param allowAbbreviation Should outputs be shortened, if possible? * @param maxAbbreviationError How much error is abbreviating allowed to introduce? * @param fixedDigits Use toFixed? How many digits? * @param itemSeparator What should list items be separated by? */ constructor(allowAbbreviation: boolean, maxAbbreviationError: number, fixedDigits: number | undefined, itemSeparator: string); formatFloat(f: number): string; /** * Returns a string representation of a float, taking advantage of unicode * fractions and square roots. * * @param value The value to represent as a string. * @param epsilon The maximum error introduced by using an expression. * @param digits digits The number of digits to use if no expression matches. */ private abbreviateFloat; } export {}; } declare module '@qni/common/src/h-gate' { export const SerializedHGateType = "H"; export type SerializedHGate = { type: typeof SerializedHGateType; targets: number[]; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/index' { export * from '@qni/common/src/angle-parser'; export * from '@qni/common/src/complex'; export * from '@qni/common/src/config'; export * from '@qni/common/src/emit-event'; export * from '@qni/common/src/format'; export * from '@qni/common/src/number-formatter'; export * from '@qni/common/src/numeric-range'; export * from '@qni/common/src/util'; export * from '@qni/common/src/anti-control-gate'; export * from '@qni/common/src/bloch-display'; export * from '@qni/common/src/control-gate'; export * from '@qni/common/src/h-gate'; export * from '@qni/common/src/measurement-gate'; export * from '@qni/common/src/phase-gate'; export * from '@qni/common/src/qft-dagger-gate'; export * from '@qni/common/src/qft-gate'; export * from '@qni/common/src/rnot-gate'; export * from '@qni/common/src/rx-gate'; export * from '@qni/common/src/ry-gate'; export * from '@qni/common/src/rz-gate'; export * from '@qni/common/src/s-dagger-gate'; export * from '@qni/common/src/s-gate'; export * from '@qni/common/src/spacer-gate'; export * from '@qni/common/src/swap-gate'; export * from '@qni/common/src/t-dagger-gate'; export * from '@qni/common/src/t-gate'; export * from '@qni/common/src/write-gate'; export * from '@qni/common/src/x-gate'; export * from '@qni/common/src/y-gate'; export * from '@qni/common/src/z-gate'; export * from '@qni/common/src/circuit-step'; } declare module '@qni/common/src/measurement-gate' { export const SerializedMeasurementGateType = "Measure"; export type SerializedMeasurementGate = { type: typeof SerializedMeasurementGateType; targets: number[]; flag?: string; }; } declare module '@qni/common/src/number-formatter' { type UnicodeFraction = { character: string; ref: string; value: number; }; export class NumberFormatter { allowAbbreviation: boolean; maxAbbreviationError: number; fixedDigits: number | undefined; itemSeparator: string; static matchUnicodeFraction(predicate: (arrayItem: UnicodeFraction) => boolean): UnicodeFraction | undefined; constructor(allowAbbreviation: boolean, maxAbbreviationError: number, fixedDigits: number | undefined, itemSeparator?: string); format(n: number): string; private abbreviateNumber; } export {}; } declare module '@qni/common/src/numeric-range' { import { Config } from '@qni/common/src/config'; export type CreateArrayWithLengthX = ACC['length'] extends LENGTH ? ACC : CreateArrayWithLengthX; export type NumericRange = START_ARR['length'] extends END ? ACC | END : NumericRange<[...START_ARR, 1], END, ACC | START_ARR['length']>; export type ResizeableSpan = NumericRange, typeof Config.MAX_QUBIT_COUNT>; export const isResizeableSpan: (arg: unknown) => arg is 1 | 2 | 4 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | 11 | 12 | 13 | 14 | 15; } declare module '@qni/common/src/phase-gate' { export const SerializedPhaseGateType = "P"; export type SerializedPhaseGate = { type: typeof SerializedPhaseGateType; angle?: string; targets: number[]; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/qft-dagger-gate' { import { ResizeableSpan } from '@qni/common/src/numeric-range'; export const SerializedQftDaggerGateType = "QFT\u2020"; export type SerializedQftDaggerGate = { type: typeof SerializedQftDaggerGateType; span: ResizeableSpan; targets: number[]; }; } declare module '@qni/common/src/qft-gate' { import { ResizeableSpan } from '@qni/common/src/numeric-range'; export const SerializedQftGateType = "QFT"; export type SerializedQftGate = { type: typeof SerializedQftGateType; span: ResizeableSpan; targets: number[]; }; } declare module '@qni/common/src/rnot-gate' { export const SerializedRnotGateType = "X^\u00BD"; export type SerializedRnotGate = { type: typeof SerializedRnotGateType; targets: number[]; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/rx-gate' { export const SerializedRxGateType = "Rx"; export type SerializedRxGate = { type: typeof SerializedRxGateType; targets: number[]; angle?: string; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/ry-gate' { export const SerializedRyGateType = "Ry"; export type SerializedRyGate = { type: typeof SerializedRyGateType; targets: number[]; angle?: string; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/rz-gate' { export const SerializedRzGateType = "Rz"; export type SerializedRzGate = { type: typeof SerializedRzGateType; targets: number[]; angle?: string; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/s-dagger-gate' { export const SerializedSDaggerGateType = "S\u2020"; export type SerializedSDaggerGate = { type: typeof SerializedSDaggerGateType; targets: number[]; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/s-gate' { export const SerializedSGateType = "S"; export type SerializedSGate = { type: typeof SerializedSGateType; targets: number[]; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/spacer-gate' { export const SerializedSpacerGateType = "\u2026"; export type SerializedSpacerGate = { type: typeof SerializedSpacerGateType; targets: number[]; }; } declare module '@qni/common/src/swap-gate' { export const SerializedSwapGateType = "Swap"; export type SerializedSwapGate = { type: typeof SerializedSwapGateType; targets: [number, number]; controls?: number[]; antiControls?: number[]; }; } declare module '@qni/common/src/t-dagger-gate' { export const SerializedTDaggerGateType = "T\u2020"; export type SerializedTDaggerGate = { type: typeof SerializedTDaggerGateType; targets: number[]; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/t-gate' { export const SerializedTGateType = "T"; export type SerializedTGate = { type: typeof SerializedTGateType; targets: number[]; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/util' { /** * Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { Result } from 'neverthrow'; type ParseError = { message: string; }; export class Util { static need(expression: boolean, message: string, args?: unknown[]): asserts expression; static notNull(v: T): asserts v is NonNullable; static get urlJson(): string; static safeJsonParse: (text: string, reviver?: ((this: any, key: string, value: any) => any) | undefined) => Result; } export {}; } declare module '@qni/common/src/write-gate' { export const SerializedWrite0GateType = "|0>"; export const SerializedWrite1GateType = "|1>"; export type SerializedWriteGate = { type: typeof SerializedWrite0GateType | typeof SerializedWrite1GateType; targets: number[]; }; } declare module '@qni/common/src/x-gate' { export const SerializedXGateType = "X"; export type SerializedXGate = { type: typeof SerializedXGateType; targets: number[]; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/y-gate' { export const SerializedYGateType = "Y"; export type SerializedYGate = { type: typeof SerializedYGateType; targets: number[]; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common/src/z-gate' { export const SerializedZGateType = "Z"; export type SerializedZGate = { type: typeof SerializedZGateType; targets: number[]; controls?: number[]; antiControls?: number[]; if?: string; }; } declare module '@qni/common' { import main = require('@qni/common/src/index'); export = main; }