Home Reference Source
import {ComputeEngine} from 'projectq/src/meta/compute.js'
public class | source

ComputeEngine

Extends:

BasicEngine → ComputeEngine

Adds Compute-tags to all commands and stores them (to later uncompute them automatically)

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public
Private Members
private
private

_l: *[]

Method Summary

Public Methods
public

Modify the command tags, inserting an UncomputeTag.

public

End the compute step (exit the Compute() - statement).

public

receive(commandList: Command[])

If in compute-mode: Receive commands and store deepcopy of each cmd.

public

Send uncomputing gates.

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() source

Override:

BasicEngine#constructor

Public Members

public allocatedQubitIDs: * source

public deallocatedQubitIDs: * source

Private Members

private _compute: boolean source

private _l: *[] source

Public Methods

public addUnComputeTag(cmd: Command): * source

Modify the command tags, inserting an UncomputeTag.

Params:

NameTypeAttributeDescription
cmd Command

Command to modify.

Return:

*

public endCompute() source

End the compute step (exit the Compute() - statement).

Will tell the Compute-engine to stop caching. It then waits for the uncompute instruction, which is when it sends all cached commands inverted and in reverse order down to the next compiler engine.

Throw:

QubitManagementError

If qubit has been deallocated in Compute section which has not been allocated in Compute section

public receive(commandList: Command[]) source

If in compute-mode: Receive commands and store deepcopy of each cmd. Add ComputeTag to received cmd and send it on. Otherwise: send all received commands directly to next_engine.

Override:

BasicEngine#receive

Params:

NameTypeAttributeDescription
commandList Command[]

List of commands to receive.

public runUnCompute() source

Send uncomputing gates.

Sends the inverse of the stored commands in reverse order down to the next engine. And also deals with allocated qubits in Compute section. If a qubit has been allocated during compute, it will be deallocated during uncompute. If a qubit has been allocated and deallocated during compute, then a new qubit is allocated and deallocated during uncompute.