mod.cpp 978 B

1234567891011121314151617181920212223242526272829303132
  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. #warning "Constructing Eigen::PlainObjectBase directly is deprecated"
  26. Eigen::PlainObjectBase<DerivedA> B;
  27. mod(A,base,B);
  28. return B;
  29. }
  30. #ifdef IGL_STATIC_LIBRARY
  31. #endif