import ClassicalSimulator from 'projectq/src/backends/simulators/classicalsimulator.js'ClassicalSimulator
Extends:
A simple introspective simulator that only permits classical operations.
Allows allocation, deallocation, measuring (no-op), flushing (no-op), controls, NOTs, and any BasicMathGate. Supports reading/writing directly from/to bits and registers of bits.
Constructor Summary
| Public Constructor | ||
| public | 
      
       | 
    |
Member Summary
| Private Members | ||
| private | 
       _bit_positions: {}  | 
    |
| private | 
       _state: *  | 
    |
Method Summary
| Public Methods | ||
| public | 
       convertLogicalToMappedQubit(qubit: Qubit): * Converts a qubit from a logical to a mapped qubit if there is a mapper.  | 
    |
| public | 
      
       | 
    |
| public | 
       isAvailable(cmd: *): *  | 
    |
| public | 
      
       Returns a mask, to compare against the state, with bits from the register set to 1 and other bits set to 0.  | 
    |
| public | 
      
       Reads a bit.  | 
    |
| public | 
       readMappedBit(mappedQubit: *): *  | 
    |
| public | 
       readMappedRegister(mappedQureg: *): *  | 
    |
| public | 
       readRegister(qureg: Qureg): number Reads a group of bits as a little-endian integer.  | 
    |
| public | 
       receive(commandList: *)  | 
    |
| public | 
      
       Resets/sets a bit to the given value.  | 
    |
| public | 
       writeMappedBit(mappedQubit: *, value: *)  | 
    |
| public | 
       writeMappedRegister(mappedQureg: *, value: *)  | 
    |
| public | 
       writeRegister(qureg: Qureg, value: number) Sets a group of bits to store a little-endian integer value.  | 
    |
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 Methods
public convertLogicalToMappedQubit(qubit: Qubit): * source
Converts a qubit from a logical to a mapped qubit if there is a mapper.
Params:
| Name | Type | Attribute | Description | 
| qubit | Qubit | Logical quantum bit  | 
    
Return:
| * | 
public isAvailable(cmd: *): * source
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).
Override:
BasicEngine#isAvailableParams:
| Name | Type | Attribute | Description | 
| cmd | * | 
Return:
| * | 
public mask(qureg: Qureg): number source
Returns a mask, to compare against the state, with bits from the register set to 1 and other bits set to 0.
Params:
| Name | Type | Attribute | Description | 
| qureg | Qureg | The bits whose positions should be set.  | 
    
public readBit(qubit: Qubit): number source
Reads a bit.
Note: If there is a mapper present in the compiler, this function automatically converts from logical qubits to mapped qubits for the qureg argument.
Params:
| Name | Type | Attribute | Description | 
| qubit | Qubit | The bit to read.  | 
    
public readMappedBit(mappedQubit: *): * source
Params:
| Name | Type | Attribute | Description | 
| mappedQubit | * | 
Return:
| * | 
public readMappedRegister(mappedQureg: *): * source
Params:
| Name | Type | Attribute | Description | 
| mappedQureg | * | 
Return:
| * | 
public readRegister(qureg: Qureg): number source
Reads a group of bits as a little-endian integer.
Note: If there is a mapper present in the compiler, this function automatically converts from logical qubits to mapped qubits for the qureg argument.
Params:
| Name | Type | Attribute | Description | 
| qureg | Qureg | The group of bits to read, in little-endian order.  | 
    
public receive(commandList: *) source
Override:
BasicEngine#receiveParams:
| Name | Type | Attribute | Description | 
| commandList | * | 
public writeBit(qubit: Qubit, value: boolean | number) source
Resets/sets a bit to the given value.
Note: If there is a mapper present in the compiler, this function automatically converts from logical qubits to mapped qubits for the qureg argument.
public writeMappedBit(mappedQubit: *, value: *) source
Params:
| Name | Type | Attribute | Description | 
| mappedQubit | * | ||
| value | * | 
public writeMappedRegister(mappedQureg: *, value: *) source
Params:
| Name | Type | Attribute | Description | 
| mappedQureg | * | ||
| value | * |