normalize_row_sums.cpp 1.2 KB

12345678910111213141516171819202122232425
  1. #include "normalize_row_sums.h"
  2. template <typename DerivedV>
  3. IGL_INLINE void igl::normalize_row_sums(
  4. const Eigen::PlainObjectBase<DerivedV>& A,
  5. Eigen::PlainObjectBase<DerivedV> & B)
  6. {
  7. // Resize output
  8. B.derived().resize(A.rows(),A.cols());
  9. // loop over rows
  10. for(int i = 0; i < A.rows();i++)
  11. {
  12. typename DerivedV::Scalar sum = A.row(i).sum();
  13. assert(sum != 0);
  14. B.row(i) = A.row(i).array()/sum;
  15. }
  16. }
  17. #ifndef IGL_HEADER_ONLY
  18. // Explicit template specialization
  19. // generated by autoexplicit.sh
  20. template void igl::normalize_row_sums<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> >&);
  21. template void igl::normalize_row_sums<Eigen::Matrix<double, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&);
  22. template void igl::normalize_row_sums<Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
  23. #endif