Struct spinoza::circuit::QuantumCircuit
source · 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
impl QuantumCircuit
sourcepub fn new(registers: &mut [&mut QuantumRegister]) -> Self
pub fn new(registers: &mut [&mut QuantumRegister]) -> Self
Create a new QuantumCircuit from multiple QuantumRegisters
sourcepub fn get_statevector(&self) -> &State
pub fn get_statevector(&self) -> &State
Get a reference to the Quantum State
sourcepub fn x(&mut self, target: usize)
pub fn x(&mut self, target: usize)
Add the X gate for a given target to the list of QuantumTransformations
sourcepub fn y(&mut self, target: usize)
pub fn y(&mut self, target: usize)
Add the Y gate for a given target to the list of QuantumTransformations
sourcepub fn rx(&mut self, angle: Float, target: usize)
pub fn rx(&mut self, angle: Float, target: usize)
Add the Rx gate for a given target to the list of QuantumTransformations
sourcepub fn cx(&mut self, control: usize, target: usize)
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
sourcepub fn ccx(&mut self, control1: usize, control2: usize, target: usize)
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
sourcepub fn h(&mut self, target: usize)
pub fn h(&mut self, target: usize)
Add the Hadamard (H) gate for a given target qubit to the list of QuantumTransformations
sourcepub fn ch(&mut self, control: usize, target: usize)
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
sourcepub fn ry(&mut self, angle: Float, target: usize)
pub fn ry(&mut self, angle: Float, target: usize)
Add Ry gate for a given target qubit to the list of QuantumTransformations
sourcepub fn cry(&mut self, angle: Float, control: usize, target: usize)
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
sourcepub fn p(&mut self, angle: Float, target: usize)
pub fn p(&mut self, angle: Float, target: usize)
Add Phase (P) gate for a given target qubit to the list of QuantumTransformations
sourcepub fn cp(&mut self, angle: Float, control: usize, target: usize)
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
sourcepub fn cu(
&mut self,
theta: Float,
phi: Float,
lambda: Float,
control: usize,
target: usize
)
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
sourcepub fn cy(&mut self, control: usize, target: usize)
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
sourcepub fn crx(&mut self, angle: Float, control: usize, target: usize)
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
sourcepub fn z(&mut self, target: usize)
pub fn z(&mut self, target: usize)
Add Z gate for a given target qubit to the list of QuantumTransformations
sourcepub fn rz(&mut self, angle: Float, target: usize)
pub fn rz(&mut self, angle: Float, target: usize)
Add Rz gate for a given target qubit to the list of QuantumTransformations
sourcepub fn crz(&mut self, angle: Float, control: usize, target: usize)
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
sourcepub fn u(&mut self, theta: Float, phi: Float, lambda: Float, target: usize)
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
sourcepub fn bit_flip_noise(&mut self, prob: Float, target: usize)
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
sourcepub fn iqft(&mut self, targets: &[usize])
pub fn iqft(&mut self, targets: &[usize])
Add all transformations for an inverse Quantum Fourier Transform to the list of QuantumTransformations
sourcepub fn append(&mut self, circuit: &QuantumCircuit, reg: &QuantumRegister)
pub fn append(&mut self, circuit: &QuantumCircuit, reg: &QuantumRegister)
Append a QuantumCircuit to the given register of this QuantumCircuit
sourcepub fn c_append(
&mut self,
circuit: &QuantumCircuit,
c: usize,
reg: &QuantumRegister
)
pub fn c_append( &mut self, circuit: &QuantumCircuit, c: usize, reg: &QuantumRegister )
Append a QuantumCircuit to the given register of this QuantumCircuit
sourcepub fn mc_append(
&mut self,
circuit: &QuantumCircuit,
controls: &[usize],
reg: &QuantumRegister
)
pub fn mc_append( &mut self, circuit: &QuantumCircuit, controls: &[usize], reg: &QuantumRegister )
Append a QuantumCircuit to the given register of this QuantumCircuit
sourcepub fn unitary(&mut self, u: Unitary, target: usize)
pub fn unitary(&mut self, u: Unitary, target: usize)
Add a Unitary for a given target qubit to the list of QuantumTransformations
sourcepub fn append_u(&mut self, u: Unitary, qr: &QuantumRegister)
pub fn append_u(&mut self, u: Unitary, qr: &QuantumRegister)
Append a Unitary
to a QuantumRegister
sourcepub fn c_unitary(&mut self, u: Unitary, c: usize, t: usize)
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
sourcepub fn c_append_u(&mut self, u: Unitary, c: usize, qr: &QuantumRegister)
pub fn c_append_u(&mut self, u: Unitary, c: usize, qr: &QuantumRegister)
Append a controlled Unitary
to a QuantumRegister
sourcepub fn add(&mut self, transformation: QuantumTransformation)
pub fn add(&mut self, transformation: QuantumTransformation)
Add a given QuantumTransformation
to the list of transformations