Skip to main content

factorize_tensor_to_treetn

Function factorize_tensor_to_treetn 

Source
pub fn factorize_tensor_to_treetn<T, V>(
    tensor: &T,
    topology: &TreeTopology<V, <T::Index as IndexLike>::Id>,
    root: &V,
) -> Result<TreeTN<T, V>>
where T: TensorLike, <T::Index as IndexLike>::Id: Clone + Hash + Eq + Ord + Debug + Send + Sync, V: Clone + Hash + Eq + Send + Sync + Debug + Ord,
Expand description

Decompose a dense tensor into a TreeTN using QR-based factorization.

This function takes a dense tensor and a tree topology specification, then recursively decomposes the tensor using QR factorization to create a TreeTN.

§Algorithm

  1. Start from a leaf node, factorize to separate that node’s physical indices
  2. Contract the right factor with remaining tensor, repeat for next edge
  3. Continue until all edges are processed

§Arguments

  • tensor - The dense tensor to decompose
  • topology - Tree topology specifying nodes, edges, and physical index assignments

§Returns

A TreeTN representing the decomposed tensor.

§Errors

Returns an error if:

  • The topology is invalid
  • Physical index positions don’t match the tensor
  • Factorization fails