lu {Matrix}R Documentation

Triangular Decomposition of a Square Matrix

Description

Computes triangular decompositions of square matrices.

Usage

lu(x, ...)

Arguments

x a matrix. No missing values or IEEE special values are allowed.
... further arguments passed to or from other methods.

Details

This is a generic function with special methods for different types of matrices. Use showMethods("lu") to list all the methods for the lu generic.

The method for class dgeMatrix is based on LAPACK's "dgetrf" subroutine.

The method for class dgCMatrix of sparse matrices is based on functions from the CSparse library.

Value

an object of class "LU", i.e., "denseLU" or "sparseLU", see sparseLU; this is a representation of a triangular decomposition of x.

References

Golub, G., and Van Loan, C. F. (1989). Matrix Computations, 2nd edition, Johns Hopkins, Baltimore.

Tim Davis (2005) http://www.cise.ufl.edu/research/sparse/CSparse/

Timothy A. Davis (2006) Direct Methods for Sparse Linear Systems, SIAM Series “Fundamentals of Algorithms”.

See Also

Class definitions LU and sparseLU and function expand; qr, chol.

Examples

x <- Matrix(rnorm(9), 3, 3)
lu(x)
pm <- as(readMM(system.file("external/pores_1.mtx",
                            package = "Matrix")),
         "CsparseMatrix")
str(pmLU <- lu(pm))             # p is a 0-based permutation of the rows
                                # q is a 0-based permutation of the columns
## permute rows and columns of original matrix
ppm <- pm[pmLU@p + 1:1, pmLU@q + 1:1]
ppm[1:14, 1:5]
(pmLU@L %*% pmLU@U)[1:14, 1:5]  # product can have extra zeros

[Package Matrix version 0.9975-6 Index]