Learn R Programming

fastmatrix (version 0.5-7721)

lu: The LU factorization of a square matrix

Description

lu computes the LU factorization of a matrix.

Usage

lu(x)
# S3 method for default
lu(x)

# S3 method for lu solve(a, b, ...)

is.lu(x)

Value

The LU factorization of the matrix as computed by LAPACK. The components in the returned value correspond directly to the values returned by DGETRF.

lu

a matrix with the same dimensions as x. The upper triangle contains the \(\bold{U}\) of the decomposition and the strict lower triangle contains information on the \(\bold{L}\) of the factorization.

pivot

information on the pivoting strategy used during the factorization.

Arguments

x

a square numeric matrix whose LU factorization is to be computed.

a

an LU factorization of a square matrix.

b

a vector or matrix of right-hand sides of equations.

...

further arguments passed to or from other methods

Details

The LU factorization plays an important role in many numerical procedures. In particular it is the basic method to solve the equation \(\bold{Ax} = \bold{b}\) for given matrix \(\bold{A}\), and vector \(\bold{b}\).

solve.lu is the method for solve for lu objects.

is.lu returns TRUE if x is a list and inherits from "lu".

Unsuccessful results from the underlying LAPACK code will result in an error giving a positive error code: these can only be interpreted by detailed study of the Fortran code.

References

Anderson. E., Bai, Z., Bischof, C., Blackford, S., Demmel, J., Dongarra, J., Du Croz, J., Greenbaum, A., Hammarling, S., McKenney, A. Sorensen, D. (1999). LAPACK Users' Guide, 3rd Edition. SIAM.

Golub, G.H., Van Loan, C.F. (1996). Matrix Computations, 3rd Edition. John Hopkins University Press.

See Also

extractL, extractU, constructX for reconstruction of the matrices, lu2inv

Examples

Run this code
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