Unpacks the LU decomposition returned by lu_factor()
into the P, L, U matrices.
See also
lu()
returns the matrices from the LU decomposition. Its gradient formula is more efficient than that of doing lu_factor()
followed by lu_unpack()
.
LU_data (Tensor) – the packed LU factorization data
LU_pivots (Tensor) – the packed LU factorization pivots
unpack_data (bool) – flag indicating if the data should be unpacked. If False
, then the returned L
and U
are empty tensors. Default: True
unpack_pivots (bool) – flag indicating if the pivots should be unpacked into a permutation matrix P
. If False
, then the returned P
is an empty tensor. Default: True
out (tuple, optional) – output tuple of three tensors. Ignored if None.
A namedtuple (P, L, U)
Examples:
>>> A = torch.randn(2, 3, 3) >>> LU, pivots = torch.linalg.lu_factor(A) >>> P, L, U = torch.lu_unpack(LU, pivots) >>> # We can recover A from the factorization >>> A_ = P @ L @ U >>> torch.allclose(A, A_) True >>> # LU factorization of a rectangular matrix: >>> A = torch.randn(2, 3, 2) >>> LU, pivots = torch.linalg.lu_factor(A) >>> P, L, U = torch.lu_unpack(LU, pivots) >>> # P, L, U are the same as returned by linalg.lu >>> P_, L_, U_ = torch.linalg.lu(A) >>> torch.allclose(P, P_) and torch.allclose(L, L_) and torch.allclose(U, U_) True
Access comprehensive developer documentation for PyTorch
View Docs TutorialsGet in-depth tutorials for beginners and advanced developers
View Tutorials ResourcesFind development resources and get your questions answered
View ResourcesRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4