Skip to main content

PauliMap

Struct PauliMap 

Source
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

Source

pub fn product_phase(&self, other: &Self) -> u8

Exact power of i contributed by a product; the maps themselves remain phaseless.

Source

pub fn translated(&self, offset: IVec2) -> Self

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.

Source

pub fn try_translated( &self, offset: IVec2, ) -> Result<Self, CoordinateOverflowError>

Returns a copy with every coordinate shifted by offset.

§Errors

Returns CoordinateOverflowError if any translated coordinate exceeds the signed 32-bit lattice.

Source

pub fn from_unique_entries( entries: impl IntoIterator<Item = (IVec2, Pauli)>, ) -> Self

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.

Source

pub fn empty() -> Self

Creates an empty Pauli map.

Source

pub fn len(&self) -> usize

Returns the number of non-identity entries.

Source

pub fn is_empty(&self) -> bool

Returns whether the map contains no non-identity entries.

Source

pub fn iter(&self) -> PauliMapIter<'_> ⓘ

Iterates over the (coordinate, pauli) entries in sorted (x, y) order.

Source

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.

Source

pub fn get(&self, coord: &IVec2) -> Option<&Pauli>

The Pauli at coord, or None if the coordinate carries identity.

Source

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.

Source

pub fn to_pauli_string( &self, layout: &FxHashMap<IVec2, u32>, 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 BitXor for &PauliMap

Source§

type Output = PauliMap

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl Clone for PauliMap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PauliMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PauliMap

Source§

fn default() -> PauliMap

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PauliMap

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for PauliMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for PauliMap

Source§

impl FromIterator<(IVec2, Pauli)> for PauliMap

Source§

fn from_iter<T: IntoIterator<Item = (IVec2, Pauli)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for PauliMap

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoIterator for PauliMap

Source§

type Item = (IVec2, Pauli)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<[(IVec2, Pauli); 4]>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a PauliMap

Source§

type Item = (&'a IVec2, &'a Pauli)

The type of the elements being iterated over.
Source§

type IntoIter = PauliMapIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for PauliMap

Source§

fn eq(&self, other: &PauliMap) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PauliMap

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PauliMap

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T, BorrowedSelf> BitwiseMutViaBorrow<BorrowedSelf> for T
where T: BorrowMut<BorrowedSelf>, BorrowedSelf: BitwiseMut + ?Sized,

§

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
where Bits: BorrowMut<BorrowedSelf> + ?Sized, Other: Borrow<BorrowedOther> + ?Sized, BorrowedSelf: Bitwise + BitwisePairMut<BorrowedOther> + ?Sized, BorrowedOther: Bitwise + ?Sized,

§

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
where T: Borrow<BorrowedSelf> + ?Sized, Other: Borrow<BorrowedOther> + ?Sized, BorrowedSelf: Bitwise + BitwisePair<BorrowedOther> + ?Sized, BorrowedOther: Bitwise + ?Sized,

§

fn dot(&self, other: &Other) -> bool

§

fn and_weight(&self, other: &Other) -> usize

§

fn or_weight(&self, other: &Other) -> usize

§

fn xor_weight(&self, other: &Other) -> usize

§

impl<T, BorrowedSelf> BitwiseViaBorrow<BorrowedSelf> for T
where T: Borrow<BorrowedSelf>, BorrowedSelf: Bitwise + ?Sized,

§

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 SortedIterator
where BorrowedSelf: 'a,

§

fn max_support(&self) -> Option<usize>

§

fn min_support(&self) -> Option<usize>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.