2
0

speye.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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. #ifndef IGL_SPEYE_H
  9. #define IGL_SPEYE_H
  10. #include "igl_inline.h"
  11. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. /// Builds an m by n sparse identity matrix like matlab's speye function
  16. /// @tparam T should be a eigen sparse matrix primitive type like int or double
  17. /// @param[in] m number of rows
  18. /// @param[in] n number of cols
  19. /// @param[out] I m by n sparse matrix with 1's on the main diagonal
  20. template <typename T>
  21. IGL_INLINE void speye(const int n,const int m, Eigen::SparseMatrix<T> & I);
  22. /// \overload
  23. /// \brief m = n
  24. template <typename T>
  25. IGL_INLINE void speye(const int n, Eigen::SparseMatrix<T> & I);
  26. }
  27. #ifndef IGL_STATIC_LIBRARY
  28. # include "speye.cpp"
  29. #endif
  30. #endif