pub fn noncommon_inds<I: IndexLike>(indices_a: &[I], indices_b: &[I]) -> Vec<I>Expand description
Find indices that are not common between two collections (symmetric difference).
Returns indices that appear in either indices_a or indices_b but not in both
(matched by ID). This corresponds to ITensors.jl’s noncommoninds 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 indices from both collections that are not common to both. Order: indices from A first (in original order), then indices from B (in original order).
§Example
use tensor4all_core::index::{DefaultIndex as Index, DynId};
use tensor4all_core::index_ops::noncommon_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 noncommon = noncommon_inds(&indices_a, &indices_b);
assert_eq!(noncommon.len(), 2); // i and k