#include <ludecomposition.h>
Public Member Functions | |
bool | computeBasisKer (MatrixX< T > *result) const |
bool | computeInverse (MatrixX< T > *result) const |
bool | computeSomeAntecedent (const VectorX< T > &v, VectorX< T > *result) const |
T | determinant () const |
int | dim () const |
int | dimKer () const |
MatrixX< T > | inverse () const |
bool | isInvertible () const |
const MatrixX< T > & | LU () const |
MatrixX< T > & | LU () |
LUDecompositionX (const MatrixX< T > &mat) | |
const VectorX< int > & | P () const |
VectorX< int > & | P () |
const VectorX< int > & | Q () const |
VectorX< int > & | Q () |
int | rank () const |
Protected Member Functions | |
LUDecompositionX () | |
void | perform (const MatrixX< T > &A) |
Protected Attributes | |
T | m_biggestEigenValueU |
int | m_detPQ |
int | m_dim |
int | m_dimKer |
MatrixX< T > | m_LU |
VectorX< int > | m_P |
VectorX< int > | 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 following typedefs are provided to cover the usual cases:
typedef LUDecompositionX<double> LUDecompositionXd; typedef LUDecompositionX<float> LUDecompositionXf; typedef LUDecompositionX< std::complex<double> > LUDecompositionXcd; typedef LUDecompositionX< std::complex<float> > LUDecompositionXcf;
LUDecompositionX | ( | const MatrixX< T > & | mat | ) | [inline] |
Performs the LU Decomposition of mat. Use this constructor.
LUDecompositionX | ( | ) | [inline, protected] |
Default constructor. Does nothing.
For internal use only.
bool computeBasisKer | ( | MatrixX< T > * | result | ) | const [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 | ( | MatrixX< T > * | result | ) | const [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.
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 [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.
MatrixX< T > 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 MatrixX< T > & LU | ( | ) | const [inline, inherited] |
MatrixX< T > & 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 VectorX< int > & P | ( | ) | const [inline, inherited] |
VectorX< int > & 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 MatrixX< T > & | A | ) | [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 VectorX< int > & Q | ( | ) | const [inline, inherited] |
VectorX< int > & 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.
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.
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.