pub struct QuantumCircuit {
    pub transformations: Vec<QuantumTransformation>,
    pub state: State,
    pub quantum_registers_info: Vec<usize>,
    /* private fields */
}
Expand description

A model of a Quantum circuit See https://en.wikipedia.org/wiki/Quantum_circuit

Fields§

§transformations: Vec<QuantumTransformation>

The list of operations to be applied to the State

§state: State

The Quantum State to which transformations are applied

§quantum_registers_info: Vec<usize>

The sizes of the provided quantum registers

Implementations§

source§

impl QuantumCircuit

source

pub fn new(registers: &mut [&mut QuantumRegister]) -> Self

Create a new QuantumCircuit from multiple QuantumRegisters

source

pub fn get_statevector(&self) -> &State

Get a reference to the Quantum State

source

pub fn inverse(&mut self)

Invert this circuit

source

pub fn measure(&mut self, target: usize)

Measure a single qubit

source

pub fn swap(&mut self, t0: usize, t1: usize)

Add a SWAP gate that swaps two qubits

source

pub fn x(&mut self, target: usize)

Add the X gate for a given target to the list of QuantumTransformations

source

pub fn y(&mut self, target: usize)

Add the Y gate for a given target to the list of QuantumTransformations

source

pub fn rx(&mut self, angle: Float, target: usize)

Add the Rx gate for a given target to the list of QuantumTransformations

source

pub fn cx(&mut self, control: usize, target: usize)

Add the CX gate for a given target qubit and control qubit to the list of QuantumTransformations

source

pub fn ccx(&mut self, control1: usize, control2: usize, target: usize)

Add the CCX gate for a given target qubit and two control qubits to the list of QuantumTransformations

source

pub fn h(&mut self, target: usize)

Add the Hadamard (H) gate for a given target qubit to the list of QuantumTransformations

source

pub fn ch(&mut self, control: usize, target: usize)

Add a controlled Hadamard gate for a given target qubit and a given control qubit to the list of QuantumTransformations

source

pub fn ry(&mut self, angle: Float, target: usize)

Add Ry gate for a given target qubit to the list of QuantumTransformations

source

pub fn cry(&mut self, angle: Float, control: usize, target: usize)

Add CRy gate for a given target qubit and a given control qubit to the list of QuantumTransformations

source

pub fn p(&mut self, angle: Float, target: usize)

Add Phase (P) gate for a given target qubit to the list of QuantumTransformations

source

pub fn cp(&mut self, angle: Float, control: usize, target: usize)

Add the Controlled Phase (CP) gate for a given target qubit and a given control qubit to the list of QuantumTransformations

source

pub fn cu( &mut self, theta: Float, phi: Float, lambda: Float, control: usize, target: usize )

Add the Controlled U gate for a given target qubit and a given control qubit to the list of QuantumTransformations

source

pub fn cy(&mut self, control: usize, target: usize)

Add the Controlled Y gate for a given target qubit and a given control qubit to the list of QuantumTransformations

source

pub fn crx(&mut self, angle: Float, control: usize, target: usize)

Add the Controlled Rx gate for a given target qubit and a given control qubit to the list of QuantumTransformations

source

pub fn z(&mut self, target: usize)

Add Z gate for a given target qubit to the list of QuantumTransformations

source

pub fn rz(&mut self, angle: Float, target: usize)

Add Rz gate for a given target qubit to the list of QuantumTransformations

source

pub fn crz(&mut self, angle: Float, control: usize, target: usize)

Add the Controlled Rz gate for a given target qubit and a given control qubit to the list of QuantumTransformations

source

pub fn u(&mut self, theta: Float, phi: Float, lambda: Float, target: usize)

Add the U gate for a given target to the list of QuantumTransformations

source

pub fn bit_flip_noise(&mut self, prob: Float, target: usize)

Add the bit flip noise gate for a given target qubit, given a probability

source

pub fn iqft(&mut self, targets: &[usize])

Add all transformations for an inverse Quantum Fourier Transform to the list of QuantumTransformations

source

pub fn append(&mut self, circuit: &QuantumCircuit, reg: &QuantumRegister)

Append a QuantumCircuit to the given register of this QuantumCircuit

source

pub fn c_append( &mut self, circuit: &QuantumCircuit, c: usize, reg: &QuantumRegister )

Append a QuantumCircuit to the given register of this QuantumCircuit

source

pub fn mc_append( &mut self, circuit: &QuantumCircuit, controls: &[usize], reg: &QuantumRegister )

Append a QuantumCircuit to the given register of this QuantumCircuit

source

pub fn unitary(&mut self, u: Unitary, target: usize)

Add a Unitary for a given target qubit to the list of QuantumTransformations

source

pub fn append_u(&mut self, u: Unitary, qr: &QuantumRegister)

Append a Unitary to a QuantumRegister

source

pub fn c_unitary(&mut self, u: Unitary, c: usize, t: usize)

Add a controlled Unitary for a given target qubit to the list of QuantumTransformations

source

pub fn c_append_u(&mut self, u: Unitary, c: usize, qr: &QuantumRegister)

Append a controlled Unitary to a QuantumRegister

source

pub fn add(&mut self, transformation: QuantumTransformation)

Add a given QuantumTransformation to the list of transformations

source

pub fn execute(&mut self)

Run the list of transformations against the State

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V