mindspore.ops.lu_unpack
- mindspore.ops.lu_unpack(LU_data, LU_pivots, unpack_data=True, unpack_pivots=True)[source]
Unpack the LU decomposition returned by
mindspore.scipy.linalg.lu_factor()
into the P, L, U matrices.Note
LU_data of shape
, LU_pivots of shape , where is batch dimensions.
- Parameters
LU_data (Tensor) – The packed LU factorization data, the rank is greater than or equal to 2.
LU_pivots (Tensor) – The packed LU factorization pivots.
unpack_data (bool, optional) – A flag indicating if the LU_data should be unpacked. If
False
, then the returned L and U are None. DefaultTrue
.unpack_pivots (bool, optional) – A flag indicating if the LU_pivots should be unpacked into a permutation matrix P. If
False
, then the returned P is None. DefaultTrue
.
- Returns
Tuple of tensors(Pivots, L, U).
- Supported Platforms:
GPU
CPU
Examples
>>> import mindspore >>> LU_data = mindspore.tensor([[[-0.3806, -0.4872, 0.5536], ... [-0.1287, 0.6508, -0.2396], ... [ 0.2583, 0.5239, 0.6902]], ... [[ 0.6706, -1.1782, 0.4574], ... [-0.6401, -0.4779, 0.6701], ... [ 0.1015, -0.5363, 0.6165]]]) >>> LU_pivots = mindspore.tensor(([[1, 3, 3], [2, 3, 3]]), mindspore.int32) >>> pivots, L, U = mindspore.ops.lu_unpack(LU_data, LU_pivots) >>> print(pivots) [[[1. 0. 0.] [0. 0. 1.] [0. 1. 0.]] [[0. 0. 1.] [1. 0. 0.] [0. 1. 0.]]] >>> print(L) [[[ 1. 0. 0.] [-0.1287 1. 0.] [ 0.2583 0.5239 1.]] [[ 1.0000 0. 0.] [-0.6401 1. 0.] [ 0.1015 -0.5363 1.]]] >>> print(U) [[[-0.3806 -0.4872 0.5536] [ 0. 0.6508 -0.2396] [ 0. 0. 0.6902]] [[ 0.6706 -1.1782 0.4574] [ 0. -0.4779 0.6701] [ 0. 0. 0.6165]]]