pub struct Contraction<T: SVDScalar>{ /* private fields */ }Expand description
Contraction of two MPOs with caching
This struct efficiently computes the product of two MPOs by caching left and right environments for reuse.
Implementations§
Source§impl<T: SVDScalar> Contraction<T>
impl<T: SVDScalar> Contraction<T>
Sourcepub fn new(mpo_a: MPO<T>, mpo_b: MPO<T>) -> Result<Self>
pub fn new(mpo_a: MPO<T>, mpo_b: MPO<T>) -> Result<Self>
Create a new Contraction from two MPOs
Sourcepub fn with_transform<F>(mpo_a: MPO<T>, mpo_b: MPO<T>, f: F) -> Result<Self>
pub fn with_transform<F>(mpo_a: MPO<T>, mpo_b: MPO<T>, f: F) -> Result<Self>
Create a new Contraction with a transformation function
Sourcepub fn result_site_dims(&self) -> Vec<(usize, usize)>
pub fn result_site_dims(&self) -> Vec<(usize, usize)>
Get site dimensions for the contracted result
Returns (s1_result, s2_result) at each site where:
- s1_result = s1_a (first physical index of A)
- s2_result = s2_b (second physical index of B)
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear all cached environments
Sourcepub fn evaluate(&mut self, indices: &[(usize, usize)]) -> Result<T>
pub fn evaluate(&mut self, indices: &[(usize, usize)]) -> Result<T>
Evaluate the contraction at a specific set of indices
indices should be [(i1, j1), (i2, j2), …] where:
- i_k is the index for s1 of MPO A at site k
- j_k is the index for s2 of MPO B at site k
Auto Trait Implementations§
impl<T> Freeze for Contraction<T>
impl<T> !RefUnwindSafe for Contraction<T>
impl<T> Send for Contraction<T>
impl<T> Sync for Contraction<T>
impl<T> Unpin for Contraction<T>
impl<T> UnsafeUnpin for Contraction<T>
impl<T> !UnwindSafe for Contraction<T>
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
§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