Skip to main content

factorize_tensor_to_treetn_with

Function factorize_tensor_to_treetn_with 

Source
pub fn factorize_tensor_to_treetn_with<T, V>(
    tensor: &T,
    topology: &TreeTopology<V, <T::Index as IndexLike>::Id>,
    options: FactorizeOptions,
    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

Factorize a dense tensor into a TreeTN using specified factorization options.

This function takes a dense tensor and a tree topology specification, then recursively decomposes the tensor using the specified algorithm 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
  • options - Factorization options (algorithm, max_rank, rtol, etc.)

§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