Loading...
Searching...
No Matches
math::MatrixProperties Class Reference

Contains methods for checking basic matrix properties. More...

#include <backend/MatrixProperties.h>

Public Member Functions

bool isDD (const gpr::EigenMatrix &Matrix)
 Return true if the given matrix is Diagonally Dominant (DD).
bool isPD (const gpr::EigenMatrix &Matrix)
 Return true if the given matrix is Positive Definite (PD).
bool isPSD (const gpr::EigenMatrix &Matrix)
 Return true if the given matrix is Positive Semi-Definite (PSD).

Detailed Description

Contains methods for checking basic matrix properties.

Definition at line 17 of file MatrixProperties.h.

Member Function Documentation

◆ isDD()

bool math::MatrixProperties::isDD ( const gpr::EigenMatrix & Matrix)

Return true if the given matrix is Diagonally Dominant (DD).

Definition at line 12 of file MatrixProperties.cpp.

13{
14 bool res = true;
15
16 for (long i = 0; i < Matrix.rows(); ++i) {
17 double off_diag = 0.;
18 double diag = 0.;
19 for (long j = 0; j < Matrix.cols(); ++j) {
20 double coeff = Matrix(i, j);
21 if (j != i)
22 off_diag += fabs(coeff);
23 else
24 diag = fabs(coeff);
25 }
26
27 /*
28 * If absolute value of diagonal element is smaller than a sum of
29 * absolute values of off-diagonal elements matrix is not DD
30 */
31 if (fabs(diag) < fabs(off_diag)) {
32 res = false;
33 break;
34 }
35 }
36
37 return res;
38}
Eigen::MatrixXd Matrix

◆ isPD()

bool math::MatrixProperties::isPD ( const gpr::EigenMatrix & Matrix)

Return true if the given matrix is Positive Definite (PD).

Definition at line 40 of file MatrixProperties.cpp.

41{
42 return xTAx(Matrix) > 0 ? true : false;
43}

◆ isPSD()

bool math::MatrixProperties::isPSD ( const gpr::EigenMatrix & Matrix)

Return true if the given matrix is Positive Semi-Definite (PSD).

Definition at line 45 of file MatrixProperties.cpp.

46{
47 return xTAx(Matrix) >= 0 ? true : false;
48}

The documentation for this class was generated from the following files: