speye.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  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. // Templates:
  17. // T should be a eigen sparse matrix primitive type like int or double
  18. // Inputs:
  19. // m number of rows
  20. // n number of cols
  21. // Outputs:
  22. // I m by n sparse matrix with 1's on the main diagonal
  23. template <typename T>
  24. IGL_INLINE void speye(const int n,const int m, Eigen::SparseMatrix<T> & I);
  25. // Builds an n by n sparse identity matrix like matlab's speye function
  26. // Templates:
  27. // T should be a eigen sparse matrix primitive type like int or double
  28. // Inputs:
  29. // n number of rows and cols
  30. // Outputs:
  31. // I n by n sparse matrix with 1's on the main diagonal
  32. template <typename T>
  33. IGL_INLINE void speye(const int n, Eigen::SparseMatrix<T> & I);
  34. }
  35. #ifndef IGL_STATIC_LIBRARY
  36. # include "speye.cpp"
  37. #endif
  38. #endif