edu.princeton.cs.algs4
Class GaussJordanElimination
- java.lang.Object
-
- edu.princeton.cs.algs4.GaussJordanElimination
-
public class GaussJordanElimination extends java.lang.ObjectTheGaussJordanEliminationdata type provides methods to solve a linear system of equations Ax = b, where A is an n-by-n matrix and b is a length n vector. If no solution exists, it finds a solution y to yA = 0, yb ≠ 0, which which serves as a certificate of infeasibility.This implementation uses Gauss-Jordan elimination with partial pivoting. See
GaussianEliminationfor an implementation that uses Gaussian elimination (but does not provide the certificate of infeasibility). For an industrial-strength numerical linear algebra library, see JAMA.For additional documentation, see Section 9.9 Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
-
-
Constructor Summary
Constructors Constructor and Description GaussJordanElimination(double[][] A, double[] b)Solves the linear system of equations Ax = b, where A is an n-by-n matrix and b is a length n vector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description double[]dual()Returns a solution to the linear system of equations yA = 0, yb ≠ 0.booleanisFeasible()Returns true if there exists a solution to the linear system of equations Ax = b.static voidmain(java.lang.String[] args)Unit tests theGaussJordanEliminationdata type.double[]primal()Returns a solution to the linear system of equations Ax = b.
-
-
-
Constructor Detail
-
GaussJordanElimination
public GaussJordanElimination(double[][] A, double[] b)Solves the linear system of equations Ax = b, where A is an n-by-n matrix and b is a length n vector.- Parameters:
A- the n-by-n constraint matrixb- the length n right-hand-side vector
-
-
Method Detail
-
primal
public double[] primal()
Returns a solution to the linear system of equations Ax = b.- Returns:
- a solution x to the linear system of equations
Ax = b;
nullif no such solution
-
dual
public double[] dual()
Returns a solution to the linear system of equations yA = 0, yb ≠ 0.- Returns:
- a solution y to the linear system of equations
yA = 0, yb ≠ 0;
nullif no such solution
-
isFeasible
public boolean isFeasible()
Returns true if there exists a solution to the linear system of equations Ax = b.- Returns:
trueif there exists a solution to the linear system of equations Ax = b;falseotherwise
-
main
public static void main(java.lang.String[] args)
Unit tests theGaussJordanEliminationdata type.- Parameters:
args- the command-line arguments
-
-
DataMelt 3.0 © DataMelt by jWork.ORG