normalize_rows.cpp 486 B

123456789101112131415161718192021222324
  1. #include "normalize_rows.h"
  2. IGL_INLINE void igl::normalize_rows(const Eigen::MatrixXd & A, Eigen::MatrixXd & B)
  3. {
  4. // Resize output
  5. B.resize(A.rows(),A.cols());
  6. // loop over rows
  7. for(int i = 0; i < A.rows();i++)
  8. {
  9. double length = 0;
  10. // loop over cols
  11. for(int j = 0; j < A.cols();j++)
  12. {
  13. length += A(i,j)*A(i,j);
  14. }
  15. length = sqrt(length);
  16. // loop over cols
  17. for(int j = 0; j < A.cols();j++)
  18. {
  19. B(i,j) = A(i,j) / length;
  20. }
  21. }
  22. }