Home Reference Source

# Function

 Static Public Summary public C(gate: BasicGate, n: number): * Return n-controlled version of the provided gate. public CRz(angle: *): * public Compute(engine: *, func: *) Start a compute-section. public Control(engine: BasicEngine, qubits: Array, func: function) Condition an entire code block on the value of qubits being 1. public CustomUncompute(engine: *, func: *) Start a custom uncompute-section. public Dagger(engine: BasicEngine, func: function) Invert an entire code block. public Loop(engine: *, num: *, func: *) Loop n times over an entire code block. public ObjectCopy(obj: Object): Object create copy of object, with same `class` public Qureg(args: ...*): * public SubConstant(a: number): * Subtract a constant from a quantum number represented by a quantum register, stored from low- to high-bit. public SubConstantModN(a: number, N: number): * Subtract a constant from a quantum number represented by a quantum register modulo N. public Uncompute(engine: *) Uncompute automatically. public add(key: *, value: *) public add_constant(eng: *, c: *, quint: *) Adds a classical constant c to the quantum integer (qureg) quint using Draper addition. public add_constant_modN(eng: *, c: *, N: *, quint: *) Adds a classical constant c to a quantum integer (qureg) quint modulo N using Draper addition and the construction from `https://arxiv.org/abs/quant-ph/0205095`. public arrayEqual(a1: Array, a2: Array, itemCompareFunc: function): boolean test if two array(a1, a2) are equal, support instance of classes in this library public arrayFromRange(start: number, end: number, step: number): number[] create an array filled by number in range, active like python does public arrayIsTuple(value: Array): boolean check if an array is `tuple` public classHierachy(cls: function): function[] return class hierachy of `cls` public complexVectorDot(a1: Complex[], a2: Complex[]): Complex return dot product of two complex vector(a1, a2) public create_test_matrices(): * public dropEngineAfter(engine: BasicEngine): BasicEngine Removes an engine from the singly-linked list of engines. public expmod(base: number, exp: number, mod: number): number return (base ^ exp) % mod, it's fast and support big number public genString(item: string, n: number): string return item * n string like python does. public get(key: *): * public getEngineList(one_qubit_gates: string | Array, two_qubit_gates: string | Array, other_gates: string | Array): Array Returns an engine list to compile to a restricted gate set. public getEngineList(): public getEngineList(num_rows: number, num_columns: number, one_qubit_gates: string | Array, two_qubit_gates: string | Array): Returns an engine list to compile to a 2-D grid of qubits. public getEngineList(): public getEngineList(): public getEngineList(num_qubits: number, cyclic: boolean, one_qubit_gates: string | Array, two_qubit_gates: string | Array): Array Returns an engine list to compile to a linear chain of qubits. public getInverse(gate: BasicGate): * Return the inverse of a gate. public high_level_gates(eng: *, cmd: *): boolean Remove any MathGates public insertEngine(prevEngine: BasicEngine, engineToInsert: BasicEngine) Inserts an engine into the singly-linked list of engines. public instanceOf(inst: any, cls: function): boolean check if `inst` is instance of `cls`, specialized for some class public intersection(s1: Set, s2: Set): Set return intersection of s1 & s2 public isComplex(value: Object): boolean check if value is complex number public isKindclassOf(cls: function, superClass: function): boolean check if `cls` is kind of `superClass`, will return true if cls is superClass public isNumeric(value: Object): boolean check if value is number or complex number public isSubclassOf(cls: function, superClass: function): boolean check if `cls` is subclass of `superClass`, will return false if cls is superClass public len(v: any): number return `length` of v, act like python public markTuple(value: *) force mark a value as `tuple`, internal usage only public matrixDot(matrix: math.matrix, vector: number[]): math.matrix dot product of matrix & vector public matrixGetRow(matrix: math.matrix, index: number): number[] return a row of matrix public matrixRangeAssign(matrix: math.matrix, indices: number[], vector: number[]) assign value in `vector` into `matrix` by index in `indices` public matrixRangeIndicesAssign(matrix: *, mstart: *, mend: *, vector: *, vstart: *) public mul_by_constant_modN(eng: *, c: *, N: *, quint_in: *) Multiplies a quantum integer by a classical number a modulo N, i.e., public narray(item: Function | any, count: number): Array return n-length Array filled by item public phase(c: *): * public productLoop(p1: Array, p2: Array, func: function) product loop on two Arrays p1 & p2 public productLoop3(p1: Array, p2: Array, p3: Array, func: function) product loop on three Arrays p1 & p2 & p3 public randomSample(array: any[], count: number): any[] return a random sample from `array` which length is `count` public return_swap_depth(swaps: Array): number Returns the circuit depth to execute these swaps. public setDifference(s1: *, s2: *): * public setEqual(s1: Set, s2: Set): boolean check if s1 is equal to s2 public setFromRange(n: number): Set create a Set contains numbers in range from 0 to n public setIsSuperSet(superset: Set, s: Set): boolean check if `superset` is the super set of `s` public stringToArray(key: *): * public stringToBitArray(str: string): boolean[] parse string contains 1/0 into bit array public symmetricDifference(s1: Set, s2: Set): Set<*> return symmetric difference of s1 & s2 public tuple(args: *): Array create `tuple` from arguments public unionSet(s1: Set, s2: Set): Set return union set of s1 & s2 public zeros(n: number): number[] generate a n-Length Array filled by `0`
 Static Private Summary private _decompose_CnU(cmd: *) Decompose a multi-controlled gate U into a single-controlled U. private _decompose_barrier(cmd: *) private _decompose_ry(cmd: *) private _find_parameters(matrix: Array): number[] Given a 2x2 unitary matrix, find the parameters a, b/2, c/2, and d/2 such that matrix == [[exp(j(a-b/2-d/2))cos(c/2), -exp(j(a-b/2+d/2))sin(c/2)], [exp(j(a+b/2-d/2))sin(c/2), exp(j(a+b/2+d/2))cos(c/2)]] private _recognize_CnU(cmd: *): boolean Recognize an arbitrary gate which has n>=2 control qubits, except a Toffoli gate. private _recognize_RxNoCtrl(cmd: *) private _recognize_RyNoCtrl(cmd: *) private _recognize_arb1qubit(cmd: Command): boolean Recognize an arbitrary one qubit gate which has a matrix property. private _recognize_barrier(cmd: *): boolean private _recognize_carb1qubit(cmd: *): boolean private _recognize_cnot(cmd: *) private _recognize_v(matrix: Array): boolean Recognizes a matrix which can be written in the following form:

## Static Public

### publicC(gate: BasicGate, n: number): * source

``import {C} from 'projectq/src/ops/metagates.js'``

Return n-controlled version of the provided gate.

#### Params:

 Name Type Attribute Description gate BasicGate Gate to turn into its controlled version n number Number of controls (default: 1)

 *

### publicCRz(angle: *): * source

``import {CRz} from 'projectq/src/ops/shortcuts.js'``

#### Params:

 Name Type Attribute Description angle *

 *

### publicCompute(engine: *, func: *) source

``import {Compute} from 'projectq/src/meta/compute.js'``

Start a compute-section.

#### Params:

 Name Type Attribute Description engine * func *

### publicControl(engine: BasicEngine, qubits: Array<BasicQubit>, func: function) source

``import {Control} from 'projectq/src/meta/control.js'``

Condition an entire code block on the value of qubits being 1.

#### Params:

 Name Type Attribute Description engine BasicEngine Engine which handles the commands (usually MainEngine) qubits Array Qubits to condition on func function Enter the section using a with-statement

### publicCustomUncompute(engine: *, func: *) source

``import {CustomUncompute} from 'projectq/src/meta/compute.js'``

Start a custom uncompute-section.

#### Params:

 Name Type Attribute Description engine * func *

#### Throw:

 QubitManagementError If qubits are allocated within Compute or within CustomUncompute context but are not deallocated.

### publicDagger(engine: BasicEngine, func: function) source

``import {Dagger} from 'projectq/src/meta/dagger.js'``

Invert an entire code block.

Use it with a with-statement, i.e.,

#### Params:

 Name Type Attribute Description engine BasicEngine Engine which handles the commands (usually MainEngine) func function

### publicLoop(engine: *, num: *, func: *) source

``import {Loop} from 'projectq/src/meta/loop.js'``

Loop n times over an entire code block.

#### Params:

 Name Type Attribute Description engine * num * func *

### publicObjectCopy(obj: Object): Object source

``import {ObjectCopy} from 'projectq/src/libs/util.js'``

create copy of object, with same `class`

#### Params:

 Name Type Attribute Description obj Object

### publicQureg(args: ...*): * source

``import {Qureg} from 'projectq/src/types/qubit.js'``

#### Params:

 Name Type Attribute Description args ...*

 *

### publicSubConstant(a: number): * source

``import {SubConstant} from 'projectq/src/libs/math/gates.js'``

Subtract a constant from a quantum number represented by a quantum register, stored from low- to high-bit.

#### Params:

 Name Type Attribute Description a number Constant to subtract

 *

### publicSubConstantModN(a: number, N: number): * source

``import {SubConstantModN} from 'projectq/src/libs/math/gates.js'``

Subtract a constant from a quantum number represented by a quantum register modulo N.

The number is stored from low- to high-bit, i.e., qunum[0] is the LSB.

#### Params:

 Name Type Attribute Description a number Constant to add N number Constant modulo which the addition of a should be carried out.

 *

### publicUncompute(engine: *) source

``import {Uncompute} from 'projectq/src/meta/compute.js'``

Uncompute automatically.

#### Params:

 Name Type Attribute Description engine *

### publicadd(key: *, value: *) source

``import {add} from 'projectq/src/ops/_cycle.js'``

#### Params:

 Name Type Attribute Description key * value *

### publicadd_constant(eng: *, c: *, quint: *) source

``import {add_constant} from 'projectq/src/libs/math/constantmath.js'``

Adds a classical constant c to the quantum integer (qureg) quint using Draper addition. Note: Uses the Fourier-transform adder from `https://arxiv.org/abs/quant-ph/0008033`.

#### Params:

 Name Type Attribute Description eng * c * quint *

### publicadd_constant_modN(eng: *, c: *, N: *, quint: *) source

``import {add_constant_modN} from 'projectq/src/libs/math/constantmath.js'``

Adds a classical constant c to a quantum integer (qureg) quint modulo N using Draper addition and the construction from `https://arxiv.org/abs/quant-ph/0205095`.

#### Params:

 Name Type Attribute Description eng * c * N * quint *

### publicarrayEqual(a1: Array, a2: Array, itemCompareFunc: function): boolean source

``import {arrayEqual} from 'projectq/src/libs/polyfill.js'``

test if two array(a1, a2) are equal, support instance of classes in this library

#### Params:

 Name Type Attribute Description a1 Array a2 Array itemCompareFunc function

### publicarrayFromRange(start: number, end: number, step: number): number[] source

``import {arrayFromRange} from 'projectq/src/libs/polyfill.js'``

create an array filled by number in range, active like python does

#### Params:

 Name Type Attribute Description start number end number step number

#### Return:

 number[]

### publicarrayIsTuple(value: Array): boolean source

``import {arrayIsTuple} from 'projectq/src/libs/util.js'``

check if an array is `tuple`

#### Params:

 Name Type Attribute Description value Array

### publicclassHierachy(cls: function): function[] source

``import {classHierachy} from 'projectq/src/libs/util.js'``

return class hierachy of `cls`

#### Params:

 Name Type Attribute Description cls function

#### Return:

 function[]

### publiccomplexVectorDot(a1: Complex[], a2: Complex[]): Complex source

``import {complexVectorDot} from 'projectq/src/libs/polyfill.js'``

return dot product of two complex vector(a1, a2)

#### Params:

 Name Type Attribute Description a1 Complex[] a2 Complex[]

#### Return:

 Complex

### publiccreate_test_matrices(): * source

``import {create_test_matrices} from 'projectq/src/setups/decompositions/arb1qubit2rzandry.spec.js'``

 *

### publicdropEngineAfter(engine: BasicEngine): BasicEngine source

``import {dropEngineAfter} from 'projectq/src/meta/util.js'``

Removes an engine from the singly-linked list of engines.

#### Params:

 Name Type Attribute Description engine BasicEngine The engine just before the engine to drop.

#### Return:

 BasicEngine The dropped engine.

### publicexpmod(base: number, exp: number, mod: number): number source

``import {expmod} from 'projectq/src/libs/polyfill.js'``

return (base ^ exp) % mod, it's fast and support big number

#### Params:

 Name Type Attribute Description base number exp number mod number

### publicgenString(item: string, n: number): string source

``import {genString} from 'projectq/src/libs/util.js'``

return item * n string like python does.

#### Params:

 Name Type Attribute Description item string n number

### publicget(key: *): * source

``import {get} from 'projectq/src/ops/_cycle.js'``

#### Params:

 Name Type Attribute Description key *

 *

### publicgetEngineList(one_qubit_gates: string | Array<BasicGate>, two_qubit_gates: string | Array<BasicGate>, other_gates: string | Array<BasicGate>): Array source

``import {getEngineList} from 'projectq/src/setups/restrictedgateset.js'``

Returns an engine list to compile to a restricted gate set.

Note: If you choose a new gate set for which the compiler does not yet have standard rules, it raises an `NoGateDecompositionError` or a `RuntimeError: maximum recursion depth exceeded...`. Also note that even the gate sets which work might not yet be optimized. So make sure to double check and potentially extend the decomposition rules. This implemention currently requires that the one qubit gates must contain Rz and at least one of {Ry(best), Rx, H} and the two qubit gate must contain CNOT (recommended) or CZ.

Note: Classical instructions gates such as e.g. Flush and Measure are automatically allowed.

#### Params:

 Name Type Attribute Description one_qubit_gates string | Array "any" allows any one qubit gate, otherwise provide a tuple of the allowed gates. If the gates are instances of a class (e.g. X), it allows all gates which are equal to it. If the gate is a class (Rz), it allows all instances of this class. Default is "any" two_qubit_gates string | Array "any" allows any two qubit gate, otherwise provide a tuple of the allowed gates. If the gates are instances of a class (e.g. CNOT), it allows all gates which are equal to it. If the gate is a class, it allows all instances of this class. Default is (CNOT,). other_gates string | Array A tuple of the allowed gates. If the gates are instances of a class (e.g. QFT), it allows all gates which are equal to it. If the gate is a class, it allows all instances of this class.

#### Return:

 Array A list of suitable compiler engines.

#### Throw:

 Error If input is for the gates is not "any" or a tuple.

#### Example:

``````get_engine_list(one_qubit_gates=(Rz, Ry, Rx, H),
two_qubit_gates=(CNOT,),
other_gates=(TimeEvolution,))``````

### publicgetEngineList(): undefined[] source

``import {getEngineList} from 'projectq/src/setups/ibm.js'``

### publicgetEngineList(num_rows: number, num_columns: number, one_qubit_gates: string | Array<BasicGate>, two_qubit_gates: string | Array<BasicGate>): undefined[] source

``import {getEngineList} from 'projectq/src/setups/grid.js'``

Returns an engine list to compile to a 2-D grid of qubits.

Note: If you choose a new gate set for which the compiler does not yet have standard rules, it raises an `NoGateDecompositionError` or a `RuntimeError: maximum recursion depth exceeded...`. Also note that even the gate sets which work might not yet be optimized. So make sure to double check and potentially extend the decomposition rules. This implemention currently requires that the one qubit gates must contain Rz and at least one of {Ry(best), Rx, H} and the two qubit gate must contain CNOT (recommended) or CZ.

Note: Classical instructions gates such as e.g. Flush and Measure are automatically allowed.

Example: get_engine_list(num_rows=2, num_columns=3, one_qubit_gates=(Rz, Ry, Rx, H), two_qubit_gates=(CNOT,))

Args: num_rows(int): Number of rows in the grid num_columns(int): Number of columns in the grid. one_qubit_gates: "any" allows any one qubit gate, otherwise provide a tuple of the allowed gates. If the gates are instances of a class (e.g. X), it allows all gates which are equal to it. If the gate is a class (Rz), it allows all instances of this class. Default is "any" two_qubit_gates: "any" allows any two qubit gate, otherwise provide a tuple of the allowed gates. If the gates are instances of a class (e.g. CNOT), it allows all gates which are equal to it. If the gate is a class, it allows all instances of this class. Default is (CNOT, Swap). Raises: TypeError: If input is for the gates is not "any" or a tuple.

Returns: A list of suitable compiler engines.

#### Params:

 Name Type Attribute Description num_rows number num_columns number one_qubit_gates string | Array two_qubit_gates string | Array

### publicgetEngineList(): undefined[] source

``import {getEngineList} from 'projectq/src/setups/index.js'``

### publicgetEngineList(): undefined[] source

``import {getEngineList} from 'projectq/src/setups/ibm16.js'``

### publicgetEngineList(num_qubits: number, cyclic: boolean, one_qubit_gates: string | Array<BasicGate>, two_qubit_gates: string | Array<BasicGate>): Array source

``import {getEngineList} from 'projectq/src/setups/linear.js'``

Returns an engine list to compile to a linear chain of qubits.

Note: If you choose a new gate set for which the compiler does not yet have standard rules, it raises an `NoGateDecompositionError` or a `RuntimeError: maximum recursion depth exceeded...`. Also note that even the gate sets which work might not yet be optimized. So make sure to double check and potentially extend the decomposition rules. This implemention currently requires that the one qubit gates must contain Rz and at least one of {Ry(best), Rx, H} and the two qubit gate must contain CNOT (recommended) or CZ.

Note: Classical instructions gates such as e.g. Flush and Measure are automatically allowed.

#### Params:

 Name Type Attribute Description num_qubits number Number of qubits in the chain cyclic boolean If a circle or not. Default is false one_qubit_gates string | Array "any" allows any one qubit gate, otherwise provide a tuple of the allowed gates. If the gates are instances of a class (e.g. X), it allows all gates which are equal to it. If the gate is a class (Rz), it allows all instances of this class. Default is "any" two_qubit_gates string | Array "any" allows any two qubit gate, otherwise provide a tuple of the allowed gates. If the gates are instances of a class (e.g. CNOT), it allows all gates which are equal to it. If the gate is a class, it allows all instances of this class. Default is (CNOT, Swap).

#### Return:

 Array A list of suitable compiler engines.

#### Throw:

 Error If input is for the gates is not "any" or a tuple.

#### Example:

``````get_engine_list(num_qubits=10, cyclic=false,
one_qubit_gates=(Rz, Ry, Rx, H),
two_qubit_gates=(CNOT,))``````

### publicgetInverse(gate: BasicGate): * source

``import {getInverse} from 'projectq/src/ops/_cycle.js'``

Return the inverse of a gate.

Tries to call gate.getInverse and, upon failure, creates a DaggeredGate instead.

#### Params:

 Name Type Attribute Description gate BasicGate Gate of which to get the inverse

 *

### publichigh_level_gates(eng: *, cmd: *): boolean source

``import {high_level_gates} from 'projectq/src/setups/grid.js'``

Remove any MathGates

#### Params:

 Name Type Attribute Description eng * cmd *

### publicinsertEngine(prevEngine: BasicEngine, engineToInsert: BasicEngine) source

``import {insertEngine} from 'projectq/src/meta/util.js'``

Inserts an engine into the singly-linked list of engines. It also sets the correct main_engine for engine_to_insert.

#### Params:

 Name Type Attribute Description prevEngine BasicEngine The engine just before the insertion point. engineToInsert BasicEngine The engine to insert at the insertion point.

### publicinstanceOf(inst: any, cls: function): boolean source

``import {instanceOf} from 'projectq/src/libs/util.js'``

check if `inst` is instance of `cls`, specialized for some class

#### Params:

 Name Type Attribute Description inst any cls function

### publicintersection(s1: Set, s2: Set): Set source

``import {intersection} from 'projectq/src/libs/polyfill.js'``

return intersection of s1 & s2

#### Params:

 Name Type Attribute Description s1 Set s2 Set

### publicisComplex(value: Object): boolean source

``import {isComplex} from 'projectq/src/libs/polyfill.js'``

check if value is complex number

#### Params:

 Name Type Attribute Description value Object

### publicisKindclassOf(cls: function, superClass: function): boolean source

``import {isKindclassOf} from 'projectq/src/libs/util.js'``

check if `cls` is kind of `superClass`, will return true if cls is superClass

#### Params:

 Name Type Attribute Description cls function superClass function

### publicisNumeric(value: Object): boolean source

``import {isNumeric} from 'projectq/src/libs/polyfill.js'``

check if value is number or complex number

#### Params:

 Name Type Attribute Description value Object

### publicisSubclassOf(cls: function, superClass: function): boolean source

``import {isSubclassOf} from 'projectq/src/libs/util.js'``

check if `cls` is subclass of `superClass`, will return false if cls is superClass

#### Params:

 Name Type Attribute Description cls function superClass function

### publiclen(v: any): number source

``import {len} from 'projectq/src/libs/polyfill.js'``

return `length` of v, act like python

#### Params:

 Name Type Attribute Description v any

### publicmarkTuple(value: *) source

``import {markTuple} from 'projectq/src/libs/util.js'``

force mark a value as `tuple`, internal usage only

#### Params:

 Name Type Attribute Description value *

### publicmatrixDot(matrix: math.matrix, vector: number[]): math.matrix source

``import {matrixDot} from 'projectq/src/libs/util.js'``

dot product of matrix & vector

#### Params:

 Name Type Attribute Description matrix math.matrix vector number[]

#### Return:

 math.matrix

### publicmatrixGetRow(matrix: math.matrix, index: number): number[] source

``import {matrixGetRow} from 'projectq/src/libs/util.js'``

return a row of matrix

#### Params:

 Name Type Attribute Description matrix math.matrix index number

#### Return:

 number[]

### publicmatrixRangeAssign(matrix: math.matrix, indices: number[], vector: number[]) source

``import {matrixRangeAssign} from 'projectq/src/libs/util.js'``

assign value in `vector` into `matrix` by index in `indices`

#### Params:

 Name Type Attribute Description matrix math.matrix indices number[] vector number[]

### publicmatrixRangeIndicesAssign(matrix: *, mstart: *, mend: *, vector: *, vstart: *) source

``import {matrixRangeIndicesAssign} from 'projectq/src/libs/util.js'``

#### Params:

 Name Type Attribute Description matrix * mstart * mend * vector * vstart *

### publicmul_by_constant_modN(eng: *, c: *, N: *, quint_in: *) source

``import {mul_by_constant_modN} from 'projectq/src/libs/math/constantmath.js'``

Multiplies a quantum integer by a classical number a modulo N, i.e.,

|x> -> |a*x mod N>

(only works if a and N are relative primes, otherwise the modular inverse does not exist).

#### Params:

 Name Type Attribute Description eng * c * N * quint_in *

### publicnarray(item: Function | any, count: number): Array source

``import {narray} from 'projectq/src/libs/polyfill.js'``

return n-length Array filled by item

#### Params:

 Name Type Attribute Description item Function | any count number

### publicphase(c: *): * source

``import {phase} from 'projectq/src/setups/decompositions/arb1qubit2rzandry.js'``

#### Params:

 Name Type Attribute Description c *

 *

### publicproductLoop(p1: Array, p2: Array, func: function) source

``import {productLoop} from 'projectq/src/libs/polyfill.js'``

product loop on two Arrays p1 & p2

#### Params:

 Name Type Attribute Description p1 Array p2 Array func function

### publicproductLoop3(p1: Array, p2: Array, p3: Array, func: function) source

``import {productLoop3} from 'projectq/src/libs/polyfill.js'``

product loop on three Arrays p1 & p2 & p3

#### Params:

 Name Type Attribute Description p1 Array p2 Array p3 Array func function

### publicrandomSample(array: any[], count: number): any[] source

``import {randomSample} from 'projectq/src/libs/polyfill.js'``

return a random sample from `array` which length is `count`

#### Params:

 Name Type Attribute Description array any[] count number

 any[]

### publicreturn_swap_depth(swaps: Array<Array>): number source

``import {return_swap_depth} from 'projectq/src/cengines/linearmapper.js'``

Returns the circuit depth to execute these swaps.

#### Params:

 Name Type Attribute Description swaps Array Each tuple contains two integers representing the two IDs of the qubits involved in the Swap operation

#### Return:

 number Circuit depth to execute these swaps.

### publicsetDifference(s1: *, s2: *): * source

``import {setDifference} from 'projectq/src/libs/polyfill.js'``

#### Params:

 Name Type Attribute Description s1 * s2 *

 *

### publicsetEqual(s1: Set, s2: Set): boolean source

``import {setEqual} from 'projectq/src/libs/polyfill.js'``

check if s1 is equal to s2

#### Params:

 Name Type Attribute Description s1 Set s2 Set

### publicsetFromRange(n: number): Set<number> source

``import {setFromRange} from 'projectq/src/libs/polyfill.js'``

create a Set contains numbers in range from 0 to n

#### Params:

 Name Type Attribute Description n number

### publicsetIsSuperSet(superset: Set, s: Set): boolean source

``import {setIsSuperSet} from 'projectq/src/libs/polyfill.js'``

check if `superset` is the super set of `s`

#### Params:

 Name Type Attribute Description superset Set s Set

### publicstringToArray(key: *): * source

``import {stringToArray} from 'projectq/src/ops/qubitoperator.js'``

#### Params:

 Name Type Attribute Description key *

 *

### publicstringToBitArray(str: string): boolean[] source

``import {stringToBitArray} from 'projectq/src/libs/polyfill.js'``

parse string contains 1/0 into bit array

#### Params:

 Name Type Attribute Description str string

#### Return:

 boolean[]

### publicsymmetricDifference(s1: Set, s2: Set): Set<*> source

``import {symmetricDifference} from 'projectq/src/libs/polyfill.js'``

return symmetric difference of s1 & s2

#### Params:

 Name Type Attribute Description s1 Set s2 Set

 Set<*>

### publictuple(args: *): Array source

``import {tuple} from 'projectq/src/libs/util.js'``

create `tuple` from arguments

#### Params:

 Name Type Attribute Description args *

### publicunionSet(s1: Set, s2: Set): Set<any> source

``import {unionSet} from 'projectq/src/libs/polyfill.js'``

return union set of s1 & s2

#### Params:

 Name Type Attribute Description s1 Set s2 Set

 Set

### publiczeros(n: number): number[] source

``import {zeros} from 'projectq/src/libs/util.js'``

generate a n-Length Array filled by `0`

#### Params:

 Name Type Attribute Description n number

#### Return:

 number[]

## Static Private

### private_decompose_CnU(cmd: *) source

``import {_decompose_CnU} from 'projectq/src/setups/decompositions/cnu2toffoliandcu.js'``

Decompose a multi-controlled gate U into a single-controlled U. It uses (n-1) work qubits and 2 * (n-1) Toffoli gates.

#### Params:

 Name Type Attribute Description cmd *

### private_decompose_barrier(cmd: *) source

``import {_decompose_barrier} from 'projectq/src/setups/decompositions/barrier.js'``

#### Params:

 Name Type Attribute Description cmd *

### private_decompose_ry(cmd: *) source

``import {_decompose_ry} from 'projectq/src/setups/decompositions/ry2rz.js'``

#### Params:

 Name Type Attribute Description cmd *

### private_find_parameters(matrix: Array<number[]>): number[] source

``import {_find_parameters} from 'projectq/src/setups/decompositions/arb1qubit2rzandry.js'``

Given a 2x2 unitary matrix, find the parameters a, b/2, c/2, and d/2 such that matrix == [[exp(j(a-b/2-d/2))cos(c/2), -exp(j(a-b/2+d/2))sin(c/2)], [exp(j(a+b/2-d/2))sin(c/2), exp(j(a+b/2+d/2))cos(c/2)]]

Note: If the matrix is element of SU(2) (determinant == 1), then we can choose a = 0.

#### Params:

 Name Type Attribute Description matrix Array 2x2 unitary matrix

#### Return:

 number[] parameters of the matrix: (a, b/2, c/2, d/2)

### private_recognize_CnU(cmd: *): boolean source

``import {_recognize_CnU} from 'projectq/src/setups/decompositions/cnu2toffoliandcu.js'``

Recognize an arbitrary gate which has n>=2 control qubits, except a Toffoli gate.

#### Params:

 Name Type Attribute Description cmd *

### private_recognize_RxNoCtrl(cmd: *) source

``import {_recognize_RxNoCtrl} from 'projectq/src/setups/decompositions/rx2rz.js'``

#### Params:

 Name Type Attribute Description cmd *

### private_recognize_RyNoCtrl(cmd: *) source

``import {_recognize_RyNoCtrl} from 'projectq/src/setups/decompositions/ry2rz.js'``

#### Params:

 Name Type Attribute Description cmd *

### private_recognize_arb1qubit(cmd: Command): boolean source

``import {_recognize_arb1qubit} from 'projectq/src/setups/decompositions/arb1qubit2rzandry.js'``

Recognize an arbitrary one qubit gate which has a matrix property.

It does not allow gates which have control qubits as otherwise the AutoReplacer might go into an infinite loop. Use carb1qubit2cnotrzandry instead.

#### Params:

 Name Type Attribute Description cmd Command

### private_recognize_barrier(cmd: *): boolean source

``import {_recognize_barrier} from 'projectq/src/setups/decompositions/barrier.js'``

#### Params:

 Name Type Attribute Description cmd *

### private_recognize_carb1qubit(cmd: *): boolean source

``import {_recognize_carb1qubit} from 'projectq/src/setups/decompositions/carb1qubit2cnotrzandry.js'``

#### Params:

 Name Type Attribute Description cmd *

### private_recognize_cnot(cmd: *) source

``import {_recognize_cnot} from 'projectq/src/setups/decompositions/cnot2cz.js'``

#### Params:

 Name Type Attribute Description cmd *

### private_recognize_v(matrix: Array<number[]>): boolean source

``import {_recognize_v} from 'projectq/src/setups/decompositions/carb1qubit2cnotrzandry.js'``

Recognizes a matrix which can be written in the following form:

V = [[-sin(c/2) exp(ja), exp(j(a-b)) cos(c/2)], [exp(j(a+b)) cos(c/2), exp(ja) sin(c/2)]]

#### Params:

 Name Type Attribute Description matrix Array 2x2 matrix

#### Return:

 boolean false if it is not possible otherwise (a, b, c/2)