pub struct Subroutine {
pub gates: Vec<Gate>,
pub num_qubits: usize,
}Expand description
A subroutine for a quantum circuit.
§Fields
-
gates- A vector of gates in the subroutine. -
num_qubits- The number of qubits in the subroutine.
Fields§
§gates: Vec<Gate>The gates in the subroutine.
num_qubits: usizeThe number of qubits in the subroutine.
Implementations§
Source§impl Subroutine
impl Subroutine
Sourcepub fn new(num_qubits: usize) -> Self
pub fn new(num_qubits: usize) -> Self
Creates a new subroutine with the specified number of qubits.
§Arguments
num_qubits- The number of qubits in the subroutine.
Sourcepub fn with_gates(gates: Vec<Gate>, num_qubits: usize) -> Subroutine
pub fn with_gates(gates: Vec<Gate>, num_qubits: usize) -> Subroutine
Creates a new subroutine with the specified gates and number of qubits.
§Arguments
gates- A vector of gates in the subroutine.num_qubits- The number of qubits in the subroutine.
Sourcepub fn get_gates(&self) -> &Vec<Gate>
pub fn get_gates(&self) -> &Vec<Gate>
Gets the gates in the subroutine.
§Returns
&Vec<Gate>- A reference to the vector of gates in the subroutine.
Sourcepub fn add_gates(&mut self, gates: Vec<Gate>)
pub fn add_gates(&mut self, gates: Vec<Gate>)
Adds multiple gates to the subroutine.
§Arguments
gates- A vector of gates to be added to the subroutine.
Sourcepub fn get_num_qubits(&self) -> usize
pub fn get_num_qubits(&self) -> usize
Gets the number of qubits in the subroutine.
§Returns
usize- The number of qubits in the subroutine.
Sourcepub fn qft(qubits: Vec<usize>, num_qubits: usize) -> Subroutine
pub fn qft(qubits: Vec<usize>, num_qubits: usize) -> Subroutine
Creates a quantum fourier transform subroutine for the specified qubits.
§Arguments
-
qubits- A vector of indices of the qubits to be transformed. -
num_qubits- The number of qubits in the subroutine.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Subroutine
impl !RefUnwindSafe for Subroutine
impl Send for Subroutine
impl Sync for Subroutine
impl Unpin for Subroutine
impl !UnwindSafe for Subroutine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more