pub struct PauliGraph { /* private fields */ }Expand description
A tk-pg-core program consisting of a qubit count and an ordered list of operations.
The following structural validity checks are performed at Op insertion time:
- All
Op::Gateoperations have valid parameter counts for their gate type. - All
Op::Gateoperations have valid arguments for their gate type, within the valid range. - All Pauli graph native operations have Pauli strings with length matching the graph’s qubit count.
- Conditional bits/values lengths match.
Op::BlackBoxoperations have all argument qubits within the valid range.GateType::BlackBoxgates have no conditions, and they must have data.
Implementations§
Source§impl PauliGraph
impl PauliGraph
Sourcepub fn new(n_qubits: usize) -> PauliGraph
pub fn new(n_qubits: usize) -> PauliGraph
Sourcepub fn with_ops(self, ops: Vec<Op>) -> PauliGraph
pub fn with_ops(self, ops: Vec<Op>) -> PauliGraph
Returns the graph with its operation list replaced by ops.
§Arguments
mut self(Self) - The current graph instance.ops(Vec<Op>) - The new list ofOps to replace the current list.
§Returns
Self- The updated graph instance with the newOplist.
§Panics
Panics if any operation in ops fails the structural validity checks.
Sourcepub fn extend(&mut self, other: PauliGraph)
pub fn extend(&mut self, other: PauliGraph)
Sourcepub fn add_conditional_op(
&mut self,
op: Op,
conditional_bits: Vec<usize>,
conditional_values: Vec<bool>,
)
pub fn add_conditional_op( &mut self, op: Op, conditional_bits: Vec<usize>, conditional_values: Vec<bool>, )
Appends conditional op.
If the last operation is a
Op::ConditionalBox with matching conditions, op is appended into it instead of
creating a new box. If conditional_bits is empty, op is added unconditionally
via Self::add_op.
§Panics
Panics if op fails the structural validity checks, or if conditional_bits and
conditional_values have different lengths.
Sourcepub fn insert_conditional_op(
&mut self,
index: usize,
op: Op,
conditional_bits: Vec<usize>,
conditional_values: Vec<bool>,
)
pub fn insert_conditional_op( &mut self, index: usize, op: Op, conditional_bits: Vec<usize>, conditional_values: Vec<bool>, )
Inserts conditional op at position index.
If the adjacent operation at index - 1 or index is a Op::ConditionalBox with matching conditions, op is merged into
it instead of creating a new box. If conditional_bits is empty, op is inserted
unconditionally via Self::insert_op.
§Panics
Panics if op fails the structural validity checks, or if conditional_bits and
conditional_values have different lengths.
Sourcepub fn swap_ops(&mut self, index1: usize, index2: usize)
pub fn swap_ops(&mut self, index1: usize, index2: usize)
Swaps the operations at positions index1 and index2.
§Panics
Panics if index1 or index2 is out of bounds.
Sourcepub fn replace_slice(&mut self, range: Range<usize>, new_ops: Vec<Op>)
pub fn replace_slice(&mut self, range: Range<usize>, new_ops: Vec<Op>)
Replaces the operations in the index range range with new_ops.
§Panics
Panics if any operation in new_ops fails the structural validity checks or if range is out of bounds.
Sourcepub fn add_qubit(&mut self)
pub fn add_qubit(&mut self)
Increases the qubit count by one, extending all Pauli strings with an identity on the new qubit.
Sourcepub fn get_n_qubits(&self) -> usize
pub fn get_n_qubits(&self) -> usize
Returns the number of qubits.
Sourcepub fn try_validate(&self) -> Result<(), PauliGraphError>
pub fn try_validate(&self) -> Result<(), PauliGraphError>
Validates all operations against the structural validity checks.
§Panics
Panics if any operation fails the structural validity checks.
Trait Implementations§
Source§impl Clone for PauliGraph
impl Clone for PauliGraph
Source§fn clone(&self) -> PauliGraph
fn clone(&self) -> PauliGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PauliGraph
impl Debug for PauliGraph
Source§impl<'de> Deserialize<'de> for PauliGraph
impl<'de> Deserialize<'de> for PauliGraph
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PauliGraph, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PauliGraph, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PGRewrite for PauliGraph
impl PGRewrite for PauliGraph
Source§fn can_be_conjugated(&self, i: usize) -> bool
fn can_be_conjugated(&self, i: usize) -> bool
determine if the op can be conjugated
Source§fn is_left_boundary(&self, i: usize) -> bool
fn is_left_boundary(&self, i: usize) -> bool
Source§fn is_right_boundary(&self, i: usize) -> bool
fn is_right_boundary(&self, i: usize) -> bool
Source§fn is_clifford(&self, i: usize) -> bool
fn is_clifford(&self, i: usize) -> bool
Source§fn is_identity<T>(&self, i: usize) -> boolwhere
T: PGTableau,
fn is_identity<T>(&self, i: usize) -> boolwhere
T: PGTableau,
Source§fn op_to_tableau<T>(&mut self, i: usize)where
T: PGTableau,
fn op_to_tableau<T>(&mut self, i: usize)where
T: PGTableau,
Source§fn conj_left_op<T>(&mut self, i: usize)where
T: PGTableau,
fn conj_left_op<T>(&mut self, i: usize)where
T: PGTableau,
Source§fn conj_right_op<T>(&mut self, i: usize)where
T: PGTableau,
fn conj_right_op<T>(&mut self, i: usize)where
T: PGTableau,
Source§impl PartialEq for PauliGraph
impl PartialEq for PauliGraph
Source§impl Serialize for PauliGraph
impl Serialize for PauliGraph
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 PauliGraph
Auto Trait Implementations§
impl Freeze for PauliGraph
impl RefUnwindSafe for PauliGraph
impl Send for PauliGraph
impl Sync for PauliGraph
impl Unpin for PauliGraph
impl UnsafeUnpin for PauliGraph
impl UnwindSafe for PauliGraph
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
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>,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> ⓘ
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> ⓘ
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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.