135 if (allocateOutput) {
137 this->OutputMemory.SetSize(minmn);
138 this->PivotIndicesReference.
SetRef(this->OutputMemory);
140 this->OutputMemory.SetSize(0);
151 template <
class _vectorOwnerTypePivotIndices>
157 if (minmn != pivotIndices.size()) {
158 cmnThrow(std::runtime_error(
"nmrLUDynamicData: Size of vector pivotIndices is incorrect."));
160 if (!pivotIndices.IsCompact()) {
161 cmnThrow(std::runtime_error(
"nmrLUDynamicData: Vector pivotIndices must be compact."));
175 template <
class _matrixOwnerTypeA>
190 template <
class _matrixOwnerTypeA>
194 const size_type minmn = (A.rows() < A.cols()) ? A.rows() : A.cols();
206 template <
class _matrixOwnerTypeA>
210 const size_type minmn = (A.rows() < A.cols()) ? A.rows() : A.cols();
224 template <
class _matrixOwnerTypeA,
class _vectorOwnerTypePivotIndices,
class _matrixOwnerTypeP>
232 const size_type minmn = (A.rows() < A.cols()) ? A.rows() : A.cols();
234 if (pivotIndices.size() != minmn) {
235 cmnThrow(std::runtime_error(
"nmrLUDynamicData::UpdateMatrixP: Size of vector pivotIndices is incorrect."));
237 if (! P.IsSquare(A.rows())) {
238 cmnThrow(std::runtime_error(
"nmrLUDynamicData::UpdateMatrixP: Size of matrix P is incorrect."));
242 P.Diagonal().SetAll(1.0);
244 for (rowIndex = 0; rowIndex < minmn; ++rowIndex) {
245 colIndex = pivotIndices[rowIndex] - 1;
246 P.ExchangeColumns(rowIndex, colIndex);
265 template <
class _matrixOwnerTypeA,
class _matrixOwnerTypeL,
class _matrixOwnerTypeU>
276 L.Diagonal().SetAll(1.0);
278 for (rowIndex = 0; rowIndex <
rows; ++rowIndex) {
279 for (colIndex = 0; colIndex <
cols; ++colIndex) {
280 if (rowIndex > colIndex) {
281 L.Element(rowIndex, colIndex) = A.Element(rowIndex, colIndex);
283 U.Element(rowIndex, colIndex) = A.Element(rowIndex, colIndex);
306 return Data.PivotIndicesReference;
356 template <
class _matrixOwnerTypeA>
373 template <
class _matrixOwnerTypeA,
374 class _vectorOwnerTypePivotIndices>
378 this->
SetRef(A, pivotIndices);
390 template <
class _matrixOwnerTypeA>
420 template <
class _matrixOwnerTypeA,
421 class _vectorOwnerTypePivotIndices>
429 this->PivotIndicesReference.
SetRef(pivotIndices);
467template <vct::
size_type _rows, vct::
size_type _cols>
473 enum {
MIN_MN = (_rows < _cols) ? _rows : _cols};
509 return Data.PivotIndicesMember;
542 P.Diagonal().SetAll(1.0);
544 for (rowIndex = 0; rowIndex <
MIN_MN; ++rowIndex) {
545 colIndex = pivotIndices[rowIndex] - 1;
546 P.ExchangeColumns(rowIndex, colIndex);
574 L.Diagonal().SetAll(1.0);
576 for (rowIndex = 0; rowIndex < _rows; ++rowIndex) {
577 for (colIndex = 0; colIndex < _cols; ++colIndex) {
578 if (rowIndex > colIndex) {
579 L.Element(rowIndex, colIndex) = A.Element(rowIndex, colIndex);
581 U.Element(rowIndex, colIndex) = A.Element(rowIndex, colIndex);
717template <
class _matrixOwnerType>
723 CISSTNETLIB_INTEGER info;
726 if (!A.IsColMajor()) {
727 cmnThrow(std::runtime_error(
"nmrLU: Input must use VCT_COL_MAJOR storage order."));
730 if ((dataFriend.
M() != A.rows()) || (dataFriend.
N() != A.cols())) {
731 cmnThrow(std::runtime_error(
"nmrLU: Size used for Allocate was different."));
734 if (! A.IsCompact()) {
735 cmnThrow(std::runtime_error(
"nmrLU: Requires a compact matrix."));
738 CISSTNETLIB_INTEGER m = dataFriend.
M();
739 CISSTNETLIB_INTEGER n = dataFriend.
N();
740 CISSTNETLIB_INTEGER lda = (m > 1) ? m : 1;
743#if defined(CISSTNETLIB_VERSION_MAJOR)
744#if (CISSTNETLIB_VERSION_MAJOR >= 3)
745 cisstNetlib_dgetrf_(&m, &n,
772template <
class _matrixOwnerTypeA,
class _vectorOwnerTypePivotIndices>
777 return nmrLU(A, data);
808template <vct::
size_type _rows, vct::
size_type _cols, vct::
size_type _minmn>
812#if CMN_ASSERT_IS_DEFINED
816 CMN_ASSERT(minmn ==
static_cast<CISSTNETLIB_INTEGER
>(_minmn));
818 CISSTNETLIB_INTEGER info;
819 CISSTNETLIB_INTEGER lda = (_rows> 1) ? _rows : 1;
820 CISSTNETLIB_INTEGER m = _rows;
821 CISSTNETLIB_INTEGER n = _cols;
824#if defined(CISSTNETLIB_VERSION_MAJOR)
825#if (CISSTNETLIB_VERSION_MAJOR >= 3)
826 cisstNetlib_dgetrf_(&m, &n,
828 pivotIndices.
Pointer(), &info);
833 pivotIndices.
Pointer(), &info);
860template <vct::
size_type _rows, vct::
size_type _cols>
size_type N(void)
Definition nmrLU.h:311
vctDynamicVectorRef< CISSTNETLIB_INTEGER > & PivotIndices(void)
Definition nmrLU.h:305
Friend(nmrLUDynamicData &data)
Definition nmrLU.h:303
size_type M(void)
Definition nmrLU.h:308
Data of LU problem (Dynamic).
Definition nmrLU.h:82
nmrLUDynamicData(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
Definition nmrLU.h:357
nmrLUDynamicData(size_type m, size_type n)
Definition nmrLU.h:342
void ThrowUnlessOutputSizeIsCorrect(vctDynamicVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &pivotIndices) CISST_THROW(std
Definition nmrLU.h:152
nmrLUDynamicData(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &pivotIndices)
Definition nmrLU.h:375
size_type NMember
Definition nmrLU.h:107
vctDynamicVectorRef< CISSTNETLIB_INTEGER > PivotIndicesReference
Definition nmrLU.h:101
nmrLUDynamicData()
Definition nmrLU.h:326
vctFixedSizeVector< size_type, 2 > nsize_type
Definition nmrLU.h:92
const vctDynamicVectorRef< CISSTNETLIB_INTEGER > & PivotIndices(void) const
Definition nmrLU.h:435
vct::size_type size_type
Definition nmrLU.h:90
void SetRef(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &pivotIndices) CISST_THROW(std
Definition nmrLU.h:422
size_type MMember
Definition nmrLU.h:106
static nsize_type MatrixUSize(const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
Definition nmrLU.h:208
static nsize_type MatrixPSize(const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
Definition nmrLU.h:177
static vctDynamicMatrixBase< _matrixOwnerTypeP, CISSTNETLIB_DOUBLE > & UpdateMatrixP(const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, const vctDynamicConstVectorBase< _vectorOwnerTypePivotIndices, CISSTNETLIB_INTEGER > &pivotIndices, vctDynamicMatrixBase< _matrixOwnerTypeP, CISSTNETLIB_DOUBLE > &P) CISST_THROW(std
Definition nmrLU.h:227
void Allocate(size_type m, size_type n)
Definition nmrLU.h:403
static nsize_type MatrixLSize(const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
Definition nmrLU.h:192
vctDynamicVector< CISSTNETLIB_INTEGER > OutputMemory
Definition nmrLU.h:96
void Allocate(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
Definition nmrLU.h:391
static void UpdateMatrixLU(const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicMatrixBase< _matrixOwnerTypeL, CISSTNETLIB_DOUBLE > &L, vctDynamicMatrixBase< _matrixOwnerTypeU, CISSTNETLIB_DOUBLE > &U) CISST_THROW(std
Definition nmrLU.h:267
void SetDimension(size_type m, size_type n)
Definition nmrLU.h:114
void AllocateOutput(bool allocateOutput)
Definition nmrLU.h:132
Friend(nmrLUFixedSizeData< _rows, _cols > &data)
Definition nmrLU.h:506
VectorTypePivotIndices & PivotIndices(void)
Definition nmrLU.h:508
Data of LU problem (Fixed size).
Definition nmrLU.h:469
vct::size_type size_type
Definition nmrLU.h:472
nmrLUFixedSizeData()
Definition nmrLU.h:517
vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, MIN_MN, VCT_COL_MAJOR > MatrixTypeL
Definition nmrLU.h:486
static void UpdateMatrixLU(const MatrixTypeA &A, MatrixTypeL &L, MatrixTypeU &U) CISST_THROW(std
Definition nmrLU.h:567
vctFixedSizeVector< CISSTNETLIB_INTEGER, MIN_MN > VectorTypePivotIndices
Definition nmrLU.h:480
vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _rows, VCT_COL_MAJOR > MatrixTypeP
Definition nmrLU.h:483
@ MIN_MN
Definition nmrLU.h:473
const VectorTypePivotIndices & PivotIndices(void) const
Definition nmrLU.h:522
static MatrixTypeP & UpdateMatrixP(const VectorTypePivotIndices &pivotIndices, MatrixTypeP &P) CISST_THROW(std
Definition nmrLU.h:536
vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, VCT_COL_MAJOR > MatrixTypeA
Definition nmrLU.h:477
vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, MIN_MN, _cols, VCT_COL_MAJOR > MatrixTypeU
Definition nmrLU.h:489
VectorTypePivotIndices PivotIndicesMember
Definition nmrLU.h:492
Definition vctForwardDeclarations.h:145
Definition vctForwardDeclarations.h:119
Definition vctDynamicMatrixBase.h:43
Definition vctDynamicVectorBase.h:62
pointer Pointer(index_type index=0)
Definition vctDynamicVectorBase.h:155
Definition vctForwardDeclarations.h:131
Dynamic vector referencing existing memory.
Definition vctDynamicVectorRef.h:78
void SetRef(size_type size, pointer data, stride_type stride=1)
Definition vctDynamicVectorRef.h:156
pointer Pointer(size_type rowIndex, size_type colIndex)
Definition vctFixedSizeMatrixBase.h:161
Implementation of a fixed-size matrix using template metaprogramming.
Definition vctFixedSizeMatrix.h:54
pointer Pointer(size_type index=0)
Definition vctFixedSizeVectorBase.h:226
Implementation of a fixed-size vector using template metaprogramming.
Definition vctFixedSizeVector.h:54
#define CMN_ASSERT(expr)
Definition cmnAssert.h:97
#define CISST_THROW(exceptionParameter)
Somewhat portable compilation warning message. This works with very recent versions of gcc (4....
Definition cmnPortability.h:559
Declaration of the template function cmnThrow.
void cmnThrow(const _exceptionType &except, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_ERROR)
Definition cmnThrow.h:76
size_t size_type
Definition vctContainerTraits.h:35
CISSTNETLIB_INTEGER nmrLU(vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > &A, nmrLUDynamicData &data) CISST_THROW(std
Definition nmrLU.h:718
size_type cols() const
Definition vctDynamicConstMatrixBase.h:243
size_type rows() const
Definition vctDynamicConstMatrixBase.h:238
Declaration of vctDynamicMatrix.
Declaration of vctFixedSizeMatrix.