GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
MatrixProperties.cpp
Go to the documentation of this file.
1
//
2
// MatrixProperties.cpp
3
// gpr_dimer
4
//
5
// Created by Maxim Masterov on 18/01/2021.
6
//
7
8
#include "
MatrixProperties.h
"
9
10
namespace
math
{
11
12
bool
MatrixProperties::isDD
(
const
gpr::EigenMatrix
& Matrix)
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
}
39
40
bool
MatrixProperties::isPD
(
const
gpr::EigenMatrix
& Matrix)
41
{
42
return
xTAx(Matrix) > 0 ? true :
false
;
43
}
44
45
bool
MatrixProperties::isPSD
(
const
gpr::EigenMatrix
& Matrix)
46
{
47
return
xTAx(Matrix) >= 0 ? true :
false
;
48
}
49
50
double
MatrixProperties::xTAx(
const
gpr::EigenMatrix
& Matrix)
51
{
52
Eigen::VectorXd
z
(Matrix.rows());
53
54
z
.setOnes();
55
56
// Just add some zeros at some positions
57
for
(
int
i = 0; i <
z
.rows(); i += 4) {
58
z
(i) = 0.;
59
}
60
61
return
z
.dot(Matrix *
z
);
62
}
63
}
// namespace math
z
@ z
Definition
Enums.h:28
MatrixProperties.h
math::MatrixProperties::isPD
bool isPD(const gpr::EigenMatrix &Matrix)
Return true if the given matrix is Positive Definite (PD).
Definition
MatrixProperties.cpp:40
math::MatrixProperties::isDD
bool isDD(const gpr::EigenMatrix &Matrix)
Return true if the given matrix is Diagonally Dominant (DD).
Definition
MatrixProperties.cpp:12
math::MatrixProperties::isPSD
bool isPSD(const gpr::EigenMatrix &Matrix)
Return true if the given matrix is Positive Semi-Definite (PSD).
Definition
MatrixProperties.cpp:45
gpr::EigenMatrix
Eigen::Matrix< double, EigenDynamic, EigenDynamic, EigenMatrixStorage > EigenMatrix
Definition
Macros.h:20
math
Definition
DistributionFunctions.cpp:10
backend
MatrixProperties.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf