Home Reference Source
import LocalOptimizer from 'projectq/src/cengines/optimize.js'
public class | source

LocalOptimizer

Extends:

BasicEngine → LocalOptimizer

Constructor Summary

Public Constructor
public

Member Summary

Private Members
private

_l: {}

private

_m: *

Method Summary

Public Methods
public

Cache a command, i.e., inserts it into the command lists of all qubits involved.

public

Check whether a qubit pipeline must be sent on and, if so, optimize the pipeline and then send it on.

public

getGateIndices(idx: number, i: number, IDs: number[]): number[]

Return all indices of a command, each index corresponding to the command's index in one of the qubits' command lists.

public

optimize(idx: number, lim: number): *

Try to merge or even cancel successive gates using the get_merged and getInverse functions of the gate (see, e.g., BasicRotationGate).

public

receive(commandList: *)

Receive commands from the previous engine and cache them.

public

Send n gate operations of the qubit with index idx to the next engine.

Inherited Summary

From class BasicEngine
public
public

Return a new qubit as a list containing 1 qubit object (quantum register of size 1).

public

Allocate n qubits and return them as a quantum register, which is a list of qubit objects.

public

Deallocate a qubit (and sends the deallocation command down the pipeline).

public

Default implementation of isAvailable: Ask the next engine whether a command is available, i.e., whether it can be executed by the next engine(s).

public

Check if there is a compiler engine handling the meta tag

public
public

send(commandList: Command[])

Forward the list of commands to the next engine in the pipeline.

Public Constructors

public constructor(m: number) source

Override:

BasicEngine#constructor

Params:

NameTypeAttributeDescription
m number

Number of gates to cache per qubit, before sending on the first gate.

Private Members

private _l: {} source

private _m: * source

Public Methods

public cacheCMD(cmd: Command) source

Cache a command, i.e., inserts it into the command lists of all qubits involved.

Params:

NameTypeAttributeDescription
cmd Command

public checkAndSend() source

Check whether a qubit pipeline must be sent on and, if so, optimize the pipeline and then send it on.

public getGateIndices(idx: number, i: number, IDs: number[]): number[] source

Return all indices of a command, each index corresponding to the command's index in one of the qubits' command lists.

Params:

NameTypeAttributeDescription
idx number

qubit index

i number

command position in qubit idx's command list

IDs number[]

IDs of all qubits involved in the command

Return:

number[]

public optimize(idx: number, lim: number): * source

Try to merge or even cancel successive gates using the get_merged and getInverse functions of the gate (see, e.g., BasicRotationGate).

It does so for all qubit command lists.

Params:

NameTypeAttributeDescription
idx number
lim number

Return:

*

public receive(commandList: *) source

Receive commands from the previous engine and cache them. If a flush gate arrives, the entire buffer is sent on.

Override:

BasicEngine#receive

Params:

NameTypeAttributeDescription
commandList *

public sendQubitPipeline(idx: number, n: number) source

Send n gate operations of the qubit with index idx to the next engine.

Params:

NameTypeAttributeDescription
idx number

qubit index

n number

command position in qubit idx's command list