Home Reference Source
import CommandPrinter from 'projectq/src/backends/printer.js'
public class | source

CommandPrinter

Extends:

BasicEngine → CommandPrinter

Constructor Summary

Public Constructor
public

constructor(acceptInput:: boolean, inPlace:: boolean)

Member Summary

Private Members
private
private
private

Method Summary

Public Methods
public

Specialized implementation of isAvailable: Returns true if the CommandPrinter is the last engine (since it can print any command).

public

Print a command or, if the command is a measurement instruction and the CommandPrinter is the last engine in the engine pipeline: Query the user for the measurement result (if accept_input = true) / Set the result to 0 (if it's false).

public

receive(commandList: Command[])

Receive a list of commands from the previous engine, print the commands, and then send them on 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(acceptInput:: boolean, inPlace:: boolean) source

Override:

BasicEngine#constructor

Params:

NameTypeAttributeDescription
acceptInput: boolean

If accept_input is true, the printer queries the user to input measurement results if the CommandPrinter is the last engine. Otherwise, all measurements yield

defaultMeasure. boolean

Default measurement result (if accept_input is false).

inPlace: boolean

If in_place is true, all output is written on the same line of the terminal.

Private Members

private _acceptInput: * source

private _defaultMeasure: * source

private _inPlace: * source

Public Methods

public isAvailable(cmd: Command): boolean source

Specialized implementation of isAvailable: Returns true if the CommandPrinter is the last engine (since it can print any command).

Override:

BasicEngine#isAvailable

Params:

NameTypeAttributeDescription
cmd Command

Command of which to check availability (all Commands can be printed).

Return:

boolean

true, unless the next engine cannot handle the Command (if there is a next engine).

public printCMD(cmd: Command) source

Print a command or, if the command is a measurement instruction and the CommandPrinter is the last engine in the engine pipeline: Query the user for the measurement result (if accept_input = true) / Set the result to 0 (if it's false).

Params:

NameTypeAttributeDescription
cmd Command

Command to print.

public receive(commandList: Command[]) source

Receive a list of commands from the previous engine, print the commands, and then send them on to the next engine.

Override:

BasicEngine#receive

Params:

NameTypeAttributeDescription
commandList Command[]

List of Commands to print (and potentially send on to the next engine).