Version: dev

plan_factorization

Stable function · Sparsity and structure

Tier: stable · Kind: function · Topic: Sparsity and structure

JuliaPythonRust
plan_factorizationplan_factorizationblock_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 .

Source

Example (structure)

@assert detect_structure(entries, view) == :block_diagonal
plan = plan_factorization(entries, view)
@assert sort(plan.block_vars) == ["A", "B", "C"]

From docs/api/examples/julia/jacobians.jl

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.

Source

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"]

From docs/api/examples/python/jacobians.py

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 ).

Source · Rust docs

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"]);

From docs/api/examples/rust/jacobians.rs