Computes the LU factorization of a matrix or batches of matrices A. Returns a tuple containing the LU factorization and pivots of A. Pivoting is done if pivot is set to True.

torch_lu(A, pivot = TRUE, get_infos = FALSE, out = NULL)

Arguments

A

(Tensor) the tensor to factor of size (, m, n)(,m,n)

pivot

(bool, optional) – controls whether pivoting is done. Default: TRUE

get_infos

(bool, optional) – if set to True, returns an info IntTensor. Default: FALSE

out

(tuple, optional) – optional output tuple. If get_infos is True, then the elements in the tuple are Tensor, IntTensor, and IntTensor. If get_infos is False, then the elements in the tuple are Tensor, IntTensor. Default: NULL

Examples

if (torch_is_installed()) { A = torch_randn(c(2, 3, 3)) torch_lu(A) }
#> [[1]] #> torch_tensor #> (1,.,.) = #> -1.9975 -0.0988 1.4241 #> -0.2641 2.0836 -0.5751 #> 0.4134 0.3229 -0.5267 #> #> (2,.,.) = #> 0.9759 0.5061 -0.8058 #> -0.1225 1.0351 2.4615 #> 0.3408 -0.0359 0.1193 #> [ CPUFloatType{2,3,3} ] #> #> [[2]] #> torch_tensor #> 3 2 3 #> 2 2 3 #> [ CPUIntType{2,3} ] #>