Skip to content

Commit

Permalink
fix spaces, add function parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
atrayees authored Jul 5, 2024
1 parent f70e447 commit 1ee58d1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions include/matrix_operations/EigenvaluesProblems.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,19 +442,17 @@ class EigenvaluesProblems<NT, Eigen::Matrix<NT,Eigen::Dynamic,Eigen::Dynamic>, E
/// Check if a matrix is indeed a correlation matrix
/// return true if input matrix is found to be a correlation matrix
/// |param[in] matrix
bool is_correlation_matrix(const MT& matrix){

const double tol = 1e-8;
bool is_correlation_matrix(const MT& matrix, const double tol = 1e-8){

//check if all the diagonal elements are ones
for(int i=0 ; i<matrix.rows() ; i++){
if(std::abs(matrix(i, i)-1.0) > tol){
for (int i=0 ; i<matrix.rows() ; i++){
if (std::abs(matrix(i, i)-1.0) > tol){
return false;
}
}

//check if the matrix is positive definite
if(isPositiveSemidefinite(matrix)) return true;
if (isPositiveSemidefinite(matrix)) return true;

return false;
}
Expand Down

0 comments on commit 1ee58d1

Please sign in to comment.