pub struct PauliMap { /* private fields */ }Expand description
A sparse, phaseless map from qubit coordinate to non-identity Pauli.
Compose maps with ^; exact product phases are discarded.
Implementations§
Source§impl PauliMap
impl PauliMap
Sourcepub fn product_phase(&self, other: &PauliMap) -> u8
pub fn product_phase(&self, other: &PauliMap) -> u8
Exact power of i contributed by a product; the maps themselves remain phaseless.
Sourcepub fn translated(&self, offset: IVec2) -> PauliMap
pub fn translated(&self, offset: IVec2) -> PauliMap
Returns a copy with every coordinate shifted by offset.
§Panics
Panics if any translated coordinate exceeds the signed 32-bit lattice.
Use Self::try_translated for untrusted offsets.
Sourcepub fn try_translated(
&self,
offset: IVec2,
) -> Result<PauliMap, CoordinateOverflowError>
pub fn try_translated( &self, offset: IVec2, ) -> Result<PauliMap, CoordinateOverflowError>
Returns a copy with every coordinate shifted by offset.
§Errors
Returns CoordinateOverflowError if any translated coordinate exceeds
the signed 32-bit lattice.
Sourcepub fn from_unique_entries(
entries: impl IntoIterator<Item = (IVec2, Pauli)>,
) -> PauliMap
pub fn from_unique_entries( entries: impl IntoIterator<Item = (IVec2, Pauli)>, ) -> PauliMap
Build a map from entries with pairwise-distinct coordinates and non-identity Paulis.
Skips the per-entry binary search and shifting that FromIterator
performs, sorting the collected entries once instead. The caller must
guarantee the entries need no deduplication or identity filtering.
§Panics
Panics if coordinates repeat or an entry is identity.
Sourcepub fn iter(&self) -> PauliMapIter<'_> ⓘ
pub fn iter(&self) -> PauliMapIter<'_> ⓘ
Iterates over the (coordinate, pauli) entries in sorted (x, y) order.
Sourcepub fn representative_coord(&self) -> Option<IVec2>
pub fn representative_coord(&self) -> Option<IVec2>
The product’s representative coordinate: its minimum data qubit by
(x, y), used as the crate::Op::MPP measurement-record key. Entries
are kept sorted, so this is the first one. Recovering it from the product
alone lets the construct/clone/translate/merge stages agree without a
shared registry. None for an empty product.
Sourcepub fn get(&self, coord: &IVec2) -> Option<&Pauli>
pub fn get(&self, coord: &IVec2) -> Option<&Pauli>
The Pauli at coord, or None if the coordinate carries identity.
Sourcepub fn insert(&mut self, coord: IVec2, pauli: Pauli) -> Option<Pauli>
pub fn insert(&mut self, coord: IVec2, pauli: Pauli) -> Option<Pauli>
Sets coord to pauli, returning the Pauli previously there.
Inserting Pauli::I removes the entry, so the no-identity invariant
holds.
Sourcepub fn to_pauli_string(
&self,
layout: &HashMap<IVec2, u32, FxBuildHasher>,
num_qubits: usize,
) -> Result<String, CircuitError>
pub fn to_pauli_string( &self, layout: &HashMap<IVec2, u32, FxBuildHasher>, num_qubits: usize, ) -> Result<String, CircuitError>
Renders the map as a dense Pauli string of length num_qubits, placing
each entry at its layout index and filling gaps with _.
§Errors
Returns CircuitError::QubitNotFoundInLayout if an entry’s coordinate
is absent from layout, or CircuitError::QubitIndexOutOfRange if its
index is at least num_qubits.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PauliMap
impl<'de> Deserialize<'de> for PauliMap
Source§fn deserialize<D>(
deserializer: D,
) -> Result<PauliMap, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<PauliMap, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for PauliMap
Source§impl FromIterator<(IVec2, Pauli)> for PauliMap
impl FromIterator<(IVec2, Pauli)> for PauliMap
Source§impl IntoIterator for PauliMap
impl IntoIterator for PauliMap
Source§impl<'a> IntoIterator for &'a PauliMap
impl<'a> IntoIterator for &'a PauliMap
Source§impl Serialize for PauliMap
impl Serialize for PauliMap
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for PauliMap
Auto Trait Implementations§
impl Freeze for PauliMap
impl RefUnwindSafe for PauliMap
impl Send for PauliMap
impl Sync for PauliMap
impl Unpin for PauliMap
impl UnsafeUnpin for PauliMap
impl UnwindSafe for PauliMap
Blanket Implementations§
§impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
fn assign_index(&mut self, index: usize, to: bool)
fn negate_index(&mut self, index: usize)
fn clear_bits(&mut self)
fn assign_random(
&mut self,
bit_count: usize,
random_number_generator: &mut impl RngExt,
)where
BorrowedSelf: BitLength,
§impl<Bits, Other, BorrowedSelf, BorrowedOther> BitwisePairMutViaBorrow<Other, BorrowedSelf, BorrowedOther> for Bits
impl<Bits, Other, BorrowedSelf, BorrowedOther> BitwisePairMutViaBorrow<Other, BorrowedSelf, BorrowedOther> for Bits
fn assign(&mut self, other: &Other)
fn bitxor_assign(&mut self, other: &Other)
fn bitand_assign(&mut self, other: &Other)
fn bitor_assign(&mut self, other: &Other)
§impl<T, Other, BorrowedSelf, BorrowedOther> BitwisePairViaBorrow<Other, BorrowedSelf, BorrowedOther> for T
impl<T, Other, BorrowedSelf, BorrowedOther> BitwisePairViaBorrow<Other, BorrowedSelf, BorrowedOther> for T
§impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
fn index(&self, index: usize) -> bool
fn weight(&self) -> usize
fn parity(&self) -> bool
fn is_zero(&self) -> bool
fn is_unit(&self, index: usize) -> bool
fn support<'a>(&'a self) -> impl SortedIteratorwhere
BorrowedSelf: 'a,
fn max_support(&self) -> Option<usize>
fn min_support(&self) -> Option<usize>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.