Learn R Programming

Matrix (version 1.2-8)

LU-class: LU (dense) Matrix Decompositions

Description

The "LU" class is the virtual class of LU decompositions of real matrices. "denseLU" the class of LU decompositions of dense real matrices.

Arguments

Objects from the Class

Objects can be created by calls of the form new("denseLU", ...). More commonly the objects are created explicitly from calls of the form lu(mm) where mm is an object that inherits from the "dgeMatrix" class or as a side-effect of other functions applied to "dgeMatrix" objects.

Extends

"LU" directly extends the virtual class "MatrixFactorization". "denseLU" directly extends "LU".

Slots

Methods

Details

The decomposition is of the form $$A = P L U$$ where typically all matrices are of size $n by n$, and the matrix $P$ is a permutation matrix, $L$ is lower triangular and $U$ is upper triangular (both of class dtrMatrix).

Note that the dense decomposition is also implemented for a $m by n$ matrix $A$, when $m != n$.

If $m < n$ (“wide case”), $U$ is $m by n$, and hence not triangular. If $m > n$ (“long case”), $L$ is $m by n$, and hence not triangular.

See Also

class sparseLU for LU decompositions of sparse matrices; further, class dgeMatrix and functions lu, expand.

Examples

Run this code
set.seed(1)
mm <- Matrix(round(rnorm(9),2), nrow = 3)
mm
str(lum <- lu(mm))
elu <- expand(lum)
elu # three components: "L", "U", and "P", the permutation
elu$L %*% elu$U
(m2 <- with(elu, P %*% L %*% U)) # the same as 'mm'
stopifnot(all.equal(as(mm, "matrix"),
                    as(m2, "matrix")))

Run the code above in your browser using DataLab