scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
lu_factor(a, overwrite_a=False, check_finite=True)

The decomposition is:

A = P L U

where P is a permutation matrix, L lower triangular with unit diagonal elements, and U upper triangular.

Notes

This is a wrapper to the *GETRF routines from LAPACK.

Parameters

a : (M, M) array_like

Matrix to decompose

overwrite_a : bool, optional

Whether to overwrite data in A (may increase performance)

check_finite : bool, optional

Whether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns

lu : (N, N) ndarray

Matrix containing U in its upper triangle, and L in its lower triangle. The unit diagonal elements of L are not stored.

piv : (N,) ndarray

Pivot indices representing the permutation matrix P: row i of matrix was interchanged with row piv[i].

Compute pivoted LU decomposition of a matrix.

See Also

lu_solve

solve an equation system using the LU factorization of a matrix

Examples

>>> from scipy.linalg import lu_factor
... A = np.array([[2, 5, 8, 7], [5, 2, 2, 8], [7, 5, 6, 6], [5, 4, 4, 8]])
... lu, piv = lu_factor(A)
... piv array([2, 2, 3, 3], dtype=int32)

Convert LAPACK's piv array to NumPy index and test the permutation

>>> piv_py = [2, 0, 3, 1]
... L, U = np.tril(lu, k=-1) + np.eye(4), np.triu(lu)
... np.allclose(A[piv_py] - L @ U, np.zeros((4, 4))) True
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.linalg._decomp_lu.lu_solve scipy.linalg._decomp_lu.lu_factor

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/linalg/_decomp_lu.py#15
type: <class 'function'>
Commit: