pub struct Circuit {
pub gates: Vec<Gate>,
pub num_qubits: usize,
}Expand description
Represents a quantum circuit as a vector of gates.
§Fields
gates- A vector of gates in the circuit.num_qubits- The number of qubits in the circuit.
Fields§
§gates: Vec<Gate>A vector of gates in the circuit.
num_qubits: usizeThe number of qubits in the circuit.
Implementations§
Source§impl Circuit
impl Circuit
Sourcepub fn get_num_qubits(&self) -> usize
pub fn get_num_qubits(&self) -> usize
Sourcepub fn get_gates(&self) -> &Vec<Gate>
pub fn get_gates(&self) -> &Vec<Gate>
Gets the gates in the circuit.
§Returns
&Vec<Gate>- A reference to the vector of gates in the circuit.
Sourcepub fn execute(&self, initial_state: &State) -> Result<State, Error>
pub fn execute(&self, initial_state: &State) -> Result<State, Error>
Executes the circuit with the given initial state, and returns the final state.
§Arguments
initial_state- The initial state of the qubits in the circuit.
§Returns
Result<State, Error>- The final state of the qubits after executing the circuit.
§Errors
- Returns an error if the number of qubits in the initial state does not match the number of qubits in the circuit.
- Returns an error if the circuit cannot be executed due to invalid gate operations.
Sourcepub fn trace_execution(
&self,
initial_state: &State,
) -> Result<Vec<State>, Error>
pub fn trace_execution( &self, initial_state: &State, ) -> Result<Vec<State>, Error>
Executes the circuit with the given initial state, and returns all the intermediate states and the final state.
§Arguments
initial_state- The initial state of the qubits in the circuit.
§Returns
Result<Vec<State>, Error>- A vector of intermediate states and the final state after executing the circuit.
§Errors
- Returns an error if the number of qubits in the initial state does not match the number of qubits in the circuit.
- Returns an error if the circuit cannot be executed due to invalid gate operations.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Circuit
impl !RefUnwindSafe for Circuit
impl Send for Circuit
impl Sync for Circuit
impl Unpin for Circuit
impl !UnwindSafe for Circuit
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