Home Reference Source
import StatePreparation from 'projectq/src/ops/statepreparation.js'
public class | source

StatePreparation

Extends:

BasicGate → StatePreparation

Gate for transforming qubits in state |0> to any desired quantum state.

Constructor Summary

Public Constructor
public

constructor(finalState: *)

Initialize StatePreparation gate.

Member Summary

Private Members
private

Method Summary

Public Methods
public

equal(other: *): boolean

public

Inherited Summary

From class BasicGate
public static

makeTupleOfQureg(qubits: Qubit | Qubit[] | Qureg | Qureg[]): Qureg[]

Convert quantum input of "gate | quantum input" to internal formatting.

public
public
public

equal(other: BasicGate | Object): boolean

public

generateCommand(qubits: *): Command

Helper function to generate a command consisting of the gate and the qubits being acted upon.

public
public
public
public

or(qubits: *)

Operator| overload which enables the syntax Gate | qubits.

public

Public Constructors

public constructor(finalState: *) source

Initialize StatePreparation gate.

Example:

qureg = eng.allocateQureg(2)
new StatePreparation([0.5, -0.5j, -0.5, 0.5]).or(qureg)

Note: The amplitude of state k is final_state[k]. When the state k is written in binary notation, then qureg[0] denotes the qubit whose state corresponds to the least significant bit of k.

Args: final_state(list[complex]): wavefunction of the desired quantum state. len(final_state) must be 2**len(qureg). Must be normalized!

Override:

BasicGate#constructor

Params:

NameTypeAttributeDescription
finalState *

Private Members

private _finalState: * source

Public Methods

public equal(other: *): boolean source

Override:

BasicGate#equal

Params:

NameTypeAttributeDescription
other *

Return:

boolean

public toString(): string source

Override:

BasicGate#toString

Return:

string