smile.math.matrix
Class QR
- java.lang.Object
-
- smile.math.matrix.QR
-
public class QR extends java.lang.ObjectFor 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 such that A = Q*R.The QR decomposition always exists, even if the matrix does not have full rank. The primary use of the QR decomposition is in the least squares solution of non-square systems of simultaneous linear equations, where
isSingular()has to be false.QR decomposition is also the basis for a particular eigenvalue algorithm, the QR algorithm.
-
-
Constructor Summary
Constructors Constructor and Description QR(DenseMatrix qr, double[] tau, boolean singular)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description CholeskyCholeskyOfAtA()Returns the Cholesky decomposition of A'A.DenseMatrixgetQ()Returns the orthogonal factor.DenseMatrixgetR()Returns the upper triangular factor.booleanisSingular()Returns true if the matrix is singular (not full column rank).voidsolve(DenseMatrix B)Solve the least squares A * X = B.voidsolve(double[] b, double[] x)Solve the least squares A*x = b.
-
-
-
Constructor Detail
-
QR
public QR(DenseMatrix qr, double[] tau, boolean singular)
Constructor.
-
-
Method Detail
-
isSingular
public boolean isSingular()
Returns true if the matrix is singular (not full column rank).
-
CholeskyOfAtA
public Cholesky CholeskyOfAtA()
Returns the Cholesky decomposition of A'A.
-
getR
public DenseMatrix getR()
Returns the upper triangular factor.
-
getQ
public DenseMatrix getQ()
Returns the orthogonal factor.
-
solve
public void solve(double[] b, double[] x)Solve the least squares A*x = b.- Parameters:
b- right hand side of linear system.x- the output solution vector that minimizes the L2 norm of Q*R*x - b.- Throws:
java.lang.RuntimeException- if matrix is rank deficient.
-
solve
public void solve(DenseMatrix B)
Solve the least squares A * X = B. B will be overwritten with the solution matrix on output.- Parameters:
B- right hand side of linear system. B will be overwritten with the solution matrix on output.- Throws:
java.lang.RuntimeException- Matrix is rank deficient.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG