Home Reference Source
import {AutoReplacer} from 'projectq/src/cengines/replacer/replacer.js'
public class | source

AutoReplacer

Extends:

BasicEngine → AutoReplacer

Constructor Summary

Public Constructor
public

constructor(decompositionRuleSet: DecompositionRuleSet, decomposition_chooser:: function)

Member Summary

Public Members
public
Private Members
private

Method Summary

Public Methods
public

receive(commandList: *)

Private Methods
private

Check whether a command cmd can be handled by further engines and, if not, replace it using the decomposition rules loaded with the setup (e.g., setups.default).

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(decompositionRuleSet: DecompositionRuleSet, decomposition_chooser:: function) source

Override:

BasicEngine#constructor

Params:

NameTypeAttributeDescription
decompositionRuleSet DecompositionRuleSet
decomposition_chooser: function

A function which, given the Command to decompose and a list of potential Decomposition objects, determines (and then returns) the 'best' decomposition.

The default decomposition chooser simply returns the first list element, i.e., calling

Public Members

public decompositionRuleSet: * source

Private Members

private _decomp_chooser: * source

Public Methods

public receive(commandList: *) source

Override:

BasicEngine#receive

Params:

NameTypeAttributeDescription
commandList *

Private Methods

private _processCommand(cmd: Command) source

Check whether a command cmd can be handled by further engines and, if not, replace it using the decomposition rules loaded with the setup (e.g., setups.default).

Params:

NameTypeAttributeDescription
cmd Command

Command to process.

Throw:

*

Exception if no replacement is available in the loaded setup.