The lu function in R uses a partial (in-line) rotation. You did not provide the original matrix with your example, so I will create a new example for demonstration.
The function lu in R computes A = PLU, which is equivalent to calculating the LU decomposition of the matrix A with its own rows swapped by the permutation matrix P -1 : P - 1 A = LU. See the Matrix documentation for more information.
Example
> A <- matrix(c(1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1), 4) > A [,1] [,2] [,3] [,4] [1,] 1 1 1 1 [2,] 1 1 -1 -1 [3,] 1 -1 -1 1 [4,] 1 -1 1 -1
Here is the coefficient L :
> luDec <- lu(A) > L <- expand(luDec)$L > L 4 x 4 Matrix of class "dtrMatrix" (unitriangular) [,1] [,2] [,3] [,4] [1,] 1 . . . [2,] 1 1 . . [3,] 1 0 1 . [4,] 1 1 -1 1
Here is the coefficient U :
> U <- expand(luDec)$U > U 4 x 4 Matrix of class "dtrMatrix" [,1] [,2] [,3] [,4] [1,] 1 1 1 1 [2,] . -2 -2 0 [3,] . . -2 -2 [4,] . . . -4
Here is the permutation matrix:
> P <- expand(luDec)$P > P 4 x 4 sparse Matrix of class "pMatrix" [1,] | . . . [2,] . . | . [3,] . | . . [4,] . . . |
We can see that lu is a string-permutation version of A :
> L %*% U 4 x 4 Matrix of class "dgeMatrix" [,1] [,2] [,3] [,4] [1,] 1 1 1 1 [2,] 1 -1 -1 1 [3,] 1 1 -1 -1 [4,] 1 -1 1 -1
Returning to the original identifier A = PLU, we can restore A (compare with A above):
> P %*% L %*% U 4 x 4 Matrix of class "dgeMatrix" [,1] [,2] [,3] [,4] [1,] 1 1 1 1 [2,] 1 1 -1 -1 [3,] 1 -1 -1 1 [4,] 1 -1 1 -1