Skip to main content

LocalUpdater

Trait LocalUpdater 

Source
pub trait LocalUpdater<T, V>
where T: TensorLike, V: Clone + Hash + Eq + Send + Sync + Debug,
{ // Required method fn update( &mut self, subtree: TreeTN<T, V>, step: &LocalUpdateStep<V>, full_treetn: &TreeTN<T, V>, ) -> Result<TreeTN<T, V>>; // Provided methods fn before_step( &mut self, _step: &LocalUpdateStep<V>, _full_treetn_before: &TreeTN<T, V>, ) -> Result<()> { ... } fn after_step( &mut self, _step: &LocalUpdateStep<V>, _full_treetn_after: &TreeTN<T, V>, ) -> Result<()> { ... } }
Expand description

Trait for local update operations during a sweep.

Implementors of this trait provide the actual update logic that transforms a local subtree into an updated version. This allows different algorithms (truncation, fitting, DMRG, TDVP) to share the same sweep infrastructure.

§Type Parameters

  • T: Tensor type implementing TensorLike
  • V: Node name type

§Workflow

During apply_local_update_sweep:

  1. For each step in the sweep plan: a. Extract the subtree containing step.nodes b. Call update() with the extracted subtree and step info c. Replace the subtree in the original TreeTN with the updated one d. Update the canonical center to step.new_center

Required Methods§

Source

fn update( &mut self, subtree: TreeTN<T, V>, step: &LocalUpdateStep<V>, full_treetn: &TreeTN<T, V>, ) -> Result<TreeTN<T, V>>

Update a local subtree.

§Arguments
  • subtree - The extracted subtree to update
  • step - The current step information (nodes and new_center)
  • full_treetn - Reference to the full (global) TreeTN. This provides global context (e.g., topology, neighbor relations, and index/bond metadata) that some update algorithms may need. It may be unused by simple updaters.
§Returns

The updated subtree, which must have the same “appearance” as the input (same nodes, same external indices, same ortho_towards structure).

§Errors

Returns an error if the update fails (e.g., SVD doesn’t converge).

Provided Methods§

Source

fn before_step( &mut self, _step: &LocalUpdateStep<V>, _full_treetn_before: &TreeTN<T, V>, ) -> Result<()>

Optional hook called before performing an update step.

This is called with the full TreeTN state before the update is applied. Implementors can use it to validate assumptions or prefetch/update caches.

Source

fn after_step( &mut self, _step: &LocalUpdateStep<V>, _full_treetn_after: &TreeTN<T, V>, ) -> Result<()>

Optional hook called after an update step has been applied to the full TreeTN.

This is called after:

  • The updated subtree has been inserted back into the full TreeTN
  • The canonical center has been moved to step.new_center

Implementors can use this to update caches that must see the post-update state.

Implementors§

Source§

impl<T, V> LocalUpdater<T, V> for SquareLinsolveUpdater<T, V>
where T: TensorLike + 'static, T::Index: IndexLike, <T::Index as IndexLike>::Id: Clone + Hash + Eq + Ord + Debug + Send + Sync + 'static, V: Clone + Hash + Eq + Ord + Send + Sync + Debug + 'static,

Source§

impl<T, V> LocalUpdater<T, V> for TruncateUpdater
where T: TensorLike, <T::Index as IndexLike>::Id: Clone + Hash + Eq + Ord + Debug + Send + Sync, V: Clone + Hash + Eq + Ord + Send + Sync + Debug,