mod.cpp 892 B

12345678910111213141516171819202122232425262728293031323334
  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<A.rows();i++)
  17. {
  18. for(int j = 0;j<A.cols();j++)
  19. {
  20. B(i,j) = A(i,j)%base;
  21. }
  22. }
  23. }
  24. template <typename DerivedA>
  25. IGL_INLINE DerivedA igl::mod(
  26. const Eigen::PlainObjectBase<DerivedA> & A, const int base)
  27. {
  28. DerivedA B;
  29. mod(A,base,B);
  30. return B;
  31. }
  32. #ifdef IGL_STATIC_LIBRARY
  33. #endif