speye.cpp 595 B

123456789101112131415161718192021222324252627
  1. #include "speye.h"
  2. template <typename T>
  3. IGL_INLINE void igl::speye(const int m, const int n, Eigen::SparseMatrix<T> & I)
  4. {
  5. // size of diagonal
  6. int d = (m<n?m:n);
  7. I = Eigen::SparseMatrix<T>(m,n);
  8. I.reserve(d);
  9. for(int i = 0;i<d;i++)
  10. {
  11. I.insert(i,i) = 1.0;
  12. }
  13. I.finalize();
  14. }
  15. template <typename T>
  16. IGL_INLINE void igl::speye(const int n, Eigen::SparseMatrix<T> & I)
  17. {
  18. return igl::speye(n,n,I);
  19. }
  20. #ifndef IGL_HEADER_ONLY
  21. // Explicit template specialization
  22. // generated by autoexplicit.sh
  23. template void igl::speye<double>(int, Eigen::SparseMatrix<double, 0, int>&);
  24. #endif