SpinIndex

Trait SpinIndex 

Source
pub trait SpinIndex:
    SymmetricIndex
    + Hash
    + Eq
    + Sized
    + Clone
    + Debug
    + Display
    + FromStr
    + Default
    + Serialize
where Self::SingleSpinType: Copy,
{ type SingleSpinType; // Required methods fn new() -> Self; fn set_pauli(self, index: usize, pauli: Self::SingleSpinType) -> Self; fn get(&self, index: &usize) -> Option<&Self::SingleSpinType>; fn iter(&self) -> Iter<'_, (usize, Self::SingleSpinType)>; fn remap_qubits(&self, mapping: &HashMap<usize, usize>) -> Self; fn multiply(left: Self, right: Self) -> (Self, Complex64); fn concatenate(&self, other: Self) -> Result<Self, StruqtureError>; // Provided methods fn current_number_spins(&self) -> usize { ... } fn len(&self) -> usize { ... } fn is_empty(&self) -> bool { ... } }
Expand description

Trait for all index types requires converting between index types

Required Associated Types§

Source

type SingleSpinType

Type of operators on single spin in a SpinIndex.

This can either be a crate::spins::SinglePauliOperator (I, X, Y or Z) or a [crate::spins::SingleOperator/Hamiltonian] (I, X, iY or Z)

Required Methods§

Source

fn new() -> Self

Creates a new Self typed object.

§Returns
  • Self - The new (empty) instance of type Self.
Source

fn set_pauli(self, index: usize, pauli: Self::SingleSpinType) -> Self

Sets a new entry in Self. This function consumes Self.

§Arguments
  • index - Index of set object.
  • pauli - Value of set object.
§Returns
  • Self - The entry was correctly set and the new object is returned.
Source

fn get(&self, index: &usize) -> Option<&Self::SingleSpinType>

Gets the pauli matrix corresponding to the index.

§Arguments
  • index - The index of qubit to get the pauli matrix for.
§Returns
  • Some(&SingleSpinType) - The key exists and its corresponding value is returned.
  • None - The key does not exist in Self.
Source

fn iter(&self) -> Iter<'_, (usize, Self::SingleSpinType)>

Returns the iterator form of Self.

§Returns
  • Iter<usize, SingleSpinType> - The iterator form of Self.
Source

fn remap_qubits(&self, mapping: &HashMap<usize, usize>) -> Self

Remaps the qubits in a clone instance of Self.

§Arguments
  • mapping - The map containing the {qubit: qubit} mapping to use.
§Returns
  • Self - The new object with the qubits remapped from Self.
Source

fn multiply(left: Self, right: Self) -> (Self, Complex64)

Implements multiplication function for a Self typed object by a Self typed object.

§Arguments
  • left - Left-hand Self typed object to be multiplied.
  • right - Right-hand Self typed object to be multiplied.

Returns

  • (Self, Complex64) - The multiplied objects and the resulting prefactor.
Source

fn concatenate(&self, other: Self) -> Result<Self, StruqtureError>

Returns the concatenation of two Self typed objects with no overlapping qubits.

§Arguments
  • other - The object to concatenate Self with.

Returns

  • Ok(Self) - The concatenated objects.
  • Err(StruqtureError::ProductIndexAlreadyOccupied) - Cannot assign pauli matrix to index as it is already occupied.

Provided Methods§

Source

fn current_number_spins(&self) -> usize

Returns maximum index in Self.

§Returns
  • usize - Maximum index.
Source

fn len(&self) -> usize

Returns the length of the SpinIndex object.

§Returns
  • usize - The length of the SpinIndex object.
Source

fn is_empty(&self) -> bool

Returns whether the SpinIndex object is empty or not.

§Returns
  • bool - Whether the SpinIndex object is empty or not.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§