Skip to content

Commit

Permalink
fixed indentation and code style
Browse files Browse the repository at this point in the history
  • Loading branch information
atrayees authored Jun 12, 2024
1 parent e7e8252 commit 322f794
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions examples/correlation_matrices/sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,27 @@ void write_to_file(std::string filename, std::vector<PointType> const& randPoint

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){
return false;
}
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)
{
return false;
}
}

//check if the matrix is positive definite
Eigen::SelfAdjointEigenSolver<MT> eigen_solver(matrix);
Eigen::SelfAdjointEigenSolver<MT> eigen_solver(matrix);

if(eigen_solver.info() != Eigen::Success) return false;
if(eigen_solver.info() != Eigen::Success)
{
return false;
}

//the matrix is positive definite if all eigenvalues are positive
return eigen_solver.eigenvalues().minCoeff() > -tol;
//the matrix is positive definite if all eigenvalues are positive
return eigen_solver.eigenvalues().minCoeff() > -tol;
}

template<typename WalkType>
Expand Down

0 comments on commit 322f794

Please sign in to comment.