for_each.h 905 B

123456789101112131415161718192021222324252627282930
  1. #ifndef IGL_FOR_EACH_H
  2. #define IGL_FOR_EACH_H
  3. #include "igl_inline.h"
  4. #include <Eigen/Core>
  5. #include <Eigen/Sparse>
  6. namespace igl
  7. {
  8. // FOR_EACH Call a given function for each non-zero (i.e., explicit value
  9. // might actually be ==0) in a Sparse Matrix A _in order (of storage)_. This is
  10. // useless unless func has _side-effects_.
  11. //
  12. // Inputs:
  13. // A m by n SparseMatrix
  14. // func function handle with prototype "compatible with" `void (Index i,
  15. // Index j, Scalar & v)`. Return values will be ignored.
  16. //
  17. // See also: std::for_each
  18. template <typename AType, typename Func>
  19. IGL_INLINE void for_each(
  20. const Eigen::SparseMatrix<AType> & A,
  21. const Func & func);
  22. template <typename DerivedA, typename Func>
  23. IGL_INLINE void for_each(
  24. const Eigen::DenseBase<DerivedA> & A,
  25. const Func & func);
  26. }
  27. #ifndef IGL_STATIC_LIBRARY
  28. # include "for_each.cpp"
  29. #endif
  30. #endif