sum.h 850 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef IGL_SUM_H
  2. #define IGL_SUM_H
  3. #include "igl_inline.h"
  4. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  5. #include <Eigen/Sparse>
  6. namespace igl
  7. {
  8. // Note: If your looking for dense matrix matlab like sum for eigen matrics
  9. // just use:
  10. // M.colwise().sum() or M.rowwise().sum()
  11. //
  12. // Sum the columns or rows of a sparse matrix
  13. // Templates:
  14. // T should be a eigen sparse matrix primitive type like int or double
  15. // Inputs:
  16. // X m by n sparse matrix
  17. // dim dimension along which to sum (1 or 2)
  18. // Output:
  19. // S n-long sparse vector (if dim == 1)
  20. // or
  21. // S m-long sparse vector (if dim == 2)
  22. template <typename T>
  23. IGL_INLINE void sum(
  24. const Eigen::SparseMatrix<T>& X,
  25. const int dim,
  26. Eigen::SparseVector<T>& S);
  27. }
  28. #ifdef IGL_HEADER_ONLY
  29. # include "sum.cpp"
  30. #endif
  31. #endif