pub struct RoutedCircuit<const N: usize> {
pub gates: Vec<Box<dyn GateOp>>,
pub logical_to_physical: HashMap<usize, usize>,
pub result: RoutingResult,
}Expand description
A routed circuit with mapping information
Fields§
§gates: Vec<Box<dyn GateOp>>The routed gates in execution order
logical_to_physical: HashMap<usize, usize>Final mapping from logical to physical qubits
result: RoutingResultRouting statistics
Implementations§
Source§impl<const N: usize> RoutedCircuit<N>
impl<const N: usize> RoutedCircuit<N>
Sourcepub fn new(
gates: Vec<Box<dyn GateOp>>,
logical_to_physical: HashMap<usize, usize>,
result: RoutingResult,
) -> Self
pub fn new( gates: Vec<Box<dyn GateOp>>, logical_to_physical: HashMap<usize, usize>, result: RoutingResult, ) -> Self
Create a new routed circuit
Sourcepub fn total_cost(&self) -> f64
pub fn total_cost(&self) -> f64
Get total cost of the routed circuit
Sourcepub fn routing_overhead(&self) -> f64
pub fn routing_overhead(&self) -> f64
Get the routing overhead (SWAPs / total gates)
Sourcepub fn gates_by_type(&self) -> HashMap<String, usize>
pub fn gates_by_type(&self) -> HashMap<String, usize>
Get gates by type
Sourcepub fn to_circuit(&self) -> QuantRS2Result<Circuit<N>>
pub fn to_circuit(&self) -> QuantRS2Result<Circuit<N>>
Convert back to a Circuit<N> by replaying the routed gate sequence.
Each stored Box<dyn GateOp> is added via Circuit::add_gate_box, which
down-casts to the concrete gate type internally. Gates whose concrete type
is not recognised by add_gate_box will produce an error.
Sourcepub const fn get_mapping(&self) -> &HashMap<usize, usize>
pub const fn get_mapping(&self) -> &HashMap<usize, usize>
Get the final qubit mapping
Sourcepub fn get_inverse_mapping(&self) -> HashMap<usize, usize>
pub fn get_inverse_mapping(&self) -> HashMap<usize, usize>
Get the inverse mapping (physical to logical)
Sourcepub fn statistics(&self) -> RoutingStatistics
pub fn statistics(&self) -> RoutingStatistics
Calculate circuit statistics
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize> !RefUnwindSafe for RoutedCircuit<N>
impl<const N: usize> !UnwindSafe for RoutedCircuit<N>
impl<const N: usize> Freeze for RoutedCircuit<N>
impl<const N: usize> Send for RoutedCircuit<N>
impl<const N: usize> Sync for RoutedCircuit<N>
impl<const N: usize> Unpin for RoutedCircuit<N>
impl<const N: usize> UnsafeUnpin for RoutedCircuit<N>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.