LoopEngine
Extends:
Stores all commands and, when done, executes them num times if no loop tag handler engine is available. If there is one, it adds a loop_tag to the commands and sends them on.
Constructor Summary
Public Constructor | ||
public |
constructor(num: number) |
Member Summary
Private Members | ||
private |
|
|
private |
_cmdList: *[] |
|
private |
|
|
private |
|
|
private |
_refsToLocalQB: {} |
|
private |
_tag: * |
Method Summary
Public Methods | ||
public |
Receive (and potentially temporarily store) all commands. |
|
public |
run() Apply the loop statements to all stored commands. |
Inherited Summary
From class BasicEngine | ||
public |
|
|
public |
allocateQubit(dirty: boolean): Qureg Return a new qubit as a list containing 1 qubit object (quantum register of size 1). |
|
public |
allocateQureg(n: number): Qureg Allocate n qubits and return them as a quantum register, which is a list of qubit objects. |
|
public |
deallocateQubit(qubit: BasicQubit) Deallocate a qubit (and sends the deallocation command down the pipeline). |
|
public |
isAvailable(cmd: Command): boolean 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 |
isMetaTagSupported(metaTag: function): boolean Check if there is a compiler engine handling the meta tag |
|
public |
receive() |
|
public |
Forward the list of commands to the next engine in the pipeline. |
Public Constructors
public constructor(num: number) source
Override:
BasicEngine#constructorParams:
Name | Type | Attribute | Description |
num | number | Number of loop iterations. |
Private Members
private _allocatedQubitIDs: * source
private _cmdList: *[] source
private _deallocatedQubitIDs: * source
private _refsToLocalQB: {} source
private _tag: * source
Public Methods
public receive(commandList: Command[]) source
Receive (and potentially temporarily store) all commands.
Add LoopTag to all receiving commands and send to the next engine if a further engine is a LoopTag-handling engine. Otherwise store all commands (to later unroll them). Check that within the loop body, all allocated qubits have also been deallocated. If loop needs to be unrolled and ancilla qubits have been allocated within the loop body, then store a reference all these qubit ids (to change them when unrolling the loop)
Override:
BasicEngine#receiveParams:
Name | Type | Attribute | Description |
commandList | Command[] | List of commands to store and later unroll or, if there is a LoopTag-handling engine, add the LoopTag. |
public run() source
Apply the loop statements to all stored commands. Unrolls the loop if LoopTag is not supported by any of the following engines, i.e., if
Example:
is_meta_tag_supported(next_engine, LoopTag) == false