Struct EnginePauliString
pub struct EnginePauliString {
pub nqubits: usize,
pub x: Vec<u64>,
pub z: Vec<u64>,
/* private fields */
}Expand description
A Pauli operator on nqubits qubits, with a two-bit phase exponent of i.
Equality is structural — it compares the stored phase byte and both bitsets, not the operator up to phase.
§Examples
use ticit::{neg, pauli_string};
let xyz = pauli_string("XYZ")?;
assert_eq!(xyz.to_string(), "XYZ");
assert_eq!(neg(xyz).to_string(), "-XYZ");Fields§
§nqubits: usizeNumber of qubits in the operator.
x: Vec<u64>Packed LSB-first X bits; qubit q is bit q & 63 of word q >> 6.
z: Vec<u64>Packed LSB-first Z bits, with the same layout as x.
Implementations§
§impl PauliString
impl PauliString
pub fn new(nqubits: usize) -> PauliString
pub fn new(nqubits: usize) -> PauliString
Identity on nqubits qubits.
pub fn phase_exponent(&self) -> i32
pub fn phase_exponent(&self) -> i32
Exponent of i in the stored phase, in 0..=3.
pub fn set_phase(&mut self, phase_exponent: i32)
pub fn set_phase(&mut self, phase_exponent: i32)
Sets the phase exponent modulo 4; negative inputs wrap the same way the
C++ & 3 on a signed int does.
pub fn phase_shift(&mut self, delta: i32)
pub fn phase_shift(&mut self, delta: i32)
Adds delta to the stored phase exponent modulo four.
pub fn has_nonidentity_body(&self) -> bool
pub fn has_nonidentity_body(&self) -> bool
Returns whether any qubit carries X, Y, or Z instead of identity.
pub fn same_body(&self, other: &PauliString) -> bool
pub fn same_body(&self, other: &PauliString) -> bool
Body equality, ignoring phase. Rotation fusion uses this as the identity test for “same Pauli, possibly different sign”.
pub fn single(nqubits: usize, q: usize, pauli: Pauli) -> PauliString
pub fn single(nqubits: usize, q: usize, pauli: Pauli) -> PauliString
pub fn from_terms(
nqubits: usize,
terms: impl IntoIterator<Item = (usize, Pauli)>,
) -> PauliString
pub fn from_terms( nqubits: usize, terms: impl IntoIterator<Item = (usize, Pauli)>, ) -> PauliString
Collects (qubit, pauli) terms into a string on nqubits qubits.
Terms are assignments, not factors: a repeated index keeps the last Pauli given for it rather than multiplying the two.
§Panics
Panics if any index is >= nqubits.
pub fn set(&mut self, q: usize, pauli: Pauli)
pub fn set(&mut self, q: usize, pauli: Pauli)
Replaces the Pauli acting on q.
The stored phase absorbs the body’s implicit i per Y, so a string
built only from set is Hermitian — the phase convention documented at
the top of this module.
§Panics
Panics if q >= nqubits.
pub fn max_support(&self) -> Option<usize>
pub fn max_support(&self) -> Option<usize>
The largest qubit carrying a non-identity Pauli, or None for identity.
This — not nqubits — bounds the register the string actually acts on,
so it is what a caller sizing a register against an observable wants.
pub fn commutes_with(&self, other: &PauliString) -> bool
pub fn commutes_with(&self, other: &PauliString) -> bool
Whether self and other commute as operators.
Trait Implementations§
§impl Clone for PauliString
impl Clone for PauliString
§fn clone(&self) -> PauliString
fn clone(&self) -> PauliString
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for PauliString
impl Debug for PauliString
§impl Default for PauliString
impl Default for PauliString
§fn default() -> PauliString
fn default() -> PauliString
§impl Display for PauliString
impl Display for PauliString
impl Eq for PauliString
§impl Mul for PauliString
impl Mul for PauliString
§type Output = PauliString
type Output = PauliString
* operator.§fn mul(self, rhs: PauliString) -> PauliString
fn mul(self, rhs: PauliString) -> PauliString
* operation. Read more§impl Mul<&PauliString> for &PauliString
impl Mul<&PauliString> for &PauliString
§fn mul(self, rhs: &PauliString) -> PauliString
fn mul(self, rhs: &PauliString) -> PauliString
Panics if the operands act on different numbers of qubits: every caller multiplies rows of one tableau, so a mismatch is a wiring bug.
§type Output = PauliString
type Output = PauliString
* operator.§impl PartialEq for PauliString
impl PartialEq for PauliString
impl StructuralPartialEq for PauliString
Auto Trait Implementations§
impl Freeze for PauliString
impl RefUnwindSafe for PauliString
impl Send for PauliString
impl Sync for PauliString
impl Unpin for PauliString
impl UnsafeUnpin for PauliString
impl UnwindSafe for PauliString
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<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.