19 #ifndef HPP_CONSTRAINTS_SVD_HH 20 # define HPP_CONSTRAINTS_SVD_HH 26 namespace constraints {
27 template <
typename SVD>
28 static Eigen::Ref<const typename SVD::MatrixUType>
29 getU1 (
const SVD& svd,
const size_type& rank)
31 return svd.matrixU().leftCols (rank);
34 template <
typename SVD>
35 static Eigen::Ref<const typename SVD::MatrixUType>
36 getU2 (
const SVD& svd,
const size_type& rank)
38 return svd.matrixU().rightCols (svd.matrixU().cols() - rank);
41 template <
typename SVD>
42 static Eigen::Ref<const typename SVD::MatrixUType>
43 getV1 (
const SVD& svd,
const size_type& rank)
45 return svd.matrixV().leftCols (rank);
48 template <
typename SVD>
49 static Eigen::Ref<const typename SVD::MatrixUType>
50 getV2 (
const SVD& svd,
const size_type& rank)
52 return svd.matrixV().rightCols (svd.matrixV().cols() - rank);
55 template <
typename SVD>
56 static void pseudoInverse(
const SVD& svd,
57 Eigen::Ref <typename SVD::MatrixType> pinvmat)
59 eigen_assert(svd.computeU() && svd.computeV() &&
"Eigen::JacobiSVD " 60 "computation flags must be at least: ComputeThinU | ComputeThinV");
63 typename SVD::SingularValuesType singularValues_inv =
64 svd.singularValues().segment (0,rank).cwiseInverse ();
67 getV1<SVD> (svd, rank) * singularValues_inv.asDiagonal() *
68 getU1<SVD> (svd, rank).adjoint();
71 template <
typename SVD >
73 Eigen::Ref <typename SVD::MatrixType> projector)
75 eigen_assert(svd.computeU() && svd.computeV() &&
"Eigen::JacobiSVD " 76 "computation flags must be at least: ComputeThinU | ComputeThinV");
79 projector.noalias() = getV1<SVD> (svd, rank) * getV1<SVD>(svd, rank).adjoint();
82 template <
typename SVD >
84 Eigen::Ref <typename SVD::MatrixType> projector)
86 eigen_assert(svd.computeU() && svd.computeV() &&
"Eigen::JacobiSVD " 87 "computation flags must be at least: ComputeThinU | ComputeThinV");
90 projector.noalias() = getU1<SVD>(svd, rank) * getU1<SVD>(svd, rank).adjoint();
93 template <
typename SVD >
95 Eigen::Ref <typename SVD::MatrixType> projector,
96 const bool& computeFullV =
false)
98 eigen_assert(svd.computeV() &&
"Eigen::JacobiSVD " 99 "computation flags must be at least: ComputeThinV");
103 projector.noalias() = getV2<SVD> (svd, rank) * getV2<SVD>(svd, rank).adjoint();
105 projector.noalias() = - getV1<SVD> (svd, rank) * getV1<SVD>(svd, rank).adjoint();
106 projector.diagonal().noalias () += vector_t::Ones(svd.matrixV().rows());
110 template <
typename SVD >
112 Eigen::Ref <typename SVD::MatrixType> projector,
113 const bool& computeFullU =
false)
115 eigen_assert(svd.computeU() &&
"Eigen::JacobiSVD " 116 "computation flags must be at least: ComputeThinU");
121 projector.noalias() = getU2<SVD>(svd, rank) * getU2<SVD>(svd, rank).adjoint();
124 projector.noalias() = - getU1<SVD>(svd, rank) * getU1<SVD>(svd, rank).adjoint();
125 projector.diagonal().noalias () += vector_t::Ones(svd.matrixU().rows());
131 #endif // HPP_CONSTRAINTS_SVD_HH
matrix_t::Index size_type
void projectorOnKernel(const SVD &svd, Eigen::Ref< typename SVD::MatrixType > projector, const bool &computeFullV=false)
Definition: svd.hh:94
void projectorOnSpanOfInv(const SVD &svd, Eigen::Ref< typename SVD::MatrixType > projector)
Definition: svd.hh:83
void projectorOnKernelOfInv(const SVD &svd, Eigen::Ref< typename SVD::MatrixType > projector, const bool &computeFullU=false)
Definition: svd.hh:111
pinocchio::size_type size_type
Definition: fwd.hh:35
void projectorOnSpan(const SVD &svd, Eigen::Ref< typename SVD::MatrixType > projector)
Definition: svd.hh:72