is_symmetric.cpp 554 B

123456789101112131415161718192021
  1. #include "is_symmetric.h"
  2. template <typename T>
  3. IGL_INLINE bool igl::is_symmetric(const Eigen::SparseMatrix<T>& A)
  4. {
  5. if(A.rows() != A.cols())
  6. {
  7. return false;
  8. }
  9. Eigen::SparseMatrix<T> AT = A.transpose();
  10. Eigen::SparseMatrix<T> AmAT = A-AT;
  11. //// Eigen screws up something with LLT if you try to do
  12. //SparseMatrix<T> AmAT = A-A.transpose();
  13. //// Eigen crashes at runtime if you try to do
  14. // return (A-A.transpose()).nonZeros() == 0;
  15. return AmAT.nonZeros() == 0;
  16. }
  17. #ifndef IGL_HEADER_ONLY
  18. // Explicit template specialization
  19. #endif