group_sum_matrix.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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_GROUP_SUM_MATRIX_H
  9. #define IGL_GROUP_SUM_MATRIX_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. /// Builds a matrix A such that A*V computes the sum of
  16. /// vertices in each group specified by G
  17. ///
  18. /// @tparam T should be a eigen sparse matrix primitive type like int or double
  19. /// @param[in] G #V list of group indices (0 to k-1) for each vertex, such that vertex i
  20. /// is assigned to group G(i)
  21. /// @param[in] k #groups, good choice is max(G)+1
  22. /// @param[out] A #groups by #V sparse matrix such that A*V = group_sums
  23. ///
  24. template <typename T>
  25. IGL_INLINE void group_sum_matrix(
  26. const Eigen::Matrix<int,Eigen::Dynamic,1> & G,
  27. const int k,
  28. Eigen::SparseMatrix<T>& A);
  29. /// \overload
  30. template <typename T>
  31. IGL_INLINE void group_sum_matrix(
  32. const Eigen::Matrix<int,Eigen::Dynamic,1> & G,
  33. Eigen::SparseMatrix<T>& A);
  34. }
  35. #ifndef IGL_STATIC_LIBRARY
  36. # include "group_sum_matrix.cpp"
  37. #endif
  38. #endif