ceil.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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 "ceil.h"
  9. #include <cmath>
  10. template < typename DerivedX, typename DerivedY>
  11. IGL_INLINE void igl::ceil(
  12. const Eigen::PlainObjectBase<DerivedX>& X,
  13. Eigen::PlainObjectBase<DerivedY>& Y)
  14. {
  15. using namespace std;
  16. //Y = DerivedY::Zero(m,n);
  17. //#pragma omp parallel for
  18. //for(int i = 0;i<m;i++)
  19. //{
  20. // for(int j = 0;j<n;j++)
  21. // {
  22. // Y(i,j) = std::ceil(X(i,j));
  23. // }
  24. //}
  25. typedef typename DerivedX::Scalar Scalar;
  26. Y = X.unaryExpr([](const Scalar &x)->Scalar{return std::ceil(x);}).template cast<typename DerivedY::Scalar >();
  27. }
  28. #ifdef IGL_STATIC_LIBRARY
  29. // Explicit template instantiation
  30. template void igl::ceil<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> >&);
  31. #endif