pub fn square_linsolve<T, V>(
operator: &TreeTN<T, V>,
rhs: &TreeTN<T, V>,
init: TreeTN<T, V>,
center: &V,
options: LinsolveOptions,
input_mapping: Option<HashMap<V, IndexMapping<T::Index>>>,
output_mapping: Option<HashMap<V, IndexMapping<T::Index>>>,
) -> Result<SquareLinsolveResult<T, V>>Expand description
Solve the linear system (a₀ + a₁ * H) |x⟩ = |b⟩ for TreeTN.
This solver is for the square case where V_in = V_out (input and output spaces are the same).
§Arguments
operator- The operator H as a TreeTN (must have compatible structure withrhs)rhs- The right-hand side |b⟩ as a TreeTNinit- Initial guess for |x⟩center- Node to use as sweep centeroptions- Solver optionsinput_mapping- Optional per-node mapping from state site index to operator input index. Required when the operator (MPO) uses internal indices distinct from the state’s site indices.output_mapping- Optional per-node mapping from state site index to operator output index. Required when the operator (MPO) uses internal indices distinct from the state’s site indices.
§Returns
The solution TreeTN, or an error if solving fails.
§Example
use tensor4all_core::{DynIndex, TensorDynLen};
use tensor4all_treetn::{square_linsolve, LinsolveOptions, TreeTN};
let s = DynIndex::new_dyn(2);
let operator_tensor = TensorDynLen::from_dense(vec![s.clone()], vec![1.0, 1.0])?;
let rhs_tensor = TensorDynLen::from_dense(vec![s.clone()], vec![1.0, 2.0])?;
let init_tensor = TensorDynLen::from_dense(vec![s.clone()], vec![0.0, 0.0])?;
let operator = TreeTN::<TensorDynLen, usize>::from_tensors(vec![operator_tensor], vec![0])?;
let rhs = TreeTN::<TensorDynLen, usize>::from_tensors(vec![rhs_tensor], vec![0])?;
let init = TreeTN::<TensorDynLen, usize>::from_tensors(vec![init_tensor], vec![0])?;
let result = square_linsolve(&operator, &rhs, init, &0usize, LinsolveOptions::default(), None, None)?;
assert_eq!(result.solution.node_count(), 1);