Skip to main content

Module types

Module types 

Source
Expand description

Sentinel-index encoding and fixed solver configuration shared across every klu_native submodule — mirrors vendor/suitesparse/KLU/Include/ klu_internal.h’s EMPTY/FLIP/UNFLIP (identical, by inspection, to AMD/Include/amd_internal.h’s and BTF/Include/btf.h’s own BTF_FLIP/BTF_UNFLIP/BTF_ISFLIPPED) and KLU/Source/klu_defaults.c’s KLU_common defaults.

Ported deliberately literally, not “idiomatized” into an Option/enum at this layer — lpivot’s diagonal-preference bookkeeping (kernel.rs, landing in a later phase) reads Pinv[diagrow] < 0 directly and recovers FLIP(Pinv[pivrow]) to reroute it, and BTF’s Q uses the same encoding for unmatched columns. This is exactly the kind of index bookkeeping where block_sparse.rs’s adj.row/adj.col bug happened — silently wrong only on inputs a casual test wouldn’t cover. Conversion to Option<usize>/checked Vec<usize> happens only at each phase’s own public API boundary, once the sentinel-form algorithm is done with it.

Structs§

Options
Fixed solver configuration, mirroring the specific KLU_common fields sparse_klu.rs::new_common() (via klu_defaults) leaves at their defaults — confirmed directly from KLU/Source/klu_defaults.c — and that this port’s algorithm actually consumes. Kept as a struct (not bare constants) so differential tests (#[cfg(all(test, feature = "klu"))], comparing against the vendored C oracle) can vary tol/scale without touching any production code path, which always uses Options::default().

Constants§

EMPTY
Sentinel for “not yet assigned” — matches every one of the three ported packages’ own #define EMPTY (-1) (confirmed identical across KLU/Include/klu_internal.h:77, AMD/Include/amd_internal.h:71,93, and implicitly in BTF/Include/btf.h’s BTF_ISFLIPPED/BTF_UNFLIP, which treat -1 the same way).

Functions§

flip
“Negation about -1”: marks an otherwise-non-negative index as “flipped” (BTF uses this for unmatched columns; KLU’s lpivot uses it to encode a row’s earlier diagonal preference once that row has been claimed by a different column). flip(flip(j)) == j for all j, and flip(EMPTY) == EMPTY. Matches klu_internal.h:78’s FLIP / amd_internal.h:72’s FLIP / btf.h’s BTF_FLIP exactly (all three upstream definitions are identical: -(j)-2).
is_flipped
true iff i is currently in “flipped” form (i < EMPTY). Matches klu_internal.h’s implicit UNFLIP condition / btf.h’s BTF_ISFLIPPED exactly.
unflip
Recovers the original non-negative index whether or not i is currently flipped — a no-op if it wasn’t. Matches klu_internal.h:79’s UNFLIP / amd_internal.h:73’s UNFLIP / btf.h’s BTF_UNFLIP exactly.