plan_factorization
Stable function · Sparsity and structure
Tier: stable · Kind: function · Topic: Sparsity and structure
| Julia | Python | Rust |
|---|---|---|
plan_factorization | plan_factorization | block_diagonal_lu |
Note: Rust exposes the first plan implementation, the per-cell block LU, directly as block_diagonal_lu.
Julia
plan_factorization(entries::Vector{JacEntry}, sv::SysView; structure)
plan_factorization(entries, sv::SysView;
structure = detect_structure(entries, sv))
-> Union{FactorizationPlan, Nothing}
Symbolic factorization info for the detected structure class, or nothing
when no plan is implemented for that class (the Jacobian itself is still
fully usable — a plan is an optimization, never a requirement).
Currently implemented: :block_diagonal → BlockDiagonalPlan
.
Example (structure)
@assert detect_structure(entries, view) == :block_diagonal
plan = plan_factorization(entries, view)
@assert sort(plan.block_vars) == ["A", "B", "C"]
Python
plan_factorization(entries: list[JacEntry], sv: SysView, structure: str | None = None)
Symbolic factorization info for the detected structure.
Returns a BlockDiagonalPlan
when the structure is
"block_diagonal" and None otherwise; banded and general plans are
not implemented yet.
Example (structure)
assert earthsci_astdiff.detect_structure(entries, view) == "block_diagonal"
plan = earthsci_astdiff.plan_factorization(entries, view)
assert sorted(plan.block_vars) == ["A", "B", "C"]
Rust
pub fn block_diagonal_lu(entries: &[JacEntry]) -> BlockLu
Symbolic factorization info for a block-diagonal band list: the per-cell
block LU with Markowitz ordering and fill-in (BlockLu
).
Example (structure)
let ctx = ctx_of(&view)?;
assert_eq!(detect_structure(&entries, &ctx), "block_diagonal");
let plan = block_diagonal_lu(&entries);
let mut vars = plan.block_vars.clone();
vars.sort();
assert_eq!(vars, ["A", "B", "C"]);