Home Reference Source
public class | source

ClassicalSimulator

Extends:

BasicEngine → ClassicalSimulator

Constructor Summary

Public Constructor
public

Member Summary

Private Members
private
private

_state: *

Method Summary

Public Methods
public

Converts a qubit from a logical to a mapped qubit if there is a mapper.

public

handle(cmd: Command)

public

isAvailable(cmd: *): *

public

mask(qureg: Qureg): number

Returns a mask, to compare against the state, with bits from the register set to 1 and other bits set to 0.

public

readBit(qubit: Qubit): number

Reads a bit.

public

readMappedBit(mappedQubit: *): *

public

readMappedRegister(mappedQureg: *): *

public

Reads a group of bits as a little-endian integer.

public

receive(commandList: *)

public

writeBit(qubit: Qubit, value: boolean | number)

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

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() source

Override:

BasicEngine#constructor

Private Members

private _bit_positions: {} source

private _state: * source

Public Methods

public convertLogicalToMappedQubit(qubit: Qubit): * source

Converts a qubit from a logical to a mapped qubit if there is a mapper.

Params:

NameTypeAttributeDescription
qubit Qubit

Logical quantum bit

Return:

*

public handle(cmd: Command) source

Params:

NameTypeAttributeDescription
cmd Command

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#isAvailable

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
qureg Qureg

The bits whose positions should be set.

Return:

number

The mask.

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:

NameTypeAttributeDescription
qubit Qubit

The bit to read.

Return:

number

0 if the target bit is off, 1 if it's on.

public readMappedBit(mappedQubit: *): * source

Params:

NameTypeAttributeDescription
mappedQubit *

Return:

*

public readMappedRegister(mappedQureg: *): * source

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
qureg Qureg

The group of bits to read, in little-endian order.

Return:

number

Little-endian register value.

public receive(commandList: *) source

Override:

BasicEngine#receive

Params:

NameTypeAttributeDescription
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.

Params:

NameTypeAttributeDescription
qubit Qubit

The bit to write.

value boolean | number

Writes 1 if this value is truthy, else 0.

public writeMappedBit(mappedQubit: *, value: *) source

Params:

NameTypeAttributeDescription
mappedQubit *
value *

public writeMappedRegister(mappedQureg: *, value: *) source

Params:

NameTypeAttributeDescription
mappedQureg *
value *

public writeRegister(qureg: Qureg, value: number) source

Sets a group of bits to store a little-endian integer 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.

Params:

NameTypeAttributeDescription
qureg Qureg

The bits to write, in little-endian order.

value number

The integer value to store. Must fit in the register.