SciPy

scipy.sparse.linalg.spsolve_triangular

scipy.sparse.linalg.spsolve_triangular(A, b, lower=True, overwrite_A=False, overwrite_b=False)[source]

Solve the equation A x = b for x, assuming A is a triangular matrix.

Parameters:

A : (M, M) sparse matrix

A sparse square triangular matrix. Should be in CSR format.

b : (M,) or (M, N) array_like

Right-hand side matrix in A x = b

lower : bool, optional

Whether A is a lower or upper triangular matrix. Default is lower triangular matrix.

overwrite_A : bool, optional

Allow changing A. The indices of A are going to be sorted and zero entries are going to be removed. Enabling gives a performance gain. Default is False.

overwrite_b : bool, optional

Allow overwriting data in b. Enabling gives a performance gain. Default is False.

Returns:

x : (M,) or (M, N) ndarray

Solution to the system A x = b. Shape of return matches shape of b.

Raises:

LinAlgError

If A is singular or not triangular.

ValueError

If shape of A or shape of b do not match the requirements.

Notes

New in version 0.19.0.