# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.algebra.linear.matrix.doubles.factorization.gaussianelimination

## Class GaussianElimination

• java.lang.Object
• com.numericalmethod.suanshu.algebra.linear.matrix.doubles.factorization.gaussianelimination.GaussianElimination

• public class GaussianElimination
extends Object
The Gaussian elimination performs elementary row operations to reduce a matrix to the row echelon form. The two elementary row operations are: swapping rows, and adding multiples of a row to another row. This is equivalent to multiplying the original matrix with invertible matrices from the left. For a square matrix, this algorithm essentially computes an LU decomposition. We have,

T * A == U

where T is the transformation matrix, U is in the row echelon form. And,

P * A == L * U

where P is the permutation matrix, U is lower triangular, U is in the row echelon form.
• ### Constructor Summary

Constructors
Constructor and Description
GaussianElimination(Matrix A)
Run the Gaussian elimination algorithm with partial pivoting.
GaussianElimination(Matrix A, boolean usePivoting, double epsilon)
Run the Gaussian elimination algorithm.
• ### Method Summary

All Methods
Modifier and Type Method and Description
Matrix L()
Get the lower triangular matrix L, such that P * A = L * U.
PermutationMatrix P()
Get the permutation matrix, P, such that P * A = L * U.
Matrix T()
Get the transformation matrix, T, such that T * A = U.
Matrix U()
Get the upper triangular matrix, U, such that T * A = U and P * A = L * U.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### GaussianElimination

public GaussianElimination(Matrix A,
boolean usePivoting,
double epsilon)
Run the Gaussian elimination algorithm.
Parameters:
A - a matrix
usePivoting - true if to use partial pivoting, e.g., for numerical stability. In general, no pivoting means no row interchanges. It can be done only if Gaussian elimination never runs into zeros on the diagonal. Since division by zero is a fatal error we usually avoid no pivoting.
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
• #### GaussianElimination

public GaussianElimination(Matrix A)
Run the Gaussian elimination algorithm with partial pivoting.
Parameters:
A - a matrix
• ### Method Detail

• #### T

public Matrix T()
Get the transformation matrix, T, such that T * A = U.
Returns:
T
• #### U

public Matrix U()
Get the upper triangular matrix, U, such that T * A = U and P * A = L * U.
Returns:
U
• #### L

public Matrix L()
Get the lower triangular matrix L, such that P * A = L * U.
Returns:
L
• #### P

public PermutationMatrix P()
Get the permutation matrix, P, such that P * A = L * U.
Returns:
P