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

MainEngine

Extends:

BasicEngine → MainEngine

Constructor Summary

Public Constructor
public

constructor(backend: BasicEngine, engineList: Array<BasicEngine>, verbose: boolean)

Member Summary

Public Members
public
public

backend: *

public
public

main: *

public

mapper: *

public

next: *

public

verbose: *

Private Members
private
private

Method Summary

Public Methods
public

Destroy the main engine.

public

flush(deallocateQubits: boolean)

Flush the entire circuit down the pipeline, clearing potential buffers (of, e.g., optimizers).

public

Return the classical value of a measured qubit, given that an engine registered this result previously (see setMeasurementResult).

public

Returns a unique qubit id to be used for the next qubit allocation.

public

receive(commandList: Command[])

Forward the list of commands to the first engine.

public

send(commandList: *)

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

public

Register a measurement result

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(backend: BasicEngine, engineList: Array<BasicEngine>, verbose: boolean) source

Override:

BasicEngine#constructor

Params:

NameTypeAttributeDescription
backend BasicEngine

Backend to send the compiled circuit to.

engineList Array<BasicEngine>

List of engines / backends to use as compiler engines. Note: The engine list must not contain multiple mappers (instances of BasicMapperEngine). Default: getEngineList()

verbose boolean

Either print full or compact error messages. Default: false (i.e. compact error messages).

Example:


    

    

    

Public Members

public activeQubits: * source

public backend: * source

public dirtyQubits: * source

public main: * source

public mapper: * source

public next: * source

public verbose: * source

Private Members

private _measurements: {} source

private _qubitIdx: number source

Public Methods

public deallocate() source

Destroy the main engine. Flushes the entire circuit down the pipeline, clearing all temporary buffers (in, e.g., optimizers).

public flush(deallocateQubits: boolean) source

Flush the entire circuit down the pipeline, clearing potential buffers (of, e.g., optimizers).

Params:

NameTypeAttributeDescription
deallocateQubits boolean

If true, deallocates all qubits that are still alive (invalidating references to them by setting their id to -1).

public getMeasurementResult(qubit: BasicQubit): * source

Return the classical value of a measured qubit, given that an engine registered this result previously (see setMeasurementResult).

Params:

NameTypeAttributeDescription
qubit BasicQubit

Qubit of which to get the measurement result.

Return:

*

Example:


    

public getNewQubitID(): number source

Returns a unique qubit id to be used for the next qubit allocation.

Return:

number

New unique qubit id.

public receive(commandList: Command[]) source

Forward the list of commands to the first engine.

Override:

BasicEngine#receive

Params:

NameTypeAttributeDescription
commandList Command[]

List of commands to receive (and then send on)

public send(commandList: *) source

Forward the list of commands to the next engine in the pipeline. It also shortens exception stack traces if this.verbose is false.

Override:

BasicEngine#send

Params:

NameTypeAttributeDescription
commandList *

public setMeasurementResult(qubit: BasicQubit, value: boolean) source

Register a measurement result

The engine being responsible for measurement results needs to register these results with the master engine such that they are available when the user calls an int() or bool() conversion operator on a measured qubit.

Params:

NameTypeAttributeDescription
qubit BasicQubit

Qubit for which to register the measurement result.

value boolean

Boolean value of the measurement outcome (true / false = 1 / 0 respectively).