print_ijv.cpp 793 B

123456789101112131415161718192021222324252627282930313233
  1. #include "print_ijv.h"
  2. #include "find.h"
  3. #include <iostream>
  4. template <typename T>
  5. IGL_INLINE void igl::print_ijv(
  6. const Eigen::SparseMatrix<T>& X,
  7. const int offset)
  8. {
  9. Eigen::Matrix<int,Eigen::Dynamic,1> I;
  10. Eigen::Matrix<int,Eigen::Dynamic,1> J;
  11. Eigen::Matrix<T,Eigen::Dynamic,1> V;
  12. igl::find(X,I,J,V);
  13. // Concatenate I,J,V
  14. Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> IJV(I.size(),3);
  15. IJV.col(0) = I.cast<T>();
  16. IJV.col(1) = J.cast<T>();
  17. IJV.col(2) = V;
  18. // Offset
  19. if(offset != 0)
  20. {
  21. IJV.col(0).array() += offset;
  22. IJV.col(1).array() += offset;
  23. }
  24. std::cout<<IJV;
  25. }
  26. #ifndef IGL_HEADER_ONLY
  27. // Explicit template specialization
  28. // generated by autoexplicit.sh
  29. template void igl::print_ijv<double>(Eigen::SparseMatrix<double, 0, int> const&, int);
  30. #endif