PyBAMMSolvers
raw JSON → 0.8.1 verified Fri May 01 auth: no python
Python interface for the IDAKLU solver for block algebraic multigrid methods. Current version 0.8.1, requires Python >=3.10,<3.15. Development is active with occasional releases.
pip install pybammsolvers Common errors
error ModuleNotFoundError: No module named 'idaklu' ↓
cause Importing the solver directly without the package prefix.
fix
Use 'from pybammsolvers import idaklu' instead of 'import idaklu'.
error TypeError: idaklu() missing 2 required positional arguments: 'A' and 'b' ↓
cause Calling idaklu with only one argument or with keyword arguments incorrectly.
fix
Call idaklu(A, b) with the matrix first, right-hand side second.
Warnings
gotcha The idaklu function expects the matrix A in CSR or CSC format. Dense arrays will fail or produce incorrect results. ↓
fix Convert to scipy.sparse.csr_matrix before passing to idaklu.
gotcha The solver may not converge for indefinite matrices; it is designed for SPD-like systems. ↓
fix Ensure the matrix is symmetric positive definite or at least positive real.
deprecated The function signature changed between 0.7.x and 0.8.x: previously the order of arguments was (A, b, ...) but now also supports additional options as keyword arguments. ↓
fix Review call signature: idaklu(A, b, reorder=1) works for basic usage.
Imports
- idaklu wrong
import idaklucorrectfrom pybammsolvers import idaklu
Quickstart
import numpy as np
from scipy.sparse import csr_matrix
from pybammsolvers import idaklu
# Create a simple sparse matrix (CSR format)
n = 100
A = csr_matrix(np.random.rand(n, n) + 10 * np.eye(n))
b = np.random.rand(n)
# Solve using IDAKLU
x = idaklu(A, b)
print(x[:5])