pub struct ContractionPath {
pub nested: FxHashMap<TensorIndex, ContractionPath>,
pub toplevel: SimplePath,
}Expand description
A (possibly nested) contraction path.
It specifies the overall contraction path to contract a tensor network, but also allows to specify additional contraction paths for each tensor, in order to deal with composite tensors that have to be contracted first.
Fields§
§nested: FxHashMap<TensorIndex, ContractionPath>Nested contraction paths for composite tensors.
toplevel: SimplePathThe top-level contraction path for the tensor network itself.
Implementations§
Source§impl ContractionPath
impl ContractionPath
Sourcepub fn nested(
nested: Vec<(TensorIndex, ContractionPath)>,
toplevel: Vec<(TensorIndex, TensorIndex)>,
) -> Self
pub fn nested( nested: Vec<(TensorIndex, ContractionPath)>, toplevel: Vec<(TensorIndex, TensorIndex)>, ) -> Self
Creates a contraction path with nested paths.
Sourcepub fn simple(path: SimplePath) -> Self
pub fn simple(path: SimplePath) -> Self
Creates a plain contraction path without nested paths.
§Examples
let path: SimplePath = vec![(0, 1), (0, 2), (0, 3)];
let contraction_path = ContractionPath::simple(path.clone());
assert!(contraction_path.is_simple());
assert_eq!(contraction_path.toplevel, path);Sourcepub fn single(a: TensorIndex, b: TensorIndex) -> Self
pub fn single(a: TensorIndex, b: TensorIndex) -> Self
Creates a contraction path from a single contraction of two tensors.
§Examples
let contraction_path = ContractionPath::single(0, 1);
assert!(contraction_path.is_simple());
assert_eq!(contraction_path.toplevel, vec![(0, 1)]);Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The length of the contraction path, that is, the number of top-level contractions.
§Examples
let contraction_path = ContractionPath::simple(vec![(0, 1), (0, 2), (0, 3)]);
assert_eq!(contraction_path.len(), 3);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether there are any top-level contractions in this contraction path.
§Examples
assert!(ContractionPath::default().is_empty());
assert!(!ContractionPath::simple(vec![(0, 1)]).is_empty());Sourcepub fn is_simple(&self) -> bool
pub fn is_simple(&self) -> bool
Returns whether this path has no nested paths.
§Examples
let simple_path = path![(0, 1), (0, 2), (0, 3)];
assert!(simple_path.is_simple());
let nested_path = path![{(2, [(0, 2), (0, 1)])}, (0, 1), (0, 2)];
assert!(!nested_path.is_simple());Sourcepub fn into_simple(self) -> SimplePath
pub fn into_simple(self) -> SimplePath
Trait Implementations§
Source§impl Clone for ContractionPath
impl Clone for ContractionPath
Source§fn clone(&self) -> ContractionPath
fn clone(&self) -> ContractionPath
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContractionPath
impl Debug for ContractionPath
Source§impl Default for ContractionPath
impl Default for ContractionPath
Source§fn default() -> ContractionPath
fn default() -> ContractionPath
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ContractionPath
impl<'de> Deserialize<'de> for ContractionPath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ContractionPath
impl PartialEq for ContractionPath
Source§impl Serialize for ContractionPath
impl Serialize for ContractionPath
impl Eq for ContractionPath
impl StructuralPartialEq for ContractionPath
Auto Trait Implementations§
impl Freeze for ContractionPath
impl RefUnwindSafe for ContractionPath
impl Send for ContractionPath
impl Sync for ContractionPath
impl Unpin for ContractionPath
impl UnwindSafe for ContractionPath
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
Attempts to downcast this to
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
Attempts to downcast this to
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
Attempts to downcast this to
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
Attempts to downcast this to
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
Attempts to downcast this to
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Attempts to downcast owned
Self to T,
useful only in generic context as a workaround for specialization§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Approximate the subject to a given type with a specific scheme.
§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
Compare self to
key and return true if they are equal.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>
Converts
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>
Converts
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 more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
§impl<Src> TryFrom<Src> for Src
impl<Src> TryFrom<Src> for Src
§impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
§impl<Src> ValueFrom<Src> for Src
impl<Src> ValueFrom<Src> for Src
§fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
Convert the given value into an exactly equivalent representation.
§impl<Src, Dst> ValueInto<Dst> for Srcwhere
Dst: ValueFrom<Src>,
impl<Src, Dst> ValueInto<Dst> for Srcwhere
Dst: ValueFrom<Src>,
§fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
Convert the subject into an exactly equivalent representation.