Home Reference Source
import {CircuitDrawer} from 'projectq/src/backends/circuits/drawer.js'
public class | source

CircuitDrawer

Extends:

src/cengines.js~BasicEngine → CircuitDrawer

Constructor Summary

Public Constructor
public

constructor(accept_input: boolean, default_measure: number)

Member Summary

Private Members
private
private
private
private

_map: {}

private

Method Summary

Public Methods
public

Return the latex document string representing the circuit.

public

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

public

Add the command cmd to the circuit diagram, taking care of potential measurements as specified in the init function.

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.

public

Sets the qubit lines to use for the qubits explicitly.

Public Constructors

public constructor(accept_input: boolean, default_measure: number) source

Params:

NameTypeAttributeDescription
accept_input boolean

If accept_input is true, the printer queries the user to input measurement results if the CircuitDrawer is the last engine. Otherwise, all measurements yield the result default_measure (0 or 1).

default_measure number

Default value to use as measurement results if accept_input is false and there is no underlying backend to register real measurement results.

Private Members

private _accept_input: * source

private _default_measure: * source

private _free_lines: *[] source

private _map: {} source

private _qubit_lines: {} source

Public Methods

public getLatex(): string source

Return the latex document string representing the circuit.

Simply write this string into a tex-file or, alternatively, pipe the output directly to, e.g., pdflatex:

Return:

string

public isAvailable(cmd: Command): boolean source

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

Params:

NameTypeAttributeDescription
cmd Command

Command for 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

Add the command cmd to the circuit diagram, taking care of potential measurements as specified in the init function.

Queries the user for measurement input if a measurement command arrives if accept_input was set to true. Otherwise, it uses the default_measure parameter to register the measurement outcome.

Params:

NameTypeAttributeDescription
cmd Command

Command to add to the circuit diagram.

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.

Params:

NameTypeAttributeDescription
commandList Command[]

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

public setQubitLocations(idToLoc: Object) source

Sets the qubit lines to use for the qubits explicitly.

To figure out the qubit IDs, simply use the setting draw_id in the settings file. It is located in "gates":"AllocateQubitGate". If draw_id is true, the qubit IDs are drawn in red.

Params:

NameTypeAttributeDescription
idToLoc Object

Dictionary mapping qubit ids to qubit line numbers.

Throw:

Error

If the mapping has already begun (this function needs be called before any gates have been received).