![]() |
University of Murcia ![]() |
Matrix AlgebraSeveral matrix algebra related functions.
More... |
Functions | |
void | singularValueDecomposition (const QVMatrix &M, QVMatrix &U, QVMatrix &V, QVMatrix &S) |
Obtains the singular value decomposition (SVD) for a matrix. | |
void | SingularValueDecomposition (const QVMatrix &A, QVMatrix &U, QVMatrix &S, QVMatrix &V) |
Obtains the Singular Value Decomposition (SVD) of a matrix. | |
void | LUDecomposition (const QVMatrix &A, QVMatrix &L, QVMatrix &U, QVMatrix &P) |
Obtains the LU decomposition for a matrix. | |
void | CholeskyDecomposition (const QVMatrix &A, QVMatrix &L) |
Obtains the Cholesky decomposition for a matrix. | |
void | QRDecomposition (const QVMatrix &A, QVMatrix &Q, QVMatrix &R) |
Obtains the QR decomposition for a matrix. | |
QVMatrix | pseudoInverse (const QVMatrix &A) |
Obtains the Moore–Penrose pseudoinverse for a matrix. | |
void | eigenDecomposition (const QVMatrix &A, QVVector &l, QVMatrix &Q) |
Obtains the eigen-decomposition for a symetric matrix. | |
double | determinant (const QVMatrix &A) |
Obtains the determinant of a squared matrix. | |
void | solveLinear (const QVMatrix &A, QVVector &x, const QVVector &b) |
Solves a system of linear equations using a Householder transformation. | |
void | solveLinear (const QVMatrix &A, QVMatrix &X, const QVMatrix &B) |
Solves several system of linear equations, using a LU decomposition. | |
void | solveOverDetermined (const QVMatrix &A, QVMatrix &X, const QVMatrix &B) |
Solves several system of linear equations, using a SV decomposition. | |
void | solveHomogeneousLinear (const QVMatrix &A, QVector< double > &x) |
Solves an homogeneous linear system. |
Obtains the Cholesky decomposition for a matrix.
The Cholesky decomposition obtains a matrix L from an original matrix A, satisfying the following equation:
The matrix is a lower triangular matrix, with strictly positive diagonal entries. The
is the conjugate transpose of the matrix
.
A | param containing the matrix to decompose | |
L | param to store the resulting matrix L from the Cholesky decomposition of A |
Definition at line 279 of file qvmatrixalgebra.cpp.
double determinant | ( | const QVMatrix & | A | ) |
Obtains the determinant of a squared matrix.
A | matrix to obtain the determinant |
Por ahora con la SVD, quizá sería mejor de otro modo...
Definition at line 358 of file qvmatrixalgebra.cpp.
Referenced by QVMatrix::det().
Obtains the eigen-decomposition for a symetric matrix.
The eigen-decomposition obtains the factorization of an initial symetric matrix A into a canonical form, represented in terms of a set of (eigen) vectors, and their corresponding (eigen) values.
Each eigenvector and its corresponding eigenvalue
satisfy the following equation.
This function returns the eigenvectors and their corresponding eigenvalues in a Q matrix and a l vector. Each eigenvector is stored as a row of the Q matrix. The i-th element of the vector l contains the eigenvalue corresponding to the eigenvector stored in the i-th row.
The following equation holds, given a matrix and the vector
containing respectively the eigen-vectors and the eigen-values of the symetric matrix A:
A | symetric matrix to obtain eigen-decomposition | |
l | vector containing the eigenvalues from the eigen-decomposition of A | |
Q | matrix containing the eigenvectors from the eigen-decomposition of A. Eigenvectors are stored as row vectors. |
Definition at line 379 of file qvmatrixalgebra.cpp.
Obtains the LU decomposition for a matrix.
The Cholesky decomposition obtains three matrices: L U, and P from an original matrix A, satisfying the following equation:
Matrices L and U are a lower and upper triangular matrices respectively. P is a permutation matrix, which is equal to the identity matrix if A is invertible.
A | param containing the matrix to decompose | |
L | param to store the resulting matrix L from the LU decomposition of A | |
U | param to store the resulting matrix U from the LU decomposition of A | |
P | param to store the resulting matrix P from the LU decomposition of A |
Definition at line 225 of file qvmatrixalgebra.cpp.
Obtains the Moore–Penrose pseudoinverse for a matrix.
The Moore–Penrose pseudoinverse of an initial matrix A is another matrix A+ that satisfies the following equation:
For the matrix A+ to exist, these conditions must apply to matrix A:
A | matrix containing matrix to obtain pseudoinverse |
Definition at line 339 of file qvmatrixalgebra.cpp.
Referenced by CalibrateCameraFromPlanarHomography(), ComputeAffineHomography(), GetExtrinsicCameraMatrixFromHomography(), GetPinholeCameraIntrinsicsFromPlanarHomography(), QVMatrix::inverse(), pseudoInverse(), qvLinearRegularizedRegression(), refineExtrinsicCameraMatrixWithPolarDecomposition(), and refineExtrinsicCameraMatrixWithQRDecomposition().
Obtains the QR decomposition for a matrix.
The QR decomposition obtains two matrices Q and R from an original matrix A that satisfy the following equation:
Matrix Q is orthogonal (that is, ) and R is an upper triangular matrix.
A | param containing the matrix to decompose | |
Q | param to store the resulting matrix Q from the QR decomposition of A | |
R | param to store the resulting matrix R from the QR decomposition of A |
Definition at line 305 of file qvmatrixalgebra.cpp.
Referenced by refineExtrinsicCameraMatrixWithQRDecomposition().
Obtains the Singular Value Decomposition (SVD) of a matrix.
The SV decomposition obtains three matrices: U S, and V from an original matrix A satisfying the following equation:
The matrix U is an upper triangular matrix. The matrix S is a diagonal matrix, and the matrix V is an orthogonal matrix (that is, ).
A | matrix to decompose | |
U | param to store the matrix U from the SVD decomposition of A | |
S | param to store the matrix S from the SVD decomposition of A | |
V | param to store the matrix V from the SVD decomposition of A |
Definition at line 177 of file qvmatrixalgebra.cpp.
Referenced by determinant(), getCanonicalCameraMatricesFromEssentialMatrix(), pseudoInverse(), refineExtrinsicCameraMatrixWithPolarDecomposition(), and solveHomogeneousLinear().
Obtains the singular value decomposition (SVD) for a matrix.
Resulting matrices U, V and S will satisfy the following relationship with the input matrix:
M | matrix containing matrix to decompose | |
U | matrix to store resulting matrix U from decomposition | |
V | matrix to store resulting matrix V from decomposition | |
S | matrix to store resulting matrix S from decomposition |
Definition at line 201 of file qvmatrixalgebra.cpp.
void solveHomogeneousLinear | ( | const QVMatrix & | A, | |
QVector< double > & | x | |||
) |
Solves an homogeneous linear system.
Given a matrix A, this functions obtain the vector x satisfying the following equation:
The solution is based on the SV decomposition of the matrix A. Vector x is set to the last column of the matrix V from the SV decomposition of A.
A | coeficient matrix for the homogeneous equation system. | |
x | vector to store the solution. |
Definition at line 132 of file qvmatrixalgebra.cpp.
Referenced by ComputeProjectiveHomography(), getCameraMatrixFrom2D3DPointCorrespondences(), triangulate3DPointFrom2Views(), and triangulate3DPointFromNViews().
Solves several system of linear equations, using a LU decomposition.
Given a coefficient matrix A and an objectives matrix B, this functions obtain the matrix x satisfying the following equation:
Notice that the solution of this equation is equivalent to solving the equations:
Where xi and bi are respectively the i-th columns of X and B. But obtaining a solution for the latter set of equations is less efficient and worst conditioned than solving the former matrix equation.
This function is based on a LU decomposition, to obtain the solution for the equation. Thus, the system can not be overdetermined. That is, the A, X and B must be square.
A | coeficient matrix in the matrix equation form of the problem. | |
x | matrix to store the solutions, each column is a solution. | |
B | right-hand side matrix in the matrix equation form of the problem, each column is a right-hand side. |
Definition at line 52 of file qvmatrixalgebra.cpp.
Solves a system of linear equations using a Householder transformation.
Given a coefficient matrix A and an objective vector b, this functions obtain the vector x satisfying the following equation:
For a more efficient way of solving several systems of linear equations simultaneously, see solveLinear(const QVMatrix &, QVMatrix &, const QVMatrix &) and solveOverDetermined(const QVMatrix &, QVMatrix &, const QVMatrix &) functions.
A | coeficient matrix in the matrix equation form of the problem. | |
x | vector to store the solution. | |
b | right-hand side vector in the matrix equation form of the problem. |
solveLinear(const QVMatrix &, QVMatrix &, const QVMatrix &)
solveOverDetermined(const QVMatrix &, QVMatrix &, const QVMatrix &)
Definition at line 36 of file qvmatrixalgebra.cpp.
Referenced by QVMatrix::matrixDivide().
Solves several system of linear equations, using a SV decomposition.
Given a coefficient matrix A and an objectives matrix B, this functions obtain the matrix x satisfying the following equation:
This function is equivalent to solveLinear(const QVMatrix &, QVMatrix &, const QVMatrix &). The difference is that it uses SV decomposition, thus it can handle over-determined systems, where the first dimension of the matrix B is smaller or equal than its second dimension.
A coeficient matrix in the matrix equation form of the problem. X matrix to store the solutions, each column is a solution. B right-hand side matrix in the matrix equation form of the problem, each column is a right-hand side.
Definition at line 89 of file qvmatrixalgebra.cpp.
Referenced by QVMatrix::matrixDivide().