Skip to main content

apply_local_update_sweep

Function apply_local_update_sweep 

Source
pub fn apply_local_update_sweep<T, V, U>(
    treetn: &mut TreeTN<T, V>,
    plan: &LocalUpdateSweepPlan<V>,
    updater: &mut U,
) -> Result<()>
where T: TensorLike, <T::Index as IndexLike>::Id: Clone + Hash + Eq + Ord + Debug + Send + Sync, V: Clone + Hash + Eq + Ord + Send + Sync + Debug, U: LocalUpdater<T, V>,
Expand description

Apply a local update sweep to a TreeTN.

This function orchestrates the sweep by:

  1. Iterating through the sweep plan
  2. For each step: a. Validate that the canonical center is a single node within the extracted subtree b. Extract the local subtree c. Call the updater to transform it d. Replace the subtree back into the TreeTN

§Arguments

  • treetn - The TreeTN to update (modified in place)
  • plan - The sweep plan specifying the update order
  • updater - The local updater implementation

§Preconditions

  • The TreeTN must be canonicalized with a single-node canonical center
  • The canonical center must be within the first step’s nodes

§Returns

Ok(()) if the sweep completes successfully.

§Errors

Returns an error if:

  • TreeTN is not canonicalized (canonical_region is empty)
  • canonical_region is not a single node
  • canonical_region is not within the extracted subtree
  • Subtree extraction fails
  • The updater returns an error
  • Subtree replacement fails