Catalano.Math.Decompositions
Class QRDecomposition
- java.lang.Object
-
- Catalano.Math.Decompositions.QRDecomposition
-
- All Implemented Interfaces:
- java.io.Serializable
public class QRDecomposition extends java.lang.Object implements java.io.SerializableQR 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.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description QRDecomposition(double[][] matrix)Initializes a new instance of the QRDecomposition class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description double[][]getH()Get the Householder vectors.double[][]getQ()Generate the (economy-sized) orthogonal factor.double[][]getR()Get the upper triangular factor.booleanisFullRank()Check if the matrix is full rank.double[][]solve(double[][] B)Least squares solution of A*X = B
-
-
-
Constructor Detail
-
QRDecomposition
public QRDecomposition(double[][] matrix)
Initializes a new instance of the QRDecomposition class.- Parameters:
matrix- Matrix.
-
-
Method Detail
-
isFullRank
public boolean isFullRank()
Check if the matrix is full rank.- Returns:
- True if R, and hence A has full rank, otherwise false.
-
getH
public double[][] getH()
Get the Householder vectors.- Returns:
- Lower trapezoidal matrix whose columns define the reflections.
-
getR
public double[][] getR()
Get the upper triangular factor.- Returns:
- Upper triangular factor.
-
getQ
public double[][] getQ()
Generate the (economy-sized) orthogonal factor.- Returns:
- Economy-sized orthogonal factor.
-
solve
public double[][] solve(double[][] B)
Least squares solution of A*X = B- Parameters:
B- A Matrix with as many rows as A and any number of columns.- Returns:
- X that minimizes the two norm of Q*R*X-B.
- Throws:
java.lang.IllegalArgumentException- Matrix row dimensions must agree.java.lang.RuntimeException- Matrix is rank deficient.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG