colon.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 "colon.h"
  9. #include <cstdio>
  10. template <typename L,typename S,typename H,typename T>
  11. IGL_INLINE void igl::colon(
  12. const L low,
  13. const S step,
  14. const H hi,
  15. Eigen::Matrix<T,Eigen::Dynamic,1> & I)
  16. {
  17. const int size = ((hi-low)/step)+1;
  18. I = Eigen::Matrix<T,Eigen::Dynamic,1>::LinSpaced(size,low,low+step*(size-1));
  19. }
  20. template <typename L,typename H,typename T>
  21. IGL_INLINE void igl::colon(
  22. const L low,
  23. const H hi,
  24. Eigen::Matrix<T,Eigen::Dynamic,1> & I)
  25. {
  26. return igl::colon(low,(T)1,hi,I);
  27. }
  28. template <typename T,typename L,typename H>
  29. IGL_INLINE Eigen::Matrix<T,Eigen::Dynamic,1> igl::colon(
  30. const L low,
  31. const H hi)
  32. {
  33. Eigen::Matrix<T,Eigen::Dynamic,1> I;
  34. igl::colon(low,hi,I);
  35. return I;
  36. }
  37. #ifdef IGL_STATIC_LIBRARY
  38. // Explicit template specialization
  39. // generated by autoexplicit.sh
  40. template Eigen::Matrix<int,-1,1,0,-1,1> igl::colon<int,int,int>(int, int);
  41. template Eigen::Matrix<int,-1,1,0,-1,1> igl::colon<int,int,long>(int,long);
  42. template Eigen::Matrix<int,-1,1,0,-1,1> igl::colon<int,int,long long int>(int,long long int);
  43. template Eigen::Matrix<double, -1, 1, 0, -1, 1> igl::colon<double, double, double>(double, double);
  44. // generated by autoexplicit.sh
  45. template void igl::colon<int, long, int, int>(int, long, int, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
  46. template void igl::colon<int, int, long, int>(int, int, long, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
  47. template void igl::colon<int, long, int>(int, long, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
  48. template void igl::colon<int, int, int>(int, int, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
  49. template void igl::colon<int,long long int,int>(int,long long int,Eigen::Matrix<int,-1,1,0,-1,1> &);
  50. template void igl::colon<int, int, int, int>(int, int, int, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
  51. template void igl::colon<int, long, long>(int, long, Eigen::Matrix<long, -1, 1, 0, -1, 1>&);
  52. template void igl::colon<double, double, double>(double, double, Eigen::Matrix<double, -1, 1, 0, -1, 1>&);
  53. #ifdef WIN32
  54. template void igl::colon<int, long long,long>(int, long long, class Eigen::Matrix<long,-1,1,0,-1,1> &);
  55. #endif
  56. #endif