5 #ifndef __pinocchio_algorithm_delassus_operator_dense_hpp__
6 #define __pinocchio_algorithm_delassus_operator_dense_hpp__
8 #include "pinocchio/algorithm/fwd.hpp"
9 #include "pinocchio/algorithm/delassus-operator-base.hpp"
14 template<
typename _Scalar,
int _Options>
17 typedef _Scalar Scalar;
21 RowsAtCompileTime = Eigen::Dynamic
24 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Options> Matrix;
25 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Options> Vector;
28 template<
typename _Scalar,
int _Options>
32 typedef _Scalar Scalar;
42 typedef Eigen::LLT<Matrix> CholeskyDecomposition;
45 template<
typename MatrixDerived>
48 , delassus_matrix(mat)
49 , mat_tmp(mat.rows(), mat.cols())
51 , damping(Vector::Zero(mat.rows()))
53 PINOCCHIO_CHECK_ARGUMENT_SIZE(mat.rows(), mat.cols());
56 template<
typename VectorLike>
57 void updateDamping(
const Eigen::MatrixBase<VectorLike> & vec)
60 mat_tmp = delassus_matrix;
61 mat_tmp += vec.asDiagonal();
65 void updateDamping(
const Scalar & mu)
67 updateDamping(Vector::Constant(size(), mu));
70 template<
typename MatrixLike>
71 void solveInPlace(
const Eigen::MatrixBase<MatrixLike> & mat)
const
73 llt.solveInPlace(mat.const_cast_derived());
76 template<
typename MatrixLike>
77 typename PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixLike)
78 solve(
const Eigen::MatrixBase<MatrixLike> & mat)
const
80 typename PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixLike) res(mat);
85 template<
typename MatrixDerivedIn,
typename MatrixDerivedOut>
87 const Eigen::MatrixBase<MatrixDerivedIn> & x,
88 const Eigen::MatrixBase<MatrixDerivedOut> & res)
const
90 res.const_cast_derived() = x;
91 solveInPlace(res.const_cast_derived());
94 template<
typename MatrixIn,
typename MatrixOut>
96 const Eigen::MatrixBase<MatrixIn> & x,
const Eigen::MatrixBase<MatrixOut> & res_)
const
98 MatrixOut & res = res_.const_cast_derived();
99 res.noalias() = delassus_matrix * x;
100 res.array() += damping.array() * x.array();
103 template<
typename MatrixDerived>
104 typename PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixDerived)
105 operator*(
const Eigen::MatrixBase<MatrixDerived> & x)
const
107 typedef typename PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixDerived) ReturnType;
109 PINOCCHIO_CHECK_ARGUMENT_SIZE(x.rows(), size());
110 ReturnType res(x.rows(), x.cols());
111 applyOnTheRight(x, res);
115 Eigen::DenseIndex size()
const
117 return delassus_matrix.rows();
119 Eigen::DenseIndex rows()
const
121 return delassus_matrix.rows();
123 Eigen::DenseIndex cols()
const
125 return delassus_matrix.cols();
128 Matrix matrix()
const
130 mat_tmp = delassus_matrix;
131 mat_tmp += damping.asDiagonal();
135 Matrix inverse()
const
137 Matrix res = Matrix::Identity(size(), size());
138 llt.solveInPlace(res);
143 Matrix delassus_matrix;
144 mutable Matrix mat_tmp;
145 CholeskyDecomposition llt;
Main pinocchio namespace.
Common traits structure to fully define base classes for CRTP.