mod.cpp 884 B

12345678910111213141516171819202122232425262728293031
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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. #include "mod.h"
  9. template <typename DerivedA, typename DerivedB>
  10. IGL_INLINE void igl::mod(
  11. const Eigen::PlainObjectBase<DerivedA> & A,
  12. const int base,
  13. Eigen::PlainObjectBase<DerivedB> & B)
  14. {
  15. B.resize(A.rows(),A.cols());
  16. for(int i = 0;i<B.size();i++)
  17. {
  18. *(B.data()+i) = (*(A.data()+i))%base;
  19. }
  20. }
  21. template <typename DerivedA>
  22. IGL_INLINE Eigen::PlainObjectBase<DerivedA> igl::mod(
  23. const Eigen::PlainObjectBase<DerivedA> & A, const int base)
  24. {
  25. DerivedA B;
  26. mod(A,base,B);
  27. return B;
  28. }
  29. #ifdef IGL_STATIC_LIBRARY
  30. #endif