Learn R Programming

comphy (version 1.0.5)

transform_upper: Transform to upper triangular

Description

Transform an \(n\times n\) matrix to upper-triangular form, using a series of row operations.

Usage

transform_upper(M)

Value

The transformed \(n\times n\) or

\(n\times (n+1)\) matrix.

Arguments

M

An \(n\times n\) or \(n\times (n+1)\) matrix.

Details

The algorithm used for the transformation is Gauss elimination, which makes use of row operations. If the input matrix has \(n+1\) columns, the transformed \(n\times (n+1)\) matrix can be used to find the solution of the associated system of linear equations.

Examples

Run this code
# 3X3 matrix
#
# [ 3  1  1
#   1 -1  2
#  -1  1  1]

# Input matrix
A <- matrix(c(3,1,2,1,1,-1,1,1,-1),ncol=3)

# Upper-triangular matrix
U <- transform_upper(A)
print(U)

Run the code above in your browser using DataLab