...

/

LU Matrix Factorization

LU Matrix Factorization

Learn how to do LU matrix factorization of matrices using R, Rcpp, Armadillo, and Eigen.

What is LU factorization?

An LU factorization refers to the factorization of a square matrix 𝐴𝐴, with proper row and/or column orderings or permutations, into two factors:

  • A lower triangular matrix 𝐿𝐿
  • An upper triangular matrix π‘ˆπ‘ˆ

𝐴=πΏπ‘ˆπ΄ = πΏπ‘ˆ

Press + to interact
A <- matrix(c(1, -1, 2, 2),
nrow = 2,
byrow = TRUE)
fA <- LU(A = A) # compute the LU factorization of A
A_ <- fA$P%*%fA$L%*%fA$U # retrieve the original matrix A by multiplying all factors
fA
A_

Explanation

The resulting LU factors are:

fA <- LU(A = A)

P, L, U factors

P=[1001]    L=[1021]    U=[1βˆ’104] P= \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \space\space\space\space L= \begin{bmatrix} 1 & 0 \\ 2 & 1 \end{bmatrix} \space\space\space\space U= \begin{bmatrix} 1 & -1 \\ 0 & 4 \end{bmatrix} ...