9 #ifndef INCLUDE_TEMPLE_SYLVESTERS_CRITERION_H
10 #define INCLUDE_TEMPLE_SYLVESTERS_CRITERION_H
15 namespace Molassembler {
25 template<
typename Derived>
27 using Scalar =
typename Eigen::MatrixBase<Derived>::Scalar;
28 assert(matrix.rows() == matrix.cols());
30 const unsigned N = matrix.rows();
33 if(matrix(0, 0) <= Scalar {0.0}) {
45 if(matrix.template block<2, 2>(0, 0).determinant() <= Scalar {0.0}) {
54 if(matrix.template block<3, 3>(0, 0).determinant() <= Scalar {0.0}) {
63 if(matrix.template block<4, 4>(0, 0).determinant() <= Scalar {0.0}) {
74 for(
unsigned I = 5; I <= N; ++I) {
75 if(matrix.block(0, 0, I, I).determinant() <= Scalar {0.0}) {
90 template<
typename Derived>
92 using Scalar =
typename Eigen::MatrixBase<Derived>::Scalar;
93 assert(matrix.rows() == matrix.cols());
95 const unsigned N = matrix.rows();
98 if((matrix.array() < Scalar {0.0}).any()) {
107 for(
unsigned i = 0; i < N - 1; ++i) {
108 for(
unsigned j = 0; j < N - 1; ++j) {
109 if(matrix.template block<2, 2>(i, j).determinant() < Scalar {0.0}) {
120 for(
unsigned i = 0; i < N - 2; ++i) {
121 for(
unsigned j = 0; j < N - 2; ++j) {
122 if(matrix.template block<3, 3>(i, j).determinant() < Scalar {0.0}) {
133 for(
unsigned i = 0; i < N - 3; ++i) {
134 for(
unsigned j = 0; j < N - 3; ++j) {
135 if(matrix.template block<4, 4>(i, j).determinant() < Scalar {0.0}) {
146 for(
unsigned I = 5; I <= N; ++I) {
147 for(
unsigned i = 0; i < N - I; ++i) {
148 for(
unsigned j = 0; j < N - I; ++j) {
149 if(matrix.block(i, j, I, I).determinant() < Scalar {0.0}) {
bool positiveSemidefinite(const Eigen::MatrixBase< Derived > &matrix)
Determine whether a matrix is positive semidefinite.
Definition: SylvestersCriterion.h:91
bool positiveDefinite(const Eigen::MatrixBase< Derived > &matrix)
Determine whether a matrix is positive definite.
Definition: SylvestersCriterion.h:26