a <- matrix(c(3,2,6,17,4,18,10,-2,-12), ncol = 3)
z <- lu(a)
z # information of LU factorization
# computing det(a)
prod(diag(z$lu)) # product of diagonal elements of U
# solve linear equations
b <- matrix(1:6, ncol = 2)
solve(z, b)
Run the code above in your browser using DataLab