normalize_row_sums.cpp 1007 B

1234567891011121314151617181920212223
  1. #include "normalize_row_sums.h"
  2. template <typename DerivedA, typename DerivedB>
  3. IGL_INLINE void igl::normalize_row_sums(
  4. const Eigen::MatrixBase<DerivedA>& A,
  5. Eigen::MatrixBase<DerivedB> & 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 DerivedB::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. template void igl::normalize_row_sums<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  20. template void igl::normalize_row_sums<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
  21. #endif