Computes the partial-pivoted LU decomposition of a matrix operand:
$$P A = L U,$$
where \(P\) is a permutation matrix, \(L\) is unit lower
triangular, and \(U\) is upper triangular.
This function returns L and U as separate matrices.
Use prim_lu() to get them in packed LU form.
Arguments
- operand
(
arrayish)
Matrix of data type floating-point with exactly 2 dimensions.
Value
Named list:
L– unit lower-triangular factor of shape(m, k), where(m, n) = shape(operand)andk = min(m, n).U– upper-triangular factor of shape(k, n).pivots– lengthk, dtypei32. LAPACK-style sequential 1-based row swaps as returned bygetrf.permutation– lengthm, dtypei32. A 1-based permutation vector representing \(P\).
Examples
x <- nv_matrix(c(4, 3, 6, 3), nrow = 2, dtype = "f64")
nv_lu(x)
#> $L
#> AnvlArray
#> 1.0000 0.0000
#> 0.7500 1.0000
#> [ CPUf64{2,2} ]
#>
#> $U
#> AnvlArray
#> 4.0000 6.0000
#> 0.0000 -1.5000
#> [ CPUf64{2,2} ]
#>
#> $pivots
#> AnvlArray
#> 1
#> 2
#> [ CPUi32{2} ]
#>
#> $permutation
#> AnvlArray
#> 1
#> 2
#> [ CPUi32{2} ]
#>