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, and A’s scalar type must be float32 or float64. A non-symmetric block is zero-safe (becomes identity); a symmetric but non-positive-definite block is not (undefined, per warp.tile_cholesky()).

    • "id": Identity (null) preconditioner

    All "block_jacobi*" variants require A to be a square warp.sparse.BsrMatrix with square blocks, and fall back to "diag" for 1x1-block (CSR) matrices.

Returns:

A LinearOperator applying the requested preconditioner, or None for ptype="id".

Raises:

ValueErrorptype is not one of the supported values, a "block_jacobi*" ptype is requested with a non-warp.sparse.BsrMatrix A, one that isn’t square, or one whose blocks aren’t square; or ptype="block_jacobi_tile" is requested with an A whose scalar type isn’t float32/float64.

Return type:

LinearOperator