isdiag.cpp 955 B

1234567891011121314151617181920212223242526272829303132
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "isdiag.h"
  9. template <typename Derived>
  10. IGL_INLINE bool igl::isdiag(const Eigen::SparseCompressedBase<Derived> & A)
  11. {
  12. // Iterate over outside of A
  13. for(int k=0; k<A.outerSize(); ++k)
  14. {
  15. // Iterate over inside
  16. for(typename Derived::InnerIterator it (A,k); it; ++it)
  17. {
  18. if(it.row() != it.col() && it.value()!=0)
  19. {
  20. return false;
  21. }
  22. }
  23. }
  24. return true;
  25. }
  26. #ifdef IGL_STATIC_LIBRARY
  27. // Explicit template instantiation
  28. template bool igl::isdiag<Eigen::SparseMatrix<double,0,int>>(Eigen::SparseCompressedBase<Eigen::SparseMatrix<double,0,int>> const &);
  29. #endif