API reference#

Generated from the docstrings of the compiled module. Most functions are overloaded once per element type; the signatures list every overload.

Containers and conversion#

vector

Overloaded function.

matrix

Overloaded function.

convert

Overloaded function.

dtypes

Element dtypes accepted by convert() and the mixed-precision operations.

DenseVector_f64

DenseMatrix_f64

mtl5.DenseVector and mtl5.DenseMatrix are aliases of the float64 classes above. Every other element type has the same pair of classes with a different suffix, such as DenseMatrix_posit16. mtl5.dtypes() lists the suffixes.

Dense linear algebra#

dot

Overloaded function.

norm

Overloaded function.

matmul

Overloaded function.

matvec

Matrix-vector multiplication: y = A @ x

solve

Overloaded function.

lu

Overloaded function.

qr

Householder QR of a tall-or-square matrix (num_rows >= num_cols).

cholesky

Cholesky factorization A = L L^T of a symmetric positive definite matrix.

ldlt

LDL^T factorization of a symmetric matrix.

svd

Singular value decomposition, returned as (U, s, V) with s the vector of singular values (NumPy's convention, not MTL5's diagonal matrix)

eig

Eigenvalues and right eigenvectors of a general square matrix, as (w, V) complex arrays with V's columns the eigenvectors

eigh

Eigenvalues and eigenvectors of a symmetric matrix, as (w, Q) with A = Q diag(w) Q^T

inv

Overloaded function.

det

Compute the determinant of a matrix via LU factorization.

condition_number

2-norm condition number sigma_max/sigma_min via SVD.

Sparse matrices and direct solvers#

csr_matrix

Construct an MTL5 CSR sparse matrix directly from the three CSR arrays.

coo_matrix

Construct an MTL5 COO matrix from scipy-style (row, col, data) triplets.

from_scipy

Convert a scipy.sparse matrix (any format) to an MTL5 SparseMatrix.

to_scipy

Convert an MTL5 sparse matrix back to scipy.sparse.

splu

LU-factorize a square sparse matrix (Gilbert-Peierls, threshold pivoting).

klu

Factor a square sparse matrix with native KLU.

cholesky

Cholesky factorization A = L L^T of a symmetric positive definite matrix.

ldlt

LDL^T factorization of a symmetric matrix.

qr

Householder QR for sparse linear least squares.

supernodal_lu

Supernodal LU: columns grouped into supernodes, applied as dense blocks.

supernodal_ldlt

Supernodal LDL^T of a symmetric matrix, using dense block updates.

orderings

Fill-reducing orderings accepted by the sparse factorizations

ordering

Return a fill-reducing permutation of A as an int64 array.

amd

Approximate minimum degree ordering on the pattern of A + A^T.

colamd

Column approximate minimum degree ordering on the pattern of A^T A.

rcm

Reverse Cuthill-McKee (bandwidth-reducing) ordering.

nested_dissection

Nested dissection ordering on the pattern of A + A^T.

SparseLU_f64

SupernodalLU_f64

SparseCholesky_f64

SparseLDLT_f64

SupernodalLDLT_f64

SparseQR_f64

KLU_f64

Sparse iterative solvers#

cg

Conjugate Gradient, for symmetric positive definite systems.

gmres

GMRES with restarts, for general non-symmetric systems.

bicgstab

BiCGSTAB, for general non-symmetric systems.

minres

MINRES, for symmetric systems that may be indefinite — where CG does not apply.

iterative_solve

Solve A @ x = b with any of the Krylov solvers in solvers().

ilu0

Incomplete LU factorization with no fill-in.

ic0

Incomplete Cholesky factorization with no fill-in (SPD matrices only).

ilut

Incomplete LU with a drop threshold tau and at most fill entries kept per row — more accurate than ILU(0), and more expensive.

Mixed precision#

iterative_refine

Overloaded function.

lu_iterative_refine

Solve A x = b by factoring in working precision and refining with a float64 residual.

dot

Overloaded function.

matmul

Overloaded function.

accumulators

Accumulators available for an element dtype (None is always valid and means 'accumulate in the element precision')

Input and output#

mm_read

Read a Matrix Market file into a sparse (CSR) matrix.

mm_write

Write a dense matrix in Matrix Market array format.

spy

Binary non-zero pattern as a grayscale PNG (MATLAB spy).

spy_magnitude

Colour each non-zero by |value| — where the mass is, not just the pattern.

spy_density

Colour each pixel by how many non-zeros landed in it.