# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.algebra.linear.matrix.doubles.linearsystem

## Class LUSolver

• java.lang.Object
• com.numericalmethod.suanshu.algebra.linear.matrix.doubles.linearsystem.LUSolver

• public class LUSolver
extends Object
Use LU decomposition to solve Ax = b where A is square and det(A) != 0. The dimensions of A and b must match. The algorithm goes as follows.

Ax = b;
LUx = PAx = Pb

We first solve Ly = b by forward substitution and then Ux = y by backward substitution.
Wikipedia: Solving linear equations
• ### Constructor Summary

Constructors
Constructor and Description
LUSolver()
• ### Method Summary

All Methods
Modifier and Type Method and Description
Vector solve(LSProblem problem)
Solve Ax = b.
Matrix solve(Matrix A, Matrix B)
Solves AX = B.
• ### Methods inherited from class java.lang.Object

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

• #### LUSolver

public LUSolver()
• ### Method Detail

• #### solve

public Vector solve(LSProblem problem)
Solve Ax = b.
Parameters:
problem - a system of linear equations
Returns:
x a solution such that Ax = b
Throws:
LinearSystemSolver.NoSolution - if there is no solution to the system
• #### solve

public Matrix solve(Matrix A,
Matrix B)
Solves AX = B.
Parameters:
A - the left-hand side coefficient matrix
B - the right-hand side of the equation
Returns:
the solution, X