5 #ifndef __pinocchio_algorithm_delassus_operator_base_hpp__
6 #define __pinocchio_algorithm_delassus_operator_base_hpp__
8 #include "pinocchio/algorithm/fwd.hpp"
9 #include "pinocchio/math/eigenvalues.hpp"
14 template<
typename DelassusOperatorDerived>
21 DelassusOperatorDerived & derived()
23 return static_cast<DelassusOperatorDerived &
>(*this);
25 const DelassusOperatorDerived & derived()
const
27 return static_cast<const DelassusOperatorDerived &
>(*this);
31 : power_iteration_algo(size)
35 Scalar computeLargestEigenValue(
36 const bool reset =
true,
const int max_it = 10,
const Scalar rel_tol = Scalar(1e-8))
const
38 power_iteration_algo.max_it = max_it;
39 power_iteration_algo.rel_tol = rel_tol;
41 power_iteration_algo.reset();
43 power_iteration_algo.run(derived());
45 return power_iteration_algo.largest_eigen_value;
48 template<
typename VectorLike>
49 Scalar computeLargestEigenValue(
50 const Eigen::PlainObjectBase<VectorLike> & largest_eigenvector_est,
51 const bool reset =
true,
52 const int max_it = 10,
53 const Scalar rel_tol = Scalar(1e-8))
const
55 PINOCCHIO_CHECK_ARGUMENT_SIZE(largest_eigenvector_est.size(), size());
56 power_iteration_algo.max_it = max_it;
57 power_iteration_algo.rel_tol = rel_tol;
59 power_iteration_algo.reset();
60 power_iteration_algo.principal_eigen_vector = largest_eigenvector_est;
62 power_iteration_algo.run(derived());
64 return power_iteration_algo.largest_eigen_value;
67 Scalar computeLowestEigenValue(
68 const bool reset =
true,
69 const bool compute_largest =
true,
70 const int max_it = 10,
71 const Scalar rel_tol = Scalar(1e-8))
const
73 power_iteration_algo.max_it = max_it;
74 power_iteration_algo.rel_tol = rel_tol;
76 power_iteration_algo.reset();
78 power_iteration_algo.lowest(derived(), compute_largest);
80 return power_iteration_algo.lowest_eigen_value;
83 template<
typename VectorLike1,
typename VectorLike2>
84 Scalar computeLowestEigenValue(
85 const Eigen::PlainObjectBase<VectorLike1> & largest_eigenvector_est,
86 const Eigen::PlainObjectBase<VectorLike2> & lowest_eigenvector_est,
87 const bool reset =
true,
88 const bool compute_largest =
true,
89 const int max_it = 10,
90 const Scalar rel_tol = Scalar(1e-8))
const
92 PINOCCHIO_CHECK_ARGUMENT_SIZE(largest_eigenvector_est.size(), size());
93 PINOCCHIO_CHECK_ARGUMENT_SIZE(lowest_eigenvector_est.size(), size());
95 power_iteration_algo.max_it = max_it;
96 power_iteration_algo.rel_tol = rel_tol;
98 power_iteration_algo.reset();
99 power_iteration_algo.principal_eigen_vector = largest_eigenvector_est;
100 power_iteration_algo.lowest_eigen_vector = lowest_eigenvector_est;
102 power_iteration_algo.lowest(derived(), compute_largest);
104 return power_iteration_algo.lowest_eigen_value;
107 template<
typename VectorLike>
108 void updateDamping(
const Eigen::MatrixBase<VectorLike> & vec)
110 derived().updateDamping(vec.derived());
113 void updateDamping(
const Scalar mu)
115 derived().updateDamping(mu);
118 template<
typename MatrixLike>
119 void solveInPlace(
const Eigen::MatrixBase<MatrixLike> & mat)
const
121 derived().solveInPlace(mat.const_cast_derived());
124 template<
typename MatrixLike>
125 typename PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixLike)
126 solve(
const Eigen::MatrixBase<MatrixLike> & mat)
const
128 return derived().solve(mat);
131 template<
typename MatrixDerivedIn,
typename MatrixDerivedOut>
133 const Eigen::MatrixBase<MatrixDerivedIn> & x,
134 const Eigen::MatrixBase<MatrixDerivedOut> & res)
const
136 derived().solve(x.derived(), res.const_cast_derived());
139 template<
typename MatrixIn,
typename MatrixOut>
140 void applyOnTheRight(
141 const Eigen::MatrixBase<MatrixIn> & x,
const Eigen::MatrixBase<MatrixOut> & res)
const
143 derived().applyOnTheRight(x.derived(), res.const_cast_derived());
146 template<
typename MatrixDerived>
147 typename PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixDerived)
148 operator*(
const Eigen::MatrixBase<MatrixDerived> & x)
const
150 return derived() * x.derived();
153 Eigen::DenseIndex size()
const
155 return derived().size();
157 Eigen::DenseIndex rows()
const
159 return derived().rows();
161 Eigen::DenseIndex cols()
const
163 return derived().cols();
168 return power_iteration_algo;
173 return power_iteration_algo;
Main pinocchio namespace.
Common traits structure to fully define base classes for CRTP.