|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpapaya.LU
public class LU
LU Decomposition.
For an m x n
matrix A
with m > n
, the LU decomposition is an m x n
unit lower triangular matrix L
, an n x n
upper triangular matrix U
,
and a permutation vector piv
of length m
so that A(piv,:) = L*U
;
If m < n
, then L
is m x m
and U
is m x n
.
The LU decomposition with pivoting always exists, even if the matrix is
singular, so the constructor will never fail. The primary use of the
LU decomposition is in the solution of square systems of simultaneous
linear equations. This will fail if isNonsingular()
returns false.
Shamelessly copied (and modified) from the
JAMA Java
Matrix package. To make things compatible with how most users use Processing, the
class take in float matrices. However, to preserve the acccuracy of the computations, the algorithm
first casts the input into a double array, prior to doing anything. All methods also return doubles; Use
Cast.doubleToFloat(double[][])
if you want/need to cast everything back to floats for
further (non-high-accuracy-dependant) processing (pun intended).
Constructor Summary | |
---|---|
LU(float[][] A)
Constructor. |
Method Summary | |
---|---|
double |
det()
Determinant |
float[] |
getFloatPivot()
Return pivot permutation vector as a one-dimensional float array |
double[][] |
getL()
Return lower triangular factor, L . |
int[] |
getPivot()
Return pivot permutation vector |
double[][] |
getU()
Return upper triangular factor, U |
boolean |
isNonsingular()
Is the matrix nonsingular? |
double[][] |
solve(float[][] B)
Solve A*X = B |
double[] |
solve(float[] b,
boolean returnZeroesForSingularCase)
Solve A*x = b for x |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LU(float[][] A)
getL()
,
getU()
,
getPivot()
,
getFloatPivot()
,
det()
Method Detail |
---|
public boolean isNonsingular()
public double[][] getL()
L
.
public double[][] getU()
U
public int[] getPivot()
public float[] getFloatPivot()
public double det()
IllegalArgumentException
- Matrix must be squarepublic double[] solve(float[] b, boolean returnZeroesForSingularCase)
b
- An array with as many elements as the number of rows in A.
IllegalArgumentException
- Matrix row dimensions must agree.
RuntimeException
- Matrix is singular.public double[][] solve(float[][] B)
B
- A Matrix with as many rows as A and any number of columns.
IllegalArgumentException
- Matrix row dimensions must agree.
RuntimeException
- Matrix is singular.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |