Home Reference Source
import {AddConstant} from 'projectq/src/libs/math/gates.js'
public class | source

AddConstant

Extends:

BasicGateBasicMathGate → AddConstant

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

Example:


qunum = eng.allocateQureg(5) # 5-qubit number
X | qunum[1] # qunum is now equal to 2
AddConstant(3) | qunum # qunum is now equal to 5

Constructor Summary

Public Constructor
public

Initializes the gate to the number to add.

Member Summary

Public Members
public

a: *

Method Summary

Public Methods
public

equal(other: *): *

public

getInverse(): *

public

Inherited Summary

From class BasicGate
public static

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

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

public
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
From class BasicMathGate
public
public

Return the math function which corresponds to the action of this math gate, given the input to the gate (a tuple of quantum registers).

public

Public Constructors

public constructor(a: number) source

Initializes the gate to the number to add.

Override:

BasicMathGate#constructor

Params:

NameTypeAttributeDescription
a number

Number to add to a quantum register.

It also initializes its base class, BasicMathGate, with the corresponding function, so it can be emulated efficiently.

Public Members

public a: * source

Public Methods

public equal(other: *): * source

Override:

BasicGate#equal

Params:

NameTypeAttributeDescription
other *

Return:

*

public getInverse(): * source

Override:

BasicGate#getInverse

Return:

*

public toString(): string source

Override:

BasicMathGate#toString

Return:

string