Skip to content

ENH: Create bindings for KLU#149

Merged
broesler merged 485 commits into
scikit-sparse:masterfrom
broesler:feature-klu
Feb 11, 2026
Merged

ENH: Create bindings for KLU#149
broesler merged 485 commits into
scikit-sparse:masterfrom
broesler:feature-klu

Conversation

@broesler
Copy link
Copy Markdown
Collaborator

@broesler broesler commented Nov 5, 2025

This PR adds an interface to the SuiteSparse KLU package. It is built on top of the development branch in #145, so it will show many more commits before that is merged.

Remove manual permutation tests from test_cholmod.
Parametrize test_ldlupdown over `order`. Remove `N` argument from
_create_update_matrix.

Some random seeds cause failues on order=None and 'natural'. Unclear
exactly what is causing this issue. The random update matrix we create
likely creates structural issues that aren't resolved by a fill-reducing
permutation. Need to investigate further.
See TODO note on whether we should un-permute the input matrix.
This update makes the CholeskyFactor.resymbol method API identical to
the procedural ldlupdate interface. It is likely more consistent with
how the function will actually be used, where the user has already
permuted the input matrix with the fill-reducing permutation by the time
multiple up/downdates have been computed and a resymbol is needed.
This commit removes the cholmod, ldlsolve, ldlupdate, ldlrowmod, and
resymbol functions, in favor of their counterparts in the CholeskyFactor
object.
Use raw .data pointers in _cholmod_sparse_from_csc and
_cholmod_dense_from_ndarray. This commit removes the unnecessary
memoryviews since we are just passing a pointer, not doing any indexing.
The pointer also works for empty arrays, so we can handle those directly
in the function and not have special cases.
Add more notes to factorize docstring.
These CholeskyFactor properties now return np.ndarrays that are
read-only views on the underlying data.
The factor attribute is assigned in __cinit__ and should *never* be
set to NULL by the cholmod functions to which it is an argument. Only
its internal components are called. We also handle errors immediately
after these functions are called, so CholeskyFactor.factor should never
be NULL after initialization.
This was referenced Nov 5, 2025
Remove the memcpy calls, which also take the pointers.
Use assertions on internal cdef functions. No need to raise ValueErrors
there.
Also do some cython-lint linting.
The value of src.worksize *is* the entire size, so just pass "1" instead
of "sizeof(...)" to _malloc_copy.
This commit allows _malloc_copy to return NULL without error. It also
checks for src/dest.LUsize and src/dest.LUbx are non-NULL before
dereferencing them within the for-loop.
This commit eliminates the need for a separate copy function for
klu_symbolic and klu_l_symbolic, as well as klu_numeric and
klu_l_numeric. It is a bit hacky, since we need an if-statement based on
the input types to generate unreachable code that will be pruned before
compilation, but it works and saves code duplication.
This commit makes the ternary statements much more readable.
@broesler broesler mentioned this pull request Dec 12, 2025
@broesler broesler merged commit 46cd586 into scikit-sparse:master Feb 11, 2026
@broesler broesler deleted the feature-klu branch February 11, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant