123456789101112131415161718192021222324252627 |
- #include "speye.h"
- template <typename T>
- IGL_INLINE void igl::speye(const int m, const int n, Eigen::SparseMatrix<T> & I)
- {
- // size of diagonal
- int d = (m<n?m:n);
- I = Eigen::SparseMatrix<T>(m,n);
- I.reserve(d);
- for(int i = 0;i<d;i++)
- {
- I.insert(i,i) = 1.0;
- }
- I.finalize();
- }
- template <typename T>
- IGL_INLINE void igl::speye(const int n, Eigen::SparseMatrix<T> & I)
- {
- return igl::speye(n,n,I);
- }
- #ifndef IGL_HEADER_ONLY
- // Explicit template specialization
- // generated by autoexplicit.sh
- template void igl::speye<double>(int, Eigen::SparseMatrix<double, 0, int>&);
- #endif
|