Home Reference Source
import SwapAndCNOTFlipper from 'projectq/src/cengines/swapandcnotflipper.js'
public class | source

SwapAndCNOTFlipper

Extends:

BasicEngine → SwapAndCNOTFlipper

Flips CNOTs and translates Swaps to CNOTs where necessary.

Warning: This engine assumes that CNOT and Hadamard gates are supported by the following engines.

Warning: This engine cannot be used as a backend.

Constructor Summary

Public Constructor
public

constructor(connectivity: Set<string>|Set<Array.<number>>)

Member Summary

Public Members
public

Method Summary

Public Methods
public

isAvailable(cmd: Command): *

Check if the IBM backend can perform the Command cmd and return true if so.

public

isCNOT(cmd: *): *

public

isSwap(cmd: *): *

public

needsFlipping(cmd: *): *

public

receive(commandList: Command[])

Receives a command list and if the command is a CNOT gate, it flips it using Hadamard gates if necessary; if it is a Swap gate, it decomposes it using 3 CNOTs.

public

sendCNOT(cmd: *, control: *, target: *, flip: boolean)

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(connectivity: Set<string>|Set<Array.<number>>) source

Override:

BasicEngine#constructor

Params:

NameTypeAttributeDescription
connectivity Set<string>|Set<Array.<number>>

Set of tuples (c, t) where if (c, t) is an element of the set means that a CNOT can be performed between the physical ids (c, t) with c being the control and t being the target qubit.

Public Members

public connectivity: * source

Public Methods

public isAvailable(cmd: Command): * source

Check if the IBM backend can perform the Command cmd and return true if so.

Override:

BasicEngine#isAvailable

Params:

NameTypeAttributeDescription
cmd Command

The command to check

Return:

*

public isCNOT(cmd: *): * source

Params:

NameTypeAttributeDescription
cmd *

Return:

*

public isSwap(cmd: *): * source

Params:

NameTypeAttributeDescription
cmd *

Return:

*

public needsFlipping(cmd: *): * source

Params:

NameTypeAttributeDescription
cmd *

Return:

*

public receive(commandList: Command[]) source

Receives a command list and if the command is a CNOT gate, it flips it using Hadamard gates if necessary; if it is a Swap gate, it decomposes it using 3 CNOTs. All other gates are simply sent to the next engine.

Override:

BasicEngine#receive

Params:

NameTypeAttributeDescription
commandList Command[]

list of commands to receive.

public sendCNOT(cmd: *, control: *, target: *, flip: boolean) source

Params:

NameTypeAttributeDescription
cmd *
control *
target *
flip boolean
  • optional
  • default: false