Challenge: LU Matrix Factorization

Solve this challenge on LU matrix factorization in R.

We'll cover the following

Exercise

Write the R code required to LU factorize this square matrix:

A=[023501142]A = \begin{bmatrix} 0 & 2 & 3 \\ 5 & 0 & 1 \\ 1 & 4 & -2 \\ \end{bmatrix}

Sample input

This is what the sample input looks like:

c(0, 5, 1, 2, 0, 4, 3, 1, -2)

Expected output

The expected output looks like this:

$P
     [,1] [,2] [,3]
[1,]    0    1    0
[2,]    1    0    0
[3,]    0    0    1

$L
     [,1] [,2] [,3]
[1,]  1.0    0    0
[2,]  0.0    1    0
[3,]  0.2    2    1

$U
     [,1] [,2] [,3]
[1,]    5    0  1.0
[2,]    0    2  3.0
[3,]    0    0 -8.2

Use the code editor below to implement your solution.

Get hands-on with 1200+ tech skills courses.