Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Humanoid Path Planner
hpp-model
Commits
ad85294f
Commit
ad85294f
authored
Oct 08, 2015
by
Joseph Mirabel
Committed by
Joseph Mirabel
Oct 23, 2015
Browse files
Add static functions to compute the projectors on kernels of a SVD decomposition
parent
f23b2e8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
include/hpp/model/eigen.hh
View file @
ad85294f
...
...
@@ -45,6 +45,49 @@ namespace hpp {
pinvmat
=
svd
.
matrixV
()
*
singularValues_inv
.
asDiagonal
()
*
svd
.
matrixU
().
adjoint
();
}
template
<
typename
SVD
>
void
projectorOnKernel
(
const
SVD
svd
,
Eigen
::
Ref
<
typename
SVD
::
MatrixType
>
projector
,
const
value_type
tolerance
=
Eigen
::
NumTraits
<
typename
SVD
::
MatrixType
::
Scalar
>::
epsilon
())
{
eigen_assert
(
svd
.
computeU
()
&&
svd
.
computeV
()
&&
"Eigen::JacobiSVD "
"computation flags must be at least: ComputeThinU | ComputeThinV"
);
const
typename
SVD
::
SingularValuesType
&
singularValues
=
svd
.
singularValues
();
typename
SVD
::
SingularValuesType
sv_invTimesSv
=
(
singularValues
.
array
()
>=
tolerance
).
select
(
SVD
::
SingularValuesType
::
Ones
(
singularValues
.
size
()),
SVD
::
SingularValuesType
::
Zero
(
singularValues
.
size
())
).
matrix
();
projector
=
svd
.
matrixV
()
*
sv_invTimesSv
.
asDiagonal
()
*
svd
.
matrixV
().
adjoint
();
}
template
<
typename
SVD
>
void
projectorOnKernelOfInv
(
const
SVD
svd
,
Eigen
::
Ref
<
typename
SVD
::
MatrixType
>
projector
,
const
value_type
tolerance
=
Eigen
::
NumTraits
<
typename
SVD
::
MatrixType
::
Scalar
>::
epsilon
())
{
eigen_assert
(
svd
.
computeU
()
&&
svd
.
computeV
()
&&
"Eigen::JacobiSVD "
"computation flags must be at least: ComputeThinU | ComputeThinV"
);
const
typename
SVD
::
SingularValuesType
&
singularValues
=
svd
.
singularValues
();
typename
SVD
::
SingularValuesType
sv_invTimesSv
=
(
singularValues
.
array
()
>=
tolerance
).
select
(
SVD
::
SingularValuesType
::
Ones
(
singularValues
.
size
()),
SVD
::
SingularValuesType
::
Zero
(
singularValues
.
size
())
).
matrix
();
projector
=
svd
.
matrixU
()
*
sv_invTimesSv
.
asDiagonal
()
*
svd
.
matrixU
().
adjoint
();
}
}
// namespace model
}
// namespace hpp
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment