TMtxType DetectMtxType(bool CheckPosDef = false);
Determines type of the matrix.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | CheckPosDef = false | bool |
Remarks:
Tests the calling matrix and returns the TMtxType of the calling of matrix. The following types are supported:
- TMtxType::mtSymmPosDef = symmetric positive definite matrix
- TMtxType::mtSymmetric = symmetric matrix
- TMtxType::mtHermPosDef = Hermitian positve definite matrix
- TMtxType::mtHermitian = Hermitian matrix
- TMtxType::mtTriangle = triangular matrix, with unit or non unit main diagonal
- TMtxType::mtGeneral = general matrix (none of the above)
Checking for positive definite matrix can be very expensive (O(n) = 1/3*n^3). Therefore the ChekPosDef parameter is False by default, unless the user specifies otherwise. The method will not detect banded matrix storage.
Examples
#include "MtxVec.h"
#include "Units.MtxVec.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxVec;
void Example()
{
TVec *X, *B;
TMtx* A;
TMtxType at;
CreateIt(X, B);
CreateIt(A);
B->SetIt(false, DewArray<double>{0, 2});
A->SetIt(2, 2, false, DewArray<double>{1, 2,
2, 4}); // 2x2 real matrix
at = A->DetectMtxType();
A->LUSolve(B, X, at);
// This is the same for this example (except slower)
A->LUSolve(B, X, TMtxType::mtSymmetric);
// You could also specify
A->AutoMtxType = true;
A->LUSolve(B, X); // the type is autodetected
FreeIt(B, X);
FreeIt(A);
}
Declared in Dew::Math::TMtx · Dew.Math/MtxVec.h · Cross-compiler