Skip to main content

create_element

Function create_element 

Source
pub fn create_element(
    ws: &mut Workspace,
    me: usize,
) -> Result<(usize, usize, i32, usize), OrderingError>
Expand description

Build the new element me by merging the (variable) tail of me’s list with every element e already in me’s list.

On success returns (pme1, pme2_excl, nvpiv, degme):

  • pme1..pme2_excl is the contiguous region in ws.iw holding the new element’s variable members (supervariables, listed once each). Exclusive end so the empty case (pme2_excl == pme1) is representable in usize without underflow.
  • nvpiv is the supervariable count of the pivot.
  • degme is the tentative new element’s external degree (sum of nv[i] over the assembled variables, before any absorption correction made by Pass-2).

Post-conditions also persisted on the workspace:

  • nv[me] = -nvpiv (marker — Pass-2 will flip sign back via -nv[i]).
  • nv[i] = -nv[i] for every i assembled into the new element (ditto — marker for Pass-2’s w-seed walk).
  • pe[me] = pme1, len[me] = pme2 - pme1 + 1, elen[me] = flip(nvpiv + degme) (dead-variable sentinel carrying the pivot-front size for the postorder phase).
  • degree[me] = degme (temporary; Pass-2 overwrites).
  • For every absorbed element e != me in the elenme>0 branch: pe[e] = flip(me), w[e] = 0. This is standard absorption (faer amd.rs:355-358) — it fires unconditionally at each knt1 iter’s end. Aggressive absorption (Pass-2 only) lands in Commit 5.
  • ws.wflg bumped via clear_flag.
  • ws.nel incremented by nvpiv.

Reference: faer amd.rs:236-366 (incl. inline GC at 289-338).