matlib (version 0.9.1)

echelon: Echelon Form of a Matrix

Description

Returns the (reduced) row-echelon form of the matrix A, using gaussianElimination.

Usage

echelon(A, B, reduced = TRUE, ...)

Arguments

A

coefficient matrix

B

right-hand side vector or matrix. If B is a matrix, the result gives solutions for each column as the right-hand side of the equations with coefficients in A.

reduced

logical; should reduced row echelon form be returned? If FALSE a non-reduced row echelon form will be returned

...

other arguments passed to gaussianElimination

Value

the reduced echelon form of X.

Details

When the matrix A is square and non-singular, the reduced row-echelon result will be the identity matrix, while the row-echelon from will be an upper triagle matrix. Otherwise, the result will have some all-zero rows, and the rank of the matrix is the number of not all-zero rows.

Examples

Run this code
# NOT RUN {
A <- matrix(c(2, 1, -1,
             -3, -1, 2,
             -2,  1, 2), 3, 3, byrow=TRUE)
b <- c(8, -11, -3)
echelon(A, b, verbose=TRUE, fractions=TRUE) # reduced row-echelon form
echelon(A, b, reduced=FALSE, verbose=TRUE, fractions=TRUE) # row-echelon form

A <- matrix(c(1,2,3,4,5,6,7,8,10), 3, 3) # a nonsingular matrix
A
echelon(A, reduced=FALSE) # the row-echelon form of A
echelon(A) # the reduced row-echelon form of A

b <- 1:3
echelon(A, b)  # solving the matrix equation Ax = b
echelon(A, diag(3)) # inverting A

B <- matrix(1:9, 3, 3) # a singular matrix
B
echelon(B)
echelon(B, reduced=FALSE)
echelon(B, b)
echelon(B, diag(3))

# }

Run the code above in your browser using DataCamp Workspace