pub fn union_inds<I: IndexLike>(indices_a: &[I], indices_b: &[I]) -> Vec<I>Expand description
Find the union of two index collections.
Returns all unique indices from both collections (matched by ID).
This corresponds to ITensors.jl’s unioninds function.
Time complexity: O(n + m) where n = len(indices_a), m = len(indices_b).
§Arguments
indices_a- First collection of indicesindices_b- Second collection of indices
§Returns
A vector containing all unique indices from both collections.
§Example
use tensor4all_core::index::{DefaultIndex as Index, DynId};
use tensor4all_core::index_ops::union_inds;
let i = Index::new_dyn(2);
let j = Index::new_dyn(3);
let k = Index::new_dyn(4);
let indices_a = vec![i.clone(), j.clone()];
let indices_b = vec![j.clone(), k.clone()];
let union = union_inds(&indices_a, &indices_b);
assert_eq!(union.len(), 3); // i, j, k