Skip to contents

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.

Usage

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,.,.) = 
#>  -0.9324 -0.2079 -0.0197
#>   0.1535 -1.4158  1.6404
#>   0.0772 -0.0395  1.5356
#> 
#> (2,.,.) = 
#>   1.3423  1.5462  0.6052
#>  -0.3469  2.3843 -0.5383
#>   0.0427 -0.4357 -0.0166
#> [ CPUFloatType{2,3,3} ]
#> 
#> [[2]]
#> torch_tensor
#>  2  3  3
#>  3  2  3
#> [ CPUIntType{2,3} ]
#>