#include <ludecomposition.h>
Public Member Functions | |
bool | computeBasisKer (MatrixType *result) const |
bool | computeInverse (MatrixType *result) const |
bool | computeSomeAntecedent (const VectorType &v, VectorType *result) const |
T | determinant () const |
int | dim () const |
int | dimKer () const |
MatrixType | inverse () const |
bool | isInvertible () const |
const MatrixType & | LU () const |
MatrixType & | LU () |
LUDecomposition (const Matrix< T, Size > &mat) | |
const IntVecType & | P () const |
IntVecType & | P () |
const IntVecType & | Q () const |
IntVecType & | Q () |
int | rank () const |
Protected Member Functions | |
LUDecomposition () | |
void | perform (const MatrixType &A) |
Protected Attributes | |
T | m_biggestEigenValueU |
int | m_detPQ |
int | m_dim |
int | m_dimKer |
MatrixType | m_LU |
IntVecType | m_P |
IntVecType | m_Q |
The template parameter T is the type of the entries of the matrix to be decomposed. It can be any type representing either real or complex numbers. The template parameter Size is the size of the matrix (both height and width, as Eigen only allows square matrices). The following typedefs are provided to cover the usual cases:
typedef LUDecomposition<double, 2> LUDecomposition2d; typedef LUDecomposition<double, 3> LUDecomposition3d; typedef LUDecomposition<double, 4> LUDecomposition4d; typedef LUDecomposition<float, 2> LUDecomposition2f; typedef LUDecomposition<float, 3> LUDecomposition3f; typedef LUDecomposition<float, 4> LUDecomposition4f; typedef LUDecomposition<std::complex<double>, 2> LUDecomposition2cd; typedef LUDecomposition<std::complex<double>, 3> LUDecomposition3cd; typedef LUDecomposition<std::complex<double>, 4> LUDecomposition4cd; typedef LUDecomposition<std::complex<float>, 2> LUDecomposition2cf; typedef LUDecomposition<std::complex<float>, 3> LUDecomposition3cf; typedef LUDecomposition<std::complex<float>, 4> LUDecomposition4cf;
LUDecomposition | ( | const Matrix< T, Size > & | mat | ) | [inline] |
Performs the LU Decomposition of mat. Use this constructor.
LUDecomposition | ( | ) | [inline, protected] |
Default constructor. Does nothing.
For internal use only.
bool computeBasisKer | ( | MatrixType * | result | ) | const [inline, inherited] |
This method computes a basis of the kernel of the matrix A of which *this is the LU decomposition.
The result argument is a pointer to the matrix in which the result will be stored. After calling this method, the dimKer() first columns of result form a basis of the kernel of A. If A is invertible, then dimKer()==0 and this method does nothing.
bool computeInverse | ( | MatrixType * | result | ) | const [inline, inherited] |
Computes the inverse matrix of A, where A is the matrix of which *this is the LU decomposition, and stores it in *result.
If A is non-invertible, this method does nothing.
bool computeSomeAntecedent | ( | const VectorType & | v, | |
VectorType * | result | |||
) | const [inline, inherited] |
Computes an antecedent of v by the matrix A of which *this is a LU decomposition. In other words, this method computes a vector u such that A u = v. If such an antecedent u doesn't exist, this method does nothing.
1. The returned vector u is only one solution of the equation Au=v, which can have more than one solution if A is non-invertible. To get a basis of the whole (affine) space of solutions, use computeBasisKer().
T determinant | ( | ) | const [inline, inherited] |
This method returns the determinant of the square matrix A of which *this is the LU decomposition. It has only linear complexity (that is, O(n) where n is the dimension of the square matrix) as the LU decomposition has already been computed.
Warning: a determinant can be very big or small, so for matrices of large dimension (like a 50-by-50 matrix) there can be a risk of overflow/underflow.
int dim | ( | ) | const [inline, inherited] |
Returns the dimension (size) of square matrix A of which *this is the LU decomposition -- just in case you forgot it!
int dimKer | ( | ) | const [inline, inherited] |
Returns the dimension of the kernel of the square matrix A of which *this is the LU decomposition. It is very fast because the computation has already been done during the LU decomposition.
MatrixType inverse | ( | ) | const [inline, inherited] |
This methods returns the inverse matrix of A, where A is the matrix of which *this is the LU decomposition. If A is non-invertible, the returned value is undefined.
This method calls computeInverse(), so the same remarks as for computeInverse() apply here.
This method returns an object by value, which is inefficient.
bool isInvertible | ( | ) | const [inline, inherited] |
Returns true if the square matrix A, of which *this is the LU decomposition, is invertible. It returns false if it is singular. It is very fast because the computation has already been done during the LU decomposition.
const MatrixType& LU | ( | ) | const [inline, inherited] |
MatrixType& LU | ( | ) | [inline, inherited] |
Returns the member m_LU, which stores the matrices L and U. See member m_LU and the class's comment.
const IntVecType& P | ( | ) | const [inline, inherited] |
IntVecType& P | ( | ) | [inline, inherited] |
Returns the member m_P, which stores the permutation P. See member m_P and the class's comment.
void perform | ( | const MatrixType & | A | ) | [inline, protected, inherited] |
The helper method actually computing the LU decomposition. Called by the constructor.
For internal reasons it is public, but you should never call it.
const IntVecType& Q | ( | ) | const [inline, inherited] |
IntVecType& Q | ( | ) | [inline, inherited] |
Returns the member m_Q, which stores the permutation Q. See member m_Q and the class's comment.
int rank | ( | ) | const [inline, inherited] |
Returns the rank of the square matrix A of which *this is the LU decomposition. It is very fast because the computation has already been done during the LU decomposition.
T m_biggestEigenValueU [protected, inherited] |
The Eigenvalue of U that has biggest absolute value.
int m_detPQ [protected, inherited] |
This is equal to the determinant of the product matrix PQ, or equivalently, to the signature of the permutation pq. This is used by the determinant() method.
int m_dim [protected, inherited] |
The dimension of the matrix A of which *this is the LU decomposition
int m_dimKer [protected, inherited] |
The dimension of the kernel of the square matrix A of which *this is the LU decomposition.
MatrixType m_LU [protected, inherited] |
This matrix holds the data of the L and U matrices of the LU decomposition, as follows. The part above the diagonal (including the diagonal) is U. The part strictly below the diagonal is L. As U is upper triangular, L is lower triangular, and L has its diagonal entries all equal to 1, this holds all the data of the matrices L and U. Also note that the Eigenvalues of U are stored in decreasing order of absolute value.
IntVecType m_P [protected, inherited] |
The permutation matrices P and Q are stored in these permutations p, q. They are understood as follows: the permutation p maps k to p[k]. Same for q. So, in terms of matrices, P moves the k-th row to the p[k]-th row, and Q moves the k-th column to the q[k]-th column.
IntVecType m_Q [protected, inherited] |