round.h 992 B

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_ROUND_H
  9. #define IGL_ROUND_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. namespace igl
  13. {
  14. /// Round a scalar value
  15. ///
  16. /// @param[in] x number
  17. /// @return x rounded to integer
  18. template <typename DerivedX>
  19. DerivedX round(const DerivedX r);
  20. /// Round a given matrix to nearest integers
  21. ///
  22. /// @param[in] X m by n matrix of scalars
  23. /// @param[out] Y m by n matrix of rounded integers
  24. template < typename DerivedX, typename DerivedY>
  25. IGL_INLINE void round(
  26. const Eigen::MatrixBase<DerivedX>& X,
  27. Eigen::PlainObjectBase<DerivedY>& Y);
  28. }
  29. #ifndef IGL_STATIC_LIBRARY
  30. # include "round.cpp"
  31. #endif
  32. #endif