28 #ifndef _nmrLUSolver_h
29 #define _nmrLUSolver_h
91 CISSTNETLIB_INTEGER
M;
92 CISSTNETLIB_INTEGER
N;
93 CISSTNETLIB_INTEGER
Lda;
122 template <
class _matrixOwnerType>
124 const unsigned int rows = A.
rows();
125 const unsigned int cols = A.
cols();
126 unsigned int rowIndex, colIndex;
127 for (rowIndex = 0; rowIndex < rows; ++rowIndex) {
128 for (colIndex = 0; colIndex < cols; ++colIndex) {
129 if (rowIndex > colIndex) {
130 L.
Element(rowIndex, colIndex) = A[rowIndex][colIndex];
132 U.
Element(rowIndex, colIndex) = A[rowIndex][colIndex];
143 CISSTNETLIB_INTEGER rowIndex, colIndex;
144 for (rowIndex = 0; rowIndex <
MinMN; ++rowIndex) {
145 colIndex =
Ipiv[rowIndex] - 1;
177 bool allocateLU =
false,
178 bool allocateP =
false) {
197 bool allocateLU =
false,
bool allocateP =
false) {
201 template <vct::
size_type _rows, vct::
size_type _cols>
203 bool allocateLU =
false,
bool allocateP =
false) {
219 inline void Allocate(CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n,
220 bool allocateLU =
false,
bool allocateP =
false) {
221 const CISSTNETLIB_INTEGER one = 1;
224 Lda = std::max(one,
M);
249 bool allocateLU =
false,
bool allocateP =
false) {
253 template <vct::
size_type _rows, vct::
size_type _cols>
255 bool allocateLU =
false,
bool allocateP =
false) {
256 Allocate(_rows, _cols, allocateLU, allocateP);
278 template <
class _matrixOwnerType>
281 if (! A.IsColMajor()) {
282 cmnThrow(std::runtime_error(
"nmrLUSolver Solve: The input must be column major"));
286 if ((
M != static_cast<CISSTNETLIB_INTEGER>(A.rows())) || (
N !=
static_cast<CISSTNETLIB_INTEGER
>(A.cols()))) {
287 cmnThrow(std::runtime_error(
"nmrLUSolver Solve: Size used for Allocate was different"));
291 if (! A.IsCompact()) {
292 cmnThrow(std::runtime_error(
"nmrLUSolver Solve: Requires a compact matrix"));
305 template <vct::
size_type _rows, vct::
size_type _cols>
321 inline CISSTNETLIB_INTEGER
GetInfo(
void)
const {
328 cmnThrow(std::runtime_error(
"nmrLUSolver GetP: P was not calculated since allocateP is not set"));
336 cmnThrow(std::runtime_error(
"nmrLUSolver GetL: L was not calculated since allocateLU is not set"));
344 cmnThrow(std::runtime_error(
"nmrLUSolver GetU: U was not calculated since allocateLU is not set"));
351 #ifdef CISST_COMPILER_IS_MSVC
353 #endif // CISST_COMPILER_IS_MSVC
356 #endif // _nmrLUSolver_h
void UpdateLU(const vctDynamicConstMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > &A)
Definition: nmrLUSolver.h:123
Declaration of vctDynamicMatrix.
Definition: vctDynamicMatrixBase.h:42
#define CISST_DEPRECATED
Definition: cmnPortability.h:310
CISSTNETLIB_INTEGER Lda
Definition: nmrLUSolver.h:93
Definition: nmrLUSolver.h:85
Declaration of vctFixedSizeMatrix.
vctDynamicMatrix< CISSTNETLIB_DOUBLE > U
Definition: nmrLUSolver.h:99
void ExchangeColumns(const size_type col1Index, const size_type col2Index)
Definition: vctDynamicMatrixBase.h:328
nmrLUSolver(const vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, bool allocateLU=false, bool allocateP=false)
Definition: nmrLUSolver.h:196
void Allocate(CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, bool allocateLU=false, bool allocateP=false)
Definition: nmrLUSolver.h:219
CISSTNETLIB_INTEGER GetInfo(void) const
Definition: nmrLUSolver.h:321
void SetSize(size_type size)
Definition: vctDynamicVector.h:315
Definition: vctDynamicConstMatrixBase.h:77
Declaration of vctDynamicVector.
void AllocateLU(void)
Definition: nmrLUSolver.h:111
value_type SetAll(const value_type value)
Definition: vctDynamicMatrixBase.h:452
Declaration of vctFixedSizeVector.
vctDynamicMatrix< CISSTNETLIB_DOUBLE > P
Definition: nmrLUSolver.h:99
size_type rows() const
Definition: vctDynamicConstMatrixBase.h:238
vctDynamicMatrix< CISSTNETLIB_DOUBLE > L
Definition: nmrLUSolver.h:99
size_type cols() const
Definition: vctDynamicConstMatrixBase.h:243
bool AllocateLUFlag
Definition: nmrLUSolver.h:98
void Allocate(const vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, bool allocateLU=false, bool allocateP=false)
Definition: nmrLUSolver.h:248
nmrLUSolver(void)
Definition: nmrLUSolver.h:156
void SetSize(size_type rows, size_type cols, bool storageOrder)
Definition: vctDynamicMatrix.h:364
#define cmnThrow(a)
Definition: MinimalCmn.h:4
Implementation of a fixed-size matrix using template metaprogramming.
Definition: vctFixedSizeMatrix.h:52
nmrLUSolver(CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, bool allocateLU=false, bool allocateP=false)
Definition: nmrLUSolver.h:176
vctDynamicVector< CISSTNETLIB_INTEGER > Ipiv
Definition: nmrLUSolver.h:96
reference Element(size_type rowIndex, size_type colIndex)
Definition: vctDynamicMatrixBase.h:214
pointer Pointer(index_type index=0)
Definition: vctDynamicVectorBase.h:155
const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & GetP(void) const
Definition: nmrLUSolver.h:326
value_type SetAll(const value_type value)
Definition: vctDynamicVectorBase.h:209
CISSTNETLIB_INTEGER Info
Definition: nmrLUSolver.h:97
const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & GetU(void) const
Definition: nmrLUSolver.h:342
void Allocate(const vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, VCT_COL_MAJOR > &A, bool allocateLU=false, bool allocateP=false)
Definition: nmrLUSolver.h:254
void UpdateP(void)
Definition: nmrLUSolver.h:140
DiagonalRefType Diagonal(void)
Definition: vctDynamicMatrixBase.h:239
const bool VCT_COL_MAJOR
Definition: vctForwardDeclarations.h:46
void Solve(vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, VCT_COL_MAJOR > &A)
Definition: nmrLUSolver.h:306
const vctDynamicVector< CISSTNETLIB_INTEGER > & GetIpiv(void) const
Definition: nmrLUSolver.h:316
void AllocateP(void)
Definition: nmrLUSolver.h:102
CISSTNETLIB_INTEGER MaxMN
Definition: nmrLUSolver.h:94
void Solve(vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > &A)
Definition: nmrLUSolver.h:279
const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & GetL(void) const
Definition: nmrLUSolver.h:334
CISSTNETLIB_INTEGER MinMN
Definition: nmrLUSolver.h:94
CISSTNETLIB_INTEGER N
Definition: nmrLUSolver.h:92
CISSTNETLIB_INTEGER M
Definition: nmrLUSolver.h:91
nmrLUSolver(const vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, VCT_COL_MAJOR > &A, bool allocateLU=false, bool allocateP=false)
Definition: nmrLUSolver.h:202
bool AllocatePFlag
Definition: nmrLUSolver.h:98