warp.optim.linear.preconditioner#
- warp.optim.linear.preconditioner(A, ptype='diag')[source]#
Construct and return a preconditioner for an input matrix.
- Parameters:
A (array | BsrMatrix | LinearOperator) – The matrix for which to build the preconditioner
ptype (str) –
The type of preconditioner. Currently the following values are supported:
"diag": Diagonal (a.k.a. Jacobi) preconditioner"diag_abs": Similar to Jacobi, but using the absolute value of diagonal coefficients"block_jacobi_direct": Block-Jacobi preconditioner that inverts each diagonal block via a dense Householder-QR-based inverse. Zero-safe: a numerically singular block falls back to the identity for that block instead of producing NaNs, mirroring the zero-safe convention of"diag"."block_jacobi_sequential": Block-Jacobi preconditioner that factorizes each diagonal block via a scalar LDL^T factorization. Requires the block to be symmetric positive-definite, but is zero-safe (a non-SPD block becomes identity). Supports any Warp floating scalar type."block_jacobi_tile": Block-Jacobi preconditioner that factorizes each diagonal block via tile-parallel Cholesky (runs on both CPU and GPU). Blocks must be symmetric positive-definite, andA’s scalar type must befloat32orfloat64. A non-symmetric block is zero-safe (becomes identity); a symmetric but non-positive-definite block is not (undefined, perwarp.tile_cholesky())."id": Identity (null) preconditioner
All
"block_jacobi*"variants requireAto be a squarewarp.sparse.BsrMatrixwith square blocks, and fall back to"diag"for 1x1-block (CSR) matrices.
- Returns:
A
LinearOperatorapplying the requested preconditioner, orNoneforptype="id".- Raises:
ValueError –
ptypeis not one of the supported values, a"block_jacobi*"ptypeis requested with a non-warp.sparse.BsrMatrixA, one that isn’t square, or one whose blocks aren’t square; orptype="block_jacobi_tile"is requested with anAwhose scalar type isn’tfloat32/float64.- Return type: