PARP Research Group University of Murcia


Matrix Algebra
[Math extensions]

Several 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.

Detailed Description

Several matrix algebra related functions.


Function Documentation

void CholeskyDecomposition ( const QVMatrix A,
QVMatrix L 
)

Obtains the Cholesky decomposition for a matrix.

The Cholesky decomposition obtains a matrix L from an original matrix A, satisfying the following equation:

$ A = L L^{*} $

The matrix $ L $ is a lower triangular matrix, with strictly positive diagonal entries. The $ L^{*} $ is the conjugate transpose of the matrix $ L $.

Parameters:
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.

Parameters:
A matrix to obtain the determinant
Returns:
the value of 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().

void eigenDecomposition ( const QVMatrix A,
QVVector l,
QVMatrix Q 
)

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 $ \mathbf{v} $ and its corresponding eigenvalue $ \lambda $ satisfy the following equation.

$ A \mathbf{v} = \lambda \mathbf{v} $

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 $ Q $ and the vector $ \vec{\lambda} $ containing respectively the eigen-vectors and the eigen-values of the symetric matrix A:

$ A = Q^{T}diag(\vec{\lambda})Q^{-T} $

Parameters:
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.

Todo:
borrar el código comentado, cuando se compruebe que el nuevo funciona bien.

Definition at line 379 of file qvmatrixalgebra.cpp.

void LUDecomposition ( const QVMatrix A,
QVMatrix L,
QVMatrix U,
QVMatrix P 
)

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:

$ A = P L U $

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.

Parameters:
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.

QVMatrix pseudoInverse ( const QVMatrix A  ) 

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:

$ A A^+ = I $

For the matrix A+ to exist, these conditions must apply to matrix A:

  • Its first dimension must be lower or equal than its second dimension.
  • Its determinant must not be zero.

Parameters:
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().

void QRDecomposition ( const QVMatrix A,
QVMatrix Q,
QVMatrix R 
)

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:

$ A = Q R $

Matrix Q is orthogonal (that is, $ Q Q^T = I $) and R is an upper triangular matrix.

Parameters:
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().

void SingularValueDecomposition ( const QVMatrix A,
QVMatrix U,
QVMatrix S,
QVMatrix V 
)

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:

$ A = U S V^T $

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, $ V V^T = I $).

Parameters:
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().

void singularValueDecomposition ( const QVMatrix M,
QVMatrix U,
QVMatrix V,
QVMatrix S 
)

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 = U S V^T $

Parameters:
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
Deprecated:
use SingularValueDecomposition(const QVMatrix &, QVMatrix &, QVMatrix &, QVMatrix &) instead.

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:

$ A\mathbf{x} = \mathbf{0} $

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.

Parameters:
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().

void solveLinear ( const QVMatrix A,
QVMatrix X,
const QVMatrix B 
)

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:

$ AX = B $

Notice that the solution of this equation is equivalent to solving the equations:

$ A\mathbf{x_i} = \mathbf{b_i} $

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.

Parameters:
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.
See also:
solveOverDetermined(const QVMatrix &, QVMatrix &, const QVMatrix &)

solveLinear(const QVMatrix &, QVVector &, const QVVector &)

Definition at line 52 of file qvmatrixalgebra.cpp.

void solveLinear ( const QVMatrix A,
QVVector x,
const QVVector b 
)

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:

$ A\mathbf{x} = \mathbf{b} $

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.

Parameters:
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.
See also:
solveLinear(const QVMatrix &, QVVector &, const QVVector &)

solveLinear(const QVMatrix &, QVMatrix &, const QVMatrix &)

solveOverDetermined(const QVMatrix &, QVMatrix &, const QVMatrix &)

Definition at line 36 of file qvmatrixalgebra.cpp.

Referenced by QVMatrix::matrixDivide().

void solveOverDetermined ( const QVMatrix A,
QVMatrix X,
const QVMatrix B 
)

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:

$ AX = B $

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.

Parameters:
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.
See also:
solveLinear(const QVMatrix &, QVMatrix &, const QVMatrix &)

solveLinear(const QVMatrix &, QVVector &, const QVVector &)

Definition at line 89 of file qvmatrixalgebra.cpp.

Referenced by QVMatrix::matrixDivide().




QVision framework. PARP research group. Copyright © 2007, 2008, 2009, 2010.