floor.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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 "floor.h"
  9. #include <cmath>
  10. #include <iostream>
  11. template < typename DerivedX, typename DerivedY>
  12. IGL_INLINE void igl::floor(
  13. const Eigen::PlainObjectBase<DerivedX>& X,
  14. Eigen::PlainObjectBase<DerivedY>& Y)
  15. {
  16. using namespace std;
  17. //Y = Eigen::PlainObjectBase<DerivedY>::Zero(m,n);
  18. //#pragma omp parallel for
  19. //for(int i = 0;i<m;i++)
  20. //{
  21. // for(int j = 0;j<n;j++)
  22. // {
  23. // Y(i,j) = std::floor(X(i,j));
  24. // }
  25. //}
  26. typedef typename DerivedX::Scalar Scalar;
  27. Y = X.unaryExpr([](const Scalar &x)->Scalar{return std::floor(x);}).template cast<typename DerivedY::Scalar >();
  28. }
  29. #ifdef IGL_STATIC_LIBRARY
  30. // Explicit instanciation
  31. template void igl::floor<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  32. template void igl::floor<Eigen::Array<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Array<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
  33. template void igl::floor<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
  34. #endif