|
| nmrLUSolver (void) |
|
| nmrLUSolver (CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, bool allocateLU=false, bool allocateP=false) |
|
void | Allocate (CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, bool allocateLU=false, bool allocateP=false) |
|
const vctDynamicVector
< CISSTNETLIB_INTEGER > & | GetIpiv (void) const |
|
CISSTNETLIB_INTEGER | GetInfo (void) const |
|
const vctDynamicMatrix
< CISSTNETLIB_DOUBLE > & | GetP (void) const throw (std::runtime_error) |
|
const vctDynamicMatrix
< CISSTNETLIB_DOUBLE > & | GetL (void) const throw (std::runtime_error) |
|
const vctDynamicMatrix
< CISSTNETLIB_DOUBLE > & | GetU (void) const throw (std::runtime_error) |
|
|
This constructor allocates the memory based on the actual input of the Solve() method. It relies on the method Allocate(). The next call to the Solve() method will check that the input matches the dimension.
- Parameters
-
A | The matrix to be factorized (or any matrix of the same size) |
allocateLU | Allocates memory to maintain a usable copy of L and U |
allocateP | Allocates memory to maintain a usable copy of P |
|
| nmrLUSolver (const vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, bool allocateLU=false, bool allocateP=false) |
|
template<vct::size_type _rows, vct::size_type _cols> |
| nmrLUSolver (const vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, VCT_COL_MAJOR > &A, bool allocateLU=false, bool allocateP=false) |
|
|
This method provides a convenient way to extract the required sizes from the input containers. The next call to the Solve() method will check that the input matches the dimension.
- Parameters
-
A | The matrix to be factorized (or any matrix of the same size) |
allocateLU | Allocates memory to maintain a usable copy of L and U |
allocateP | Allocates memory to maintain a usable copy of P |
|
void | Allocate (const vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, bool allocateLU=false, bool allocateP=false) |
|
template<vct::size_type _rows, vct::size_type _cols> |
void | Allocate (const vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, VCT_COL_MAJOR > &A, bool allocateLU=false, bool allocateP=false) |
|
|
template<class _matrixOwnerType > |
void | Solve (vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > &A) throw (std::runtime_error) |
|
template<vct::size_type _rows, vct::size_type _cols> |
void | Solve (vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, VCT_COL_MAJOR > &A) |
|
Algorithm LU: LU factorization of a general M by N matrix
The class is a wrapper for the LAPACK function dgetrf. It computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.
The factorization has the form
where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).
The data members of this class are:
- M: The number of rows of the input matrix A. M >= 0.
- N: The number of columns of the input matrix A. N >= 0.
- Lda: The leading dimension of the array A.
.
- MinMN: Lenght of diagonal

- Ipiv: The pivot indices, from 1 to min(M, N).
The LAPACK function modifies the input matrix in place. The matrices L and U are stored in the same place which is pretty inconvenient to use. To reconstruct both L and U, the user can set the AllocateLU flag to true. This will allocate the correct amount of memory for L and U and the method UpdateLU will run automatically after each Solve.
Similarly, the flag AllocateP will allocate some extra memory and built the permutation matrix P based on the pivots used (IPiv).
- Note
- The input matrices of this class must be column major. To select the storage order, use VCT_COL_MAJOR whenever you declare a matrix.
-
The input matrix must be compact (see vctDynamicMatrix::IsCompact() or vctFixedSizeMatrix::IsCompact()).
-
This code relies on the ERC CISST cnetlib library. Since cnetlib is optional, make sure that CISST_HAS_CNETLIB has been turned ON during the configuration with CMake.
- Deprecated:
- This class has been replaced by nmrLU, nmrLUDynamicData and nmrLUFixedSizeData.
template<class _matrixOwnerType >
void nmrLUSolver::Solve |
( |
vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > & |
A | ) |
|
throw | ( | std::runtime_error |
| ) | | |
|
inline |
Performs the factorization. The result is stored in the modified input and the data member IPiv (vector of pivots).
To get a more convenient representation of the results, use turn allocateLU to true with Allocate() or the constructor. This method will then update the data members L and U (matrices). Then, one can use GetL and GetU to retrieve their content. Similarly, if one needs the complete factorization as
, the matrix P can be obtained when allocateP is set with the method GetP.
- Note
- This method requires a compact matrix with column major storage order. The size must match the dimension passed to the Allocate method or the constructor. An std::runtime_error exception will be thrown if these conditions are not met.