pub struct PartialContractionSpec<I: IndexLike> {
pub contract_pairs: Vec<(I, I)>,
pub diagonal_pairs: Vec<(I, I)>,
pub output_order: Option<Vec<I>>,
}Expand description
Specification for partial site contraction between two TreeTNs.
contract_pairs: Site index pairs to sum over and remove from the result.diagonal_pairs: Site index pairs to identify through diagonal/copy structure while keeping the left-hand site leg in the result.- Remaining (unmentioned) site indices pass through as external legs.
Uses Index objects directly (not raw IDs), following Julia ITensor-style
conventions.
§Examples
use tensor4all_core::DynIndex;
use tensor4all_treetn::PartialContractionSpec;
let idx_a = DynIndex::new_dyn(4);
let idx_b = DynIndex::new_dyn(4);
let idx_c = DynIndex::new_dyn(3);
let idx_d = DynIndex::new_dyn(3);
let spec = PartialContractionSpec {
contract_pairs: vec![(idx_a.clone(), idx_b.clone())],
diagonal_pairs: vec![(idx_c.clone(), idx_d.clone())],
output_order: None,
};
assert_eq!(spec.contract_pairs.len(), 1);
assert_eq!(spec.diagonal_pairs.len(), 1);Fields§
§contract_pairs: Vec<(I, I)>Site index pairs to contract (summed over, removed from result).
diagonal_pairs: Vec<(I, I)>Site index pairs to link through diagonal/copy structure while keeping the left-hand site index in the result.
output_order: Option<Vec<I>>Optional order for the surviving external site indices in the result.
The indices must refer to the final result indices after applying
contract_pairs and diagonal_pairs. When provided, the result is
post-processed so that these indices appear in the requested order.
Current implementation requires that each surviving site index occupies a distinct node in the result.
Trait Implementations§
Source§impl<I: Clone + IndexLike> Clone for PartialContractionSpec<I>
impl<I: Clone + IndexLike> Clone for PartialContractionSpec<I>
Source§fn clone(&self) -> PartialContractionSpec<I>
fn clone(&self) -> PartialContractionSpec<I>
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 moreAuto Trait Implementations§
impl<I> Freeze for PartialContractionSpec<I>
impl<I> RefUnwindSafe for PartialContractionSpec<I>where
I: RefUnwindSafe,
impl<I> Send for PartialContractionSpec<I>
impl<I> Sync for PartialContractionSpec<I>
impl<I> Unpin for PartialContractionSpec<I>where
I: Unpin,
impl<I> UnsafeUnpin for PartialContractionSpec<I>
impl<I> UnwindSafe for PartialContractionSpec<I>where
I: UnwindSafe,
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
Casts
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
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