Registry / data / qdldl
library0.1.9.post1pypypi✓ verified 87d ago

QDLDL is a Python wrapper for the QDLDL C library, providing a high-performance LDL factorization routine primarily for sparse matrices. It's designed for use in optimization and numerical methods, particularly for solving symmetric indefinite systems like those arising in KKT matrices. The current version is 0.1.9.post1, with updates released periodically to support newer Python versions, architectures, and upstream C library improvements.

pip install qdldl
INSTALL
IMPORT
SIG · QDLDL
Q
qdldl
datapythonv0.1.9.post1
Install
7.6s avg
Import
Disk
230MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.9.post1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 7.6s · import 0.000s · 227MB
230MB installed
● package 230MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

qdldl
import qdldl
The library is typically imported directly as 'qdldl'.

This quickstart demonstrates how to factorize a sparse symmetric indefinite matrix (e.g., a KKT matrix) using `qdldl.qdldl` and then solve a linear system with the obtained factors using `qdldl.solve`. It uses `scipy.sparse.csc_matrix` for efficient sparse matrix representation.

import qdldl import numpy as np from scipy.sparse import csc_matrix # Construct a sparse symmetric indefinite matrix, typically a KKT matrix. # K = [ P A.T ] # [ A 0 ] # Example components: P_data = np.array([2.0, 1.0, 1.0, 3.0]) P_row_ind = np.array([0, 0, 1, 1]) P_col_ind = np.array([0, 1, 0, 1]) P = csc_matrix((P_data, (P_row_ind, P_col_ind)), shape=(2, 2)) A_constr_data = np.array([1.0, 1.0, 1.0]) A_constr_row_ind = np.array([0, 1, 1]) A_constr_col_ind = np.array([0, 0, 1]) A_constr = csc_matrix((A_constr_data, (A_constr_row_ind, A_constr_col_ind)), shape=(2, 2)) n_P = P.shape[0] n_A = A_constr.shape[0] n = n_P + n_A # Build the full KKT matrix KKT = csc_matrix( (n, n), dtype=P.dtype ) KKT[:n_P, :n_P] = P KKT[:n_P, n_P:] = A_constr.T KKT[n_P:, :n_P] = A_constr # The 'd' argument for qdldl.qdldl is a user-defined initial diagonal for pivoting. # A common choice is a vector of ones. d = np.ones(n) # Perform LDL factorization # L_factor is a csc_matrix (lower triangular factor), # D_diag is a numpy array (diagonal of D), # P_vec is a numpy array (permutation vector). L_factor, D_diag, P_vec = qdldl.qdldl(KKT, d) # Solve a system KKT @ x = b b = np.array([10.0, 20.0, 5.0, 8.0]) # Example right-hand side # Use the qdldl.solve function to get the solution x x = qdldl.solve(L_factor, D_diag, P_vec, b) print("Input KKT matrix (dense representation for display):\n", KKT.toarray()) print("Right-hand side b:\n", b) print("Solution x:\n", x) # Verify the solution print("KKT @ x:\n", KKT @ x) print("Error (KKT @ x - b):\n", KKT @ x - b) assert np.allclose(KKT @ x, b, atol=1e-9) print("Solution verified.")
Debug
Known issues
gotchaOlder versions of `qdldl` (pre-0.1.7.post4) may not be compatible with NumPy 2.0 due to breaking changes in NumPy's API, potentially leading to build failures or runtime errors.
fix
Upgrade `qdldl` to `0.1.7.post4` or newer: `pip install --upgrade qdldl`.
affects: <0.1.7.post4
gotchaQDLDL is specifically optimized for sparse matrices and expects input matrices to be in the Compressed Sparse Column (CSC) format for optimal performance and correctness.
fix
Ensure input matrices are in CSC format. If starting from another sparse format (e.g., CSR), convert using `matrix.tocsc()`.
affects: All
gotchaCompatibility with newer Python versions is added incrementally. For example, version `0.1.9` added support for Python 3.14. Using an older `qdldl` with a very new Python interpreter, or vice-versa, might lead to installation issues or unexpected behavior.
fix
Consult the `qdldl` release notes on GitHub for specific Python version compatibility. Ensure your Python environment is supported by the installed `qdldl` version, or upgrade `qdldl`.
affects: Specific older `qdldl` versions with very new Python interpreters, or vice-versa.
gotchaThe underlying C library of QDLDL uses `double` precision floating-point numbers. Users should be aware of potential floating-point inaccuracies inherent in numerical computations, especially when dealing with ill-conditioned matrices.
fix
Consider the numerical stability of your problem and input data. For ill-conditioned systems, preconditioning or alternative solvers may be necessary.
affects: All
Errors
Common errors & fixes
ERROR: Could not find a version that satisfies the requirement qdldl
`pip` could not find a pre-built binary wheel for your specific Python version, operating system, and architecture, and failed to build the package from source due to missing C/C++ compilers or other build dependencies.
fix
Ensure `pip` and `setuptools` are up-to-date (`pip install --upgrade pip setuptools`). On Windows, install Microsoft Visual C++ Build Tools (e.g., from Visual Studio Installer). On Linux/macOS, ensure a C compiler (like `gcc` or `clang`) is installed. Consider using a `conda` environment if `pip` wheels are consistently unavailable.
ModuleNotFoundError: No module named 'qdldl'
The `qdldl` package is either not installed in your current Python environment or the Python interpreter you are running does not have access to the installed package.
fix
First, ensure `qdldl` is installed in your active environment by running `pip install qdldl`. If you've already installed it, verify that you are running your script with the same Python interpreter where the package was installed (e.g., check `which python` and `which pip` in your terminal).
AttributeError: 'numpy.ndarray' object has no attribute 'indptr'
The `qdldl.factor()` function expects input matrices (`P`, `A`) to be sparse matrices, specifically in `scipy.sparse.csc_matrix` format, but you provided a dense NumPy array or another sparse format that lacks the `indptr` (and `data`, `indices`) attributes specific to CSC/CSR matrices.
fix
Convert your input matrix to `scipy.sparse.csc_matrix` format before passing it to `qdldl.factor()`. Example: `from scipy.sparse import csc_matrix; P_sparse = csc_matrix(P_dense)`.
ValueError: Matrix factorization failed.
The underlying QDLDL C library encountered a numerical issue or an invalid matrix property during the factorization process, indicating that the input matrices are problematic for LDL factorization (e.g., singular, ill-conditioned, or not satisfying specific requirements for the problem being solved).
fix
Examine the properties of your input matrices (`P` and `A`). Ensure `P` is positive semi-definite on the null space of `A`. Check for singularity, extreme ill-conditioning, or other numerical instabilities. You might need to add a small regularization term (e.g., to the diagonal of `P`) or pre-condition your system.
Upgrade
Version history
0.1.9.post1latest on PyPI · released Feb 19, 2026
Audit
Dependencies
numpyrequiredRequired for numerical operations and array handling.
scipyrequiredUsed for sparse matrix creation (csc_matrix) in common workflows and examples.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
qdldl — pip install qdldl · libregistry