pub struct DecoherenceProductWrapper {
pub internal: DecoherenceProduct,
}
Expand description
These are combinations of SingleDecoherenceOperators on specific qubits.
DecoherenceProducts act in a noisy system. They are representation of products of decoherence
matrices acting on qubits in order to build the terms of a hamiltonian.
For instance, to represent the term :math:\sigma_0^{x}
:math:\sigma_2^{z}
:
DecoherenceProduct().x(0).z(2)
.
Note that these methods are setters that set the decoherence operator acting on the corresponding spin, and do not represent matrix multiplication. For example
DecoherenceProduct().z(0).z(0)
will set the decoherence operator on spin 0 to Z and not to the identity.
DecoherenceProduct is supposed to be used as input for the function add_noise
,
for instance in the spin system classes PauliLindbladOpenSystem or PauliLindbladNoiseOperator,
or in the mixed systems as part of MixedDecoherenceProduct <mixed_systems.MixedDecoherenceProduct>
.
Returns: self: The new, empty DecoherenceProduct.
§Examples
.. code-block:: python
import numpy.testing as npt
from struqture_py.spins import DecoherenceProduct
dp = DecoherenceProduct().x(0).iy(1).z(2)
dp = dp.set_pauli(3, "X")
npt.assert_equal(dp.get(1), "iY")
npt.assert_equal(dp.keys(), [0, 1, 2, 3])
Fields§
§internal: DecoherenceProduct
Internal storage of struqture::spins::DecoherenceProduct
Implementations§
Source§impl DecoherenceProductWrapper
impl DecoherenceProductWrapper
Sourcepub fn from_pyany(input: &Bound<'_, PyAny>) -> PyResult<DecoherenceProduct>
pub fn from_pyany(input: &Bound<'_, PyAny>) -> PyResult<DecoherenceProduct>
Fallible conversion of generic python object..
Source§impl DecoherenceProductWrapper
impl DecoherenceProductWrapper
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty DecoherenceProduct.
Returns: self: The new, empty DecoherenceProduct.
Sourcepub fn x(&self, index: usize) -> DecoherenceProductWrapper
pub fn x(&self, index: usize) -> DecoherenceProductWrapper
Set a new entry for SingleDecoherenceOperator X in the internal dictionary.
Args: index (int): Index of set object.
Returns: DecoherenceProduct: The DecoherenceProduct with the new entry.
Sourcepub fn iy(&self, index: usize) -> DecoherenceProductWrapper
pub fn iy(&self, index: usize) -> DecoherenceProductWrapper
Set a new entry for SingleDecoherenceOperator iY in the internal dictionary.
Args: index (int): Index of set object.
Returns: DecoherenceProduct: The DecoherenceProduct with the new entry.
Sourcepub fn z(&self, index: usize) -> DecoherenceProductWrapper
pub fn z(&self, index: usize) -> DecoherenceProductWrapper
Set a new entry for SingleDecoherenceOperator Z in the internal dictionary.
Args: index (int): Index of set object.
Returns: DecoherenceProduct: The DecoherenceProduct with the new entry.
Sourcepub fn set_pauli(&self, index: usize, pauli: String) -> PyResult<Self>
pub fn set_pauli(&self, index: usize, pauli: String) -> PyResult<Self>
Set a new entry in the internal_map. This function consumes self.
Args: index (int): Index of set object. pauli (str): Value of set object.
Returns: self: The entry was correctly set and the DecoherenceProduct is returned.
Sourcepub fn hermitian_conjugate(&self) -> (DecoherenceProductWrapper, f64)
pub fn hermitian_conjugate(&self) -> (DecoherenceProductWrapper, f64)
Return the hermitian conjugate of self and its prefactor.
Returns: (self, float): The hermitian conjugate of self and the potential sign it has picked up.
Sourcepub fn is_natural_hermitian(&self) -> bool
pub fn is_natural_hermitian(&self) -> bool
Return whether self is naturally hermitian.
For spin objects, this is true when applying the hermitian conjugation does not change the sign.
For bosonic and fermionic objects, this is true when creators == annihilators.
For mixed objects, this is true when all of the spin, bosonic and fermionic parts’ is_naturally_hermitian
functions evaluate to true.
Returns: bool: Whether self is naturally hermitian or not.
Sourcepub fn get(&self, index: usize) -> Option<String>
pub fn get(&self, index: usize) -> Option<String>
Get the pauli matrix corresponding to the index.
Args: index (int): Index of get object.
Returns: Optionalstr: The key’s corresponding value (if it exists).
Sourcepub fn keys(&self) -> Vec<usize>
pub fn keys(&self) -> Vec<usize>
Return a list of the unsorted keys in self.
Returns: List[int]: The sequence of qubit index keys of self.
Sourcepub fn current_number_spins(&self) -> usize
pub fn current_number_spins(&self) -> usize
Return maximum index in self.
Returns: int: Maximum index.
Sourcepub fn __len__(&self) -> usize
pub fn __len__(&self) -> usize
Return number of entries in object.
Returns: int: The length of the content of the object.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return whether self is empty or not.
Returns: bool: Whether self is empty or not.
Sourcepub fn remap_qubits(
&self,
mapping: HashMap<usize, usize>,
) -> DecoherenceProductWrapper
pub fn remap_qubits( &self, mapping: HashMap<usize, usize>, ) -> DecoherenceProductWrapper
Remap the qubits in a new instance of self (returned).
Args: mapping (Dict[int, int]): The map containing the {qubit: qubit} mapping to use.
Returns: self: The new instance of self with the qubits remapped.
Sourcepub fn concatenate(
&self,
other: DecoherenceProductWrapper,
) -> PyResult<DecoherenceProductWrapper>
pub fn concatenate( &self, other: DecoherenceProductWrapper, ) -> PyResult<DecoherenceProductWrapper>
Return the concatenation of two objects of type self
with no overlapping qubits.
Args: other (self): The object to concatenate self with.
Returns: List[int]: A list of the corresponding creator indices.
Raises: ValueError: The two objects could not be concatenated.
Sourcepub fn multiply(
left: DecoherenceProductWrapper,
right: DecoherenceProductWrapper,
) -> (DecoherenceProductWrapper, Complex64)
pub fn multiply( left: DecoherenceProductWrapper, right: DecoherenceProductWrapper, ) -> (DecoherenceProductWrapper, Complex64)
Multiplication function for a self-typed object by a self-typed object.
Args: left (self): Left-hand self typed object to be multiplied. right (self): Right-hand self typed object to be multiplied.
Returns: (self, complex): The multiplied objects and the resulting prefactor.
Sourcepub fn __copy__(&self) -> DecoherenceProductWrapper
pub fn __copy__(&self) -> DecoherenceProductWrapper
Return a copy of self (copy here produces a deepcopy).
Returns: self: A deep copy of Self.
Sourcepub fn __deepcopy__(
&self,
_memodict: &Bound<'_, PyAny>,
) -> DecoherenceProductWrapper
pub fn __deepcopy__( &self, _memodict: &Bound<'_, PyAny>, ) -> DecoherenceProductWrapper
Return a deep copy of self.
Returns: self: A deep copy of Self.
Sourcepub fn from_bincode(
input: &Bound<'_, PyAny>,
) -> PyResult<DecoherenceProductWrapper>
pub fn from_bincode( input: &Bound<'_, PyAny>, ) -> PyResult<DecoherenceProductWrapper>
Sourcepub fn to_bincode(&self) -> PyResult<Py<PyByteArray>>
pub fn to_bincode(&self) -> PyResult<Py<PyByteArray>>
Sourcepub fn to_json(&self) -> PyResult<String>
pub fn to_json(&self) -> PyResult<String>
Return the json representation of the object.
Returns: str: The serialized form of the object.
Raises: ValueError: Cannot serialize object to json.
Sourcepub fn from_json(input: String) -> PyResult<DecoherenceProductWrapper>
pub fn from_json(input: String) -> PyResult<DecoherenceProductWrapper>
Convert the json representation of the object to an instance.
Args: input (str): The serialized object in json form.
Returns: The deserialized object.
Raises: ValueError: Input cannot be deserialized.
Sourcepub fn from_string(input: String) -> PyResult<DecoherenceProductWrapper>
pub fn from_string(input: String) -> PyResult<DecoherenceProductWrapper>
Convert a string representation of the object to an instance.
Args: input (str): The serialized index in str representation.
Returns: self: The converted object.
Raises: ValueError: Input cannot be converted from str.
Sourcepub fn __str__(&self) -> String
pub fn __str__(&self) -> String
Return a string containing a printable representation of the index.
Returns: str: The printable string representation of the index.
Sourcepub fn __repr__(&self) -> String
pub fn __repr__(&self) -> String
Return a string containing a printable representation of the index.
Returns: str: The printable string representation of the index.
Sourcepub fn __richcmp__(
&self,
other: &Bound<'_, PyAny>,
op: CompareOp,
) -> PyResult<bool>
pub fn __richcmp__( &self, other: &Bound<'_, PyAny>, op: CompareOp, ) -> PyResult<bool>
Return the richcmp magic method to perform rich comparison operations on mixed index.
Args: other: The object to compare self to. op: Whether they should be equal or not.
Returns: Whether the two operations compared evaluated to True or False
Raises: NotImplementedError: Other comparison not implemented.
Source§impl DecoherenceProductWrapper
impl DecoherenceProductWrapper
Sourcepub fn jordan_wigner(&self) -> FermionOperatorWrapper
pub fn jordan_wigner(&self) -> FermionOperatorWrapper
Transform the given spin object into a fermionic object using the Jordan Wigner mapping.
Trait Implementations§
Source§impl Clone for DecoherenceProductWrapper
impl Clone for DecoherenceProductWrapper
Source§fn clone(&self) -> DecoherenceProductWrapper
fn clone(&self) -> DecoherenceProductWrapper
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for DecoherenceProductWrapper
impl Debug for DecoherenceProductWrapper
Source§impl Default for DecoherenceProductWrapper
impl Default for DecoherenceProductWrapper
Source§fn default() -> DecoherenceProductWrapper
fn default() -> DecoherenceProductWrapper
Source§impl<'py> IntoPyObject<'py> for DecoherenceProductWrapper
impl<'py> IntoPyObject<'py> for DecoherenceProductWrapper
Source§type Target = DecoherenceProductWrapper
type Target = DecoherenceProductWrapper
Source§type Output = Bound<'py, <DecoherenceProductWrapper as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <DecoherenceProductWrapper as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl Ord for DecoherenceProductWrapper
impl Ord for DecoherenceProductWrapper
Source§fn cmp(&self, other: &DecoherenceProductWrapper) -> Ordering
fn cmp(&self, other: &DecoherenceProductWrapper) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for DecoherenceProductWrapper
impl PartialOrd for DecoherenceProductWrapper
Source§impl PyClass for DecoherenceProductWrapper
impl PyClass for DecoherenceProductWrapper
Source§impl PyClassImpl for DecoherenceProductWrapper
impl PyClassImpl for DecoherenceProductWrapper
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§type ThreadChecker = SendablePyClass<DecoherenceProductWrapper>
type ThreadChecker = SendablePyClass<DecoherenceProductWrapper>
type Inventory = Pyo3MethodsInventoryForDecoherenceProductWrapper
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<DecoherenceProductWrapper> for PyClassImplCollector<DecoherenceProductWrapper>
impl PyClassNewTextSignature<DecoherenceProductWrapper> for PyClassImplCollector<DecoherenceProductWrapper>
fn new_text_signature(self) -> Option<&'static str>
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a DecoherenceProductWrapper
impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a DecoherenceProductWrapper
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut DecoherenceProductWrapper
impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut DecoherenceProductWrapper
Source§impl PyTypeInfo for DecoherenceProductWrapper
impl PyTypeInfo for DecoherenceProductWrapper
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
impl DerefToPyAny for DecoherenceProductWrapper
impl Eq for DecoherenceProductWrapper
impl StructuralPartialEq for DecoherenceProductWrapper
Auto Trait Implementations§
impl Freeze for DecoherenceProductWrapper
impl RefUnwindSafe for DecoherenceProductWrapper
impl Send for DecoherenceProductWrapper
impl Sync for DecoherenceProductWrapper
impl Unpin for DecoherenceProductWrapper
impl UnwindSafe for DecoherenceProductWrapper
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> FromPyObject<'_> for T
impl<T> FromPyObject<'_> for T
Source§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
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<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self
into an owned Python object, dropping type information.