cisst-saw
|
#include <cisstCommon/cmnPortability.h>
#include <cisstVector/vctForwardDeclarations.h>
#include <cisstNumerical/nmrExport.h>
Go to the source code of this file.
Functions | |||||||||
Gauss Jordan Inverse for fixed size matrices | |||||||||
The function nmrGaussJordanInverseNxN (N = 2, 3, 4) computes the inverse of a NxN matrix using Gauss-Jordan elimination. The function is instantiated for matrices of double and float in either storage order. When compiled in release mode, this function is at least 2.5 times faster than a parallel function in C-LAPACK based on LU decomposition (dgetrf, dgetri), with an equvalent precision. However, the speed advantage is counted here only in RELEASE mode, whereas in debug mode these functions are significantly slower. The functions have been optimized to run for specific and typically occuring fixed-size cases, namely 2x2, 3x3 and 4x4. However, if all you need is to solve one linear equation, it is more efficient to have a direct solver than to compute the inverse first. In terms of numerical stability, the Gauss-Jordan method should be fairly stable for the specific matrix sizes in question, but it only uses row pivoting, and therefore other methods that include also column pivoting should be more stable.
| |||||||||
template<class _elementType , bool _rowMajorIn, bool _rowMajorOut> | |||||||||
CISST_EXPORT void | nmrGaussJordanInverse2x2 (vctFixedSizeMatrix< _elementType, 2, 2, _rowMajorIn > A, bool &nonsingular, vctFixedSizeMatrix< _elementType, 2, 2, _rowMajorOut > &Ainv, const _elementType singularityTolerance) | ||||||||
template<class _elementType , bool _rowMajorIn, bool _rowMajorOut> | |||||||||
CISST_EXPORT void | nmrGaussJordanInverse3x3 (vctFixedSizeMatrix< _elementType, 3, 3, _rowMajorIn > A, bool &nonsingular, vctFixedSizeMatrix< _elementType, 3, 3, _rowMajorOut > &Ainv, const _elementType singularityTolerance) | ||||||||
template<class _elementType , bool _rowMajorIn, bool _rowMajorOut> | |||||||||
CISST_EXPORT void | nmrGaussJordanInverse4x4 (vctFixedSizeMatrix< _elementType, 4, 4, _rowMajorIn > A, bool &nonsingular, vctFixedSizeMatrix< _elementType, 4, 4, _rowMajorOut > &Ainv, const _elementType singularityTolerance) | ||||||||
CISST_EXPORT void nmrGaussJordanInverse2x2 | ( | vctFixedSizeMatrix< _elementType, 2, 2, _rowMajorIn > | A, |
bool & | nonsingular, | ||
vctFixedSizeMatrix< _elementType, 2, 2, _rowMajorOut > & | Ainv, | ||
const _elementType | singularityTolerance | ||
) |
Gauss Jordan Inverse for a 2 by 2 matrix.
CISST_EXPORT void nmrGaussJordanInverse3x3 | ( | vctFixedSizeMatrix< _elementType, 3, 3, _rowMajorIn > | A, |
bool & | nonsingular, | ||
vctFixedSizeMatrix< _elementType, 3, 3, _rowMajorOut > & | Ainv, | ||
const _elementType | singularityTolerance | ||
) |
Gauss Jordan Inverse for a 3 by 3 matrix.
CISST_EXPORT void nmrGaussJordanInverse4x4 | ( | vctFixedSizeMatrix< _elementType, 4, 4, _rowMajorIn > | A, |
bool & | nonsingular, | ||
vctFixedSizeMatrix< _elementType, 4, 4, _rowMajorOut > & | Ainv, | ||
const _elementType | singularityTolerance | ||
) |
Gauss Jordan Inverse for a 4 by 4 matrix.