|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpapaya.QR
public class QR
QR Decomposition.
For an m-by-n matrix A with m ≥ n, the QR decomposition is an m-by-n orthogonal matrix Q and an n-by-n upper triangular matrix R so that A = Q*R.
The QR decompostion always exists, even if the matrix does not have full rank, so the constructor will never fail. The primary use of the QR decomposition is in the least squares solution of nonsquare systems of simultaneous linear equations. This will fail if isFullRank() 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 | |
---|---|
QR(float[][] A)
QR Decomposition, computed by Householder reflections. |
Method Summary | |
---|---|
double[][] |
getH()
Return the Householder vectors |
double[][] |
getQ()
Generate and return the (economy-sized) orthogonal factor |
double[][] |
getR()
Return the upper triangular factor |
boolean |
isFullRank()
Is the matrix full rank? |
double[] |
solve(float[] b)
Least squares solution of A*X = b |
double[][] |
solve(float[][] B)
Least squares solution of A*X = B |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public QR(float[][] A)
A
- Rectangular matrixMethod Detail |
---|
public boolean isFullRank()
public double[][] getH()
public double[][] getR()
public double[][] getQ()
public double[] solve(float[] b)
b
- An array with the same length as the number of rows in A.
IllegalArgumentException
- Matrix row dimensions must agree.
RuntimeException
- Matrix is rank deficient.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 rank deficient.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |