pub trait TensorContractionLike: TensorIndex {
// Required methods
fn conj(&self) -> Self;
fn direct_sum(
&self,
other: &Self,
pairs: &[(<Self as TensorIndex>::Index, <Self as TensorIndex>::Index)],
) -> Result<DirectSumResult<Self>, Self::Error>;
fn outer_product(&self, other: &Self) -> Result<Self, Self::Error>;
fn permuteinds(
&self,
new_order: &[<Self as TensorIndex>::Index],
) -> Result<Self, Self::Error>;
fn fuse_indices(
&self,
old_indices: &[<Self as TensorIndex>::Index],
new_index: <Self as TensorIndex>::Index,
order: LinearizationOrder,
) -> Result<Self, Self::Error>;
fn contract(tensors: &[&Self]) -> Result<Self, Self::Error>;
// Provided methods
fn contract_pair(&self, other: &Self) -> Result<Self, Self::Error> { ... }
fn validate(&self) -> Result<(), Self::Error> { ... }
}Expand description
Contraction/einsum-style operations for tensor-like values.
Types that only need vector-space algebra should not implement or require this trait. Tree tensor-network algorithms should use this trait when they truly need index-based contraction.
Required Methods§
Sourcefn direct_sum(
&self,
other: &Self,
pairs: &[(<Self as TensorIndex>::Index, <Self as TensorIndex>::Index)],
) -> Result<DirectSumResult<Self>, Self::Error>
fn direct_sum( &self, other: &Self, pairs: &[(<Self as TensorIndex>::Index, <Self as TensorIndex>::Index)], ) -> Result<DirectSumResult<Self>, Self::Error>
Direct sum of two tensors along specified index pairs.
§Errors
Returns Self::Error when the summed index spaces are incompatible
(an index-space mismatch) or the underlying construction reports a
failure.
Sourcefn outer_product(&self, other: &Self) -> Result<Self, Self::Error>
fn outer_product(&self, other: &Self) -> Result<Self, Self::Error>
Outer product (tensor product) of two tensors.
§Errors
Returns Self::Error when the two tensors share contractable indices
(a shared-index mismatch) or the underlying construction reports a
failure.
Sourcefn permuteinds(
&self,
new_order: &[<Self as TensorIndex>::Index],
) -> Result<Self, Self::Error>
fn permuteinds( &self, new_order: &[<Self as TensorIndex>::Index], ) -> Result<Self, Self::Error>
Permute tensor indices to match the specified order.
§Errors
Returns Self::Error when new_order does not contain exactly the
tensor’s external indices (an index-set mismatch or a missing-index
failure).
Sourcefn fuse_indices(
&self,
old_indices: &[<Self as TensorIndex>::Index],
new_index: <Self as TensorIndex>::Index,
order: LinearizationOrder,
) -> Result<Self, Self::Error>
fn fuse_indices( &self, old_indices: &[<Self as TensorIndex>::Index], new_index: <Self as TensorIndex>::Index, order: LinearizationOrder, ) -> Result<Self, Self::Error>
Fuse local tensor indices into one replacement index.
§Errors
Returns Self::Error when old_indices is not a subset of the
tensor’s external indices (a missing-index failure) or the fused
dimension product overflows (an overflow failure).
Sourcefn contract(tensors: &[&Self]) -> Result<Self, Self::Error>
fn contract(tensors: &[&Self]) -> Result<Self, Self::Error>
Contract a connected tensor network over its contractable indices.
§Errors
Returns Self::Error when the network is disconnected (a
disconnected-network failure), when indices are incompatible (an
index-space mismatch), or when the underlying contraction reports a
failure.
Provided Methods§
Sourcefn contract_pair(&self, other: &Self) -> Result<Self, Self::Error>
fn contract_pair(&self, other: &Self) -> Result<Self, Self::Error>
Contract this tensor with one other tensor using default pairwise semantics.
§Errors
Returns Self::Error when the pair is disconnected or has
incompatible indices (an index-space mismatch); propagates failures
from Self::contract.
Sourcefn validate(&self) -> Result<(), Self::Error>
fn validate(&self) -> Result<(), Self::Error>
Validate structural consistency of this tensor.
§Errors
Returns Self::Error when the tensor’s index space or shape is
structurally inconsistent (an index-space mismatch or an invalid
internal state). The default implementation always returns Ok(()).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".