AutoReplacer
Extends:
The AutoReplacer is a compiler engine which uses engine.isAvailable in order to determine which commands need to be replaced/decomposed/compiled further. The loaded setup is used to find decomposition rules appropriate for each command (e.g., setups.default).
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 | 
       _processCommand(cmd: Command) 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 | 
       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(decompositionRuleSet: DecompositionRuleSet, decomposition_chooser: function) source
Override:
BasicEngine#constructorParams:
| Name | Type | Attribute | Description | 
| 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  | 
    
Example:
repl = new AutoReplacer()
Amounts to
    
function decomposition_chooser(cmd, decomp_list) {
return decomp_list[0]
}
const repl = new AutoReplacer(decomposition_chooser)
    Public Members
public decompositionRuleSet: * source
Private Members
private _decomp_chooser: * source
Public Methods
public receive(commandList: *) source
Override:
BasicEngine#receiveParams:
| Name | Type | Attribute | Description | 
| 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:
| Name | Type | Attribute | Description | 
| cmd | Command | Command to process.  | 
    
Throw:
*  | 
        Exception if no replacement is available in the loaded setup.  |