Home Reference Source
import {BasicGate} from 'projectq/src/ops/basics.js'
public class | source

BasicGate

Direct Subclass:

BarrierGate, BasicMathGate, BasicPhaseGate, BasicRotationGate, ClassicalInstructionGate, ControlledGate, DaggeredGate, EntangleGate, src/backends/simulators/simulator.spec.js~Mock1QubitGate, src/backends/simulators/simulator.spec.js~Mock6QubitGate, src/backends/simulators/simulator.spec.js~MockNoMatrixGate, QFTGate, SelfInverseGate, SqrtSwapGate, SqrtXGate, TGate, Tensor, TimeEvolution

Static Method Summary

Static Public Methods
public static

makeTupleOfQureg(qubits: Qubit | Qubit[] | Qureg | Qureg[]): Qureg[]

Convert quantum input of "gate | quantum input" to internal formatting.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

Method Summary

Public Methods
public
public

equal(other: BasicGate | Object): boolean

public

generateCommand(qubits: *): Command

Helper function to generate a command consisting of the gate and the qubits being acted upon.

public
public
public
public

or(qubits: *)

Operator| overload which enables the syntax Gate | qubits.

public

Static Public Methods

public static makeTupleOfQureg(qubits: Qubit | Qubit[] | Qureg | Qureg[]): Qureg[] source

Convert quantum input of "gate | quantum input" to internal formatting.

A Command object only accepts tuples of Quregs (list of Qubit objects) as qubits input parameter. However, with this function we allow the user to use a more flexible syntax:

1) Gate | qubit 2) Gate | [qubit0, qubit1] 3) Gate | qureg 4) Gate | (qubit, ) 5) Gate | (qureg, qubit)

where qubit is a Qubit object and qureg is a Qureg object. This function takes the right hand side of | and transforms it to the correct input parameter of a Command object which is:

1) -> Gate | ([qubit], ) 2) -> Gate | ([qubit0, qubit1], ) 3) -> Gate | (qureg, ) 4) -> Gate | ([qubit], ) 5) -> Gate | (qureg, [qubit])

Params:

NameTypeAttributeDescription
qubits Qubit | Qubit[] | Qureg | Qureg[]

a Qubit object, a list of Qubit objects, a Qureg object, or a tuple of Qubit or Qureg objects (can be mixed).

Return:

Qureg[]

Canonical representation A tuple containing Qureg (or list of Qubits) objects.

Public Constructors

public constructor() source

Public Members

public interchangeableQubitIndices: *[] source

Public Methods

public copy(): BasicGate source

Return:

BasicGate

public equal(other: BasicGate | Object): boolean source

Params:

NameTypeAttributeDescription
other BasicGate | Object

Return:

boolean

public generateCommand(qubits: *): Command source

Helper function to generate a command consisting of the gate and the qubits being acted upon.

Params:

NameTypeAttributeDescription
qubits *

{Qubit | Array.<Qubit> | Qureg} see BasicGate.makeTupleOfQureg(qubits)

Return:

Command

A Command object containing the gate and the qubits.

public getInverse() source

Throw:

Error

public getMerged() source

Throw:

NotMergeable

public inspect(): string source

Return:

string

public or(qubits: *) source

Operator| overload which enables the syntax Gate | qubits.

Params:

NameTypeAttributeDescription
qubits *

{Qubit | Array.<Qubit> | Qureg} a Qubit object, a list of Qubit objects, a Qureg object, or a tuple of Qubit or Qureg objects (can be mixed).

Example:

1) Gate | qubit
2) Gate | [qubit0, qubit1]
3) Gate | qureg
4) Gate | (qubit, )
5) Gate | (qureg, qubit)

public toString() source

Throw:

Error