Skip to main content

TensorContractionLike

Trait TensorContractionLike 

Source
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>>;
    fn outer_product(&self, other: &Self) -> Result<Self>;
    fn permuteinds(
        &self,
        new_order: &[<Self as TensorIndex>::Index],
    ) -> Result<Self>;
    fn fuse_indices(
        &self,
        old_indices: &[<Self as TensorIndex>::Index],
        new_index: <Self as TensorIndex>::Index,
        order: LinearizationOrder,
    ) -> Result<Self>;
    fn contract(tensors: &[&Self]) -> Result<Self>;

    // Provided methods
    fn contract_pair(&self, other: &Self) -> Result<Self> { ... }
    fn validate(&self) -> Result<()> { ... }
}
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§

Source

fn conj(&self) -> Self

Tensor conjugate operation.

Source

fn direct_sum( &self, other: &Self, pairs: &[(<Self as TensorIndex>::Index, <Self as TensorIndex>::Index)], ) -> Result<DirectSumResult<Self>>

Direct sum of two tensors along specified index pairs.

Source

fn outer_product(&self, other: &Self) -> Result<Self>

Outer product (tensor product) of two tensors.

Source

fn permuteinds( &self, new_order: &[<Self as TensorIndex>::Index], ) -> Result<Self>

Permute tensor indices to match the specified order.

Source

fn fuse_indices( &self, old_indices: &[<Self as TensorIndex>::Index], new_index: <Self as TensorIndex>::Index, order: LinearizationOrder, ) -> Result<Self>

Fuse local tensor indices into one replacement index.

Source

fn contract(tensors: &[&Self]) -> Result<Self>

Contract a connected tensor network over its contractable indices.

Provided Methods§

Source

fn contract_pair(&self, other: &Self) -> Result<Self>

Contract this tensor with one other tensor using default pairwise semantics.

Source

fn validate(&self) -> Result<()>

Validate structural consistency of this tensor.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§