orth.cpp 635 B

12345678910111213141516171819202122232425
  1. #include "orth.h"
  2. // Broken Implementation
  3. IGL_INLINE void igl::orth(const Eigen::MatrixXd &A, Eigen::MatrixXd &Q)
  4. {
  5. //perform svd on A = U*S*V' (V is not computed and only the thin U is computed)
  6. Eigen::JacobiSVD<Eigen::MatrixXd> svd(A, Eigen::ComputeThinU );
  7. Eigen::MatrixXd U = svd.matrixU();
  8. const Eigen::VectorXd S = svd.singularValues();
  9. //get rank of A
  10. int m = A.rows();
  11. int n = A.cols();
  12. double tol = std::max(m,n) * S.maxCoeff() * 2.2204e-16;
  13. int r = 0;
  14. for (int i = 0; i < S.rows(); ++r,++i)
  15. {
  16. if (S[i] < tol)
  17. break;
  18. }
  19. //keep r first columns of U
  20. Q = U.block(0,0,U.rows(),r);
  21. }