lscm.cpp 906 B

1234567891011121314151617181920212223242526272829303132
  1. #include "lscm.h"
  2. #include "../lscm_hessian.h"
  3. #include "../massmatrix.h"
  4. #include "../repdiag.h"
  5. #include "eigs.h"
  6. template <
  7. typename DerivedV,
  8. typename DerivedF,
  9. typename DerivedV_uv>
  10. IGL_INLINE bool igl::spectra::lscm(
  11. const Eigen::MatrixBase<DerivedV> & V,
  12. const Eigen::MatrixBase<DerivedF> & F,
  13. Eigen::PlainObjectBase<DerivedV_uv> & V_uv)
  14. {
  15. using Scalar = typename DerivedV_uv::Scalar;
  16. Eigen::SparseMatrix<Scalar> Q;
  17. igl::lscm_hessian(V,F,Q);
  18. Eigen::SparseMatrix<Scalar> M;
  19. igl::massmatrix(V,F,igl::MASSMATRIX_TYPE_DEFAULT,M);
  20. Eigen::SparseMatrix<Scalar> M2;
  21. igl::repdiag(M,2,M2);
  22. Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> U;
  23. Eigen::Matrix<Scalar, Eigen::Dynamic, 1> S;
  24. if(!igl::spectra::eigs(Q,M2,3,igl::EIGS_TYPE_SM,U,S)) {
  25. return false;
  26. }
  27. V_uv.resize(V.rows(),2);
  28. V_uv<< U.col(0).head(V.rows()),U.col(0).tail(V.rows());
  29. return true;
  30. }