public class LinearEquationSystem
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private double[][] |
coeff
The matrix of coefficients.
|
private int[] |
col
Encodes column permutations, column j is at position col[j].
|
private static double |
DELTA
A small number to handle numbers near 0 as 0.
|
private static Logging |
LOG
Logger.
|
private int |
rank
The rank of the coefficient matrix.
|
private boolean |
reducedRowEchelonForm
Indicates if linear equation system is in reduced row echelon form.
|
private double[] |
rhs
The right hand side of the equation system.
|
private int[] |
row
Encodes row permutations, row i is at position row[i].
|
private boolean |
solvable
Indicates if linear equation system is solvable.
|
private boolean |
solved
Indicates if solvability has been checked.
|
private static int |
TOTAL_PIVOT_SEARCH
Indicates total pivot search strategy.
|
private static int |
TRIVAL_PIVOT_SEARCH
Indicates trivial pivot search strategy.
|
private double[][] |
u
Holds the space of solutions of the homogeneous linear equation system.
|
private double[] |
x_0
Holds the special solution vector.
|
Constructor and Description |
---|
LinearEquationSystem(double[][] a,
double[] b)
Constructs a linear equation system with given coefficient matrix
a and right hand side b . |
LinearEquationSystem(double[][] a,
double[] b,
int[] rowPermutations,
int[] columnPermutations)
Constructs a linear equation system with given coefficient matrix
a and right hand side b . |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
equationsToString(int fractionDigits)
Returns a string representation of this equation system.
|
java.lang.String |
equationsToString(java.text.NumberFormat nf)
Returns a string representation of this equation system.
|
java.lang.String |
equationsToString(java.lang.String prefix,
int fractionDigits)
Returns a string representation of this equation system.
|
java.lang.String |
equationsToString(java.lang.String prefix,
java.text.NumberFormat nf)
Returns a string representation of this equation system.
|
private void |
format(java.text.NumberFormat nf,
java.lang.StringBuilder buffer,
double value,
int maxIntegerDigits)
Helper method for output of equations and solution.
|
double[][] |
getCoefficents()
Returns a copy of the coefficient array of this linear equation system.
|
int[] |
getColumnPermutations()
Returns a copy of the column permutations, column i is at position
column[i].
|
double[] |
getRHS()
Returns a copy of the right hand side of this linear equation system.
|
int[] |
getRowPermutations()
Returns a copy of the row permutations, row i is at position row[i].
|
private int |
integerDigits(double d)
Returns the integer digits of the specified double value.
|
boolean |
isSolvable()
Checks if a solved system is solvable.
|
private boolean |
isSolvable(int method)
Checks solvability of this linear equation system with the chosen method.
|
boolean |
isSolved()
Tests if system has already been tested for solvability.
|
private int |
maxIntegerDigits(double[] values)
Returns the maximum integer digits of the specified values.
|
private int[] |
maxIntegerDigits(double[][] values)
Returns the maximum integer digits in each column of the specified values.
|
private IntIntPair |
nonZeroPivotSearch(int k)
Method for trivial pivot search, searches for non-zero entry.
|
private void |
permutePivot(IntIntPair pos1,
IntIntPair pos2)
permutes two matrix rows and two matrix columns
|
private void |
pivotOperation(int k)
performs a pivot operation
|
private void |
reducedRowEchelonForm(int method)
Brings this linear equation system into reduced row echelon form with
choice of pivot method.
|
java.lang.String |
solutionToString(int fractionDigits)
Returns a string representation of the solution of this equation system.
|
private void |
solve(int method)
solves linear system with the chosen method
|
void |
solveByTotalPivotSearch()
Solves this linear equation system by total pivot search.
|
void |
solveByTrivialPivotSearch()
Solves this linear equation system by trivial pivot search.
|
int |
subspacedim()
Return dimensionality of spanned subspace.
|
private IntIntPair |
totalPivotSearch(int k)
Method for total pivot search, searches for x,y in {k,...n}, so that
|a_xy| > |a_ij| |
private static final Logging LOG
private static final double DELTA
private static final int TRIVAL_PIVOT_SEARCH
private static final int TOTAL_PIVOT_SEARCH
private boolean solvable
private boolean solved
private int rank
private double[][] coeff
private double[] rhs
private int[] row
private int[] col
private double[] x_0
private double[][] u
private boolean reducedRowEchelonForm
public LinearEquationSystem(double[][] a, double[] b)
a
and right hand side b
.a
- the matrix of the coefficients of the linear equation systemb
- the right hand side of the linear equation systempublic LinearEquationSystem(double[][] a, double[] b, int[] rowPermutations, int[] columnPermutations)
a
and right hand side b
.a
- the matrix of the coefficients of the linear equation systemb
- the right hand side of the linear equation systemrowPermutations
- the row permutations, row i is at position row[i]columnPermutations
- the column permutations, column i is at position
column[i]public double[][] getCoefficents()
public double[] getRHS()
public int[] getRowPermutations()
public int[] getColumnPermutations()
public boolean isSolved()
public void solveByTotalPivotSearch()
( a_11 ... a_1n ) ( 0 ... a_2n ) ( 0 ... a_ii ... a_in ) ( 0 ... a_(i+1)i ... a_(i+1)n ) ( 0 ... a_ni ... a_nn )Then we search for x,y in {i,...n}, so that
|a_xy| > |a_ij|
public void solveByTrivialPivotSearch()
public boolean isSolvable()
public java.lang.String equationsToString(java.lang.String prefix, int fractionDigits)
prefix
- the prefix of each linefractionDigits
- the number of fraction digits for output accuracypublic java.lang.String equationsToString(java.lang.String prefix, java.text.NumberFormat nf)
prefix
- the prefix of each linenf
- the number formatpublic java.lang.String equationsToString(java.text.NumberFormat nf)
nf
- the number formatpublic java.lang.String equationsToString(int fractionDigits)
fractionDigits
- the number of fraction digits for output accuracypublic java.lang.String solutionToString(int fractionDigits)
fractionDigits
- precisionprivate void reducedRowEchelonForm(int method)
method
- the pivot search method to useprivate IntIntPair totalPivotSearch(int k)
|a_xy| > |a_ij|
k
- search starts at entry (k,k)private IntIntPair nonZeroPivotSearch(int k)
k
- search starts at entry (k,k)private void permutePivot(IntIntPair pos1, IntIntPair pos2)
pos1
- the fist position for the permutationpos2
- the second position for the permutationprivate void pivotOperation(int k)
k
- pivoting takes place below (k,k)private void solve(int method) throws java.lang.NullPointerException
method
- the pivot search methodjava.lang.NullPointerException
private boolean isSolvable(int method) throws java.lang.NullPointerException
method
- the pivot search methodjava.lang.NullPointerException
private int[] maxIntegerDigits(double[][] values)
values
- the values arrayprivate int maxIntegerDigits(double[] values)
values
- the values arrayprivate int integerDigits(double d)
d
- the double valueprivate void format(java.text.NumberFormat nf, java.lang.StringBuilder buffer, double value, int maxIntegerDigits)
nf
- the number formatbuffer
- the string buffer to append the value tovalue
- the value to appendmaxIntegerDigits
- the maximum number of integer digitspublic int subspacedim()
Copyright © 2019 ELKI Development Team. License information.