Package smile.math.matrix
Class Matrix.QR
java.lang.Object
smile.math.matrix.Matrix.QR
- All Implemented Interfaces:
Serializable
- Enclosing class:
Matrix
The 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 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.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
-
Field Details
-
qr
The QR decomposition. -
tau
public final double[] tauThe scalar factors of the elementary reflectors
-
-
Constructor Details
-
QR
Constructor.- Parameters:
qr
- the QR decomposition.tau
- the scalar factors of the elementary reflectors
-
-
Method Details
-
CholeskyOfAtA
Returns the Cholesky decomposition of A'A.- Returns:
- the Cholesky decomposition of A'A.
-
R
Returns the upper triangular factor.- Returns:
- the upper triangular factor.
-
Q
Returns the orthogonal factor.- Returns:
- the orthogonal factor.
-
solve
public double[] solve(double[] b) Solves the least squares min || B - A*X ||.- Parameters:
b
- the right hand side of overdetermined linear system.- Returns:
- the solution vector beta that minimizes ||Y - X*beta||.
- Throws:
RuntimeException
- when the matrix is rank deficient.
-
solve
Solves the least squares min || B - A*X ||.- Parameters:
B
- the right hand side of overdetermined linear system. B will be overwritten with the solution matrix on output.- Throws:
RuntimeException
- when the matrix is rank deficient.
-