5 #ifndef __pinocchio_algorithm_delassus_operator_sparse_hpp__
6 #define __pinocchio_algorithm_delassus_operator_sparse_hpp__
17 template<
typename Derived>
20 typedef Eigen::SimplicialCholeskyBase<Derived>
Base;
29 template<
typename Rhs,
typename Dest,
typename Temporary>
31 const Eigen::MatrixBase<Rhs> &
b,
32 Eigen::MatrixBase<Dest> & dest,
33 Eigen::MatrixBase<Temporary> & tmp)
const
39 if (m_info != Eigen::Success)
43 tmp.noalias() = m_P *
b;
47 if (m_matrix.nonZeros() > 0)
48 derived().matrixL().solveInPlace(tmp);
50 if (m_diag.size() > 0)
51 tmp = m_diag.asDiagonal().inverse() * tmp;
53 if (m_matrix.nonZeros() > 0)
54 derived().matrixU().solveInPlace(tmp);
57 dest.noalias() = m_Pinv * tmp;
62 template<
typename SparseCholeskySolver>
65 template<
typename SparseCholeskySolver>
68 #ifdef PINOCCHIO_WITH_ACCELERATE_SUPPORT
69 template<
typename MatrixType,
int UpLo, SparseFactorization_t Solver,
bool EnforceSquare>
72 typedef Eigen::AccelerateImpl<MatrixType, UpLo, Solver, EnforceSquare> SparseCholeskySolver;
74 template<
typename Rhs,
typename Dest,
typename Temporary>
76 const SparseCholeskySolver & solver,
77 const Eigen::MatrixBase<Rhs> & mat,
78 const Eigen::MatrixBase<Dest> & dest,
79 Eigen::MatrixBase<Temporary> & )
81 dest.const_cast_derived() = solver.solve(
mat.derived());
86 template<
typename SparseCholeskySolver>
87 struct SparseSolveInPlaceMethod
89 template<
typename Rhs,
typename Dest,
typename Temporary>
91 const SparseCholeskySolver & solver,
92 const Eigen::MatrixBase<Rhs> & mat,
93 const Eigen::MatrixBase<Dest> & dest,
94 Eigen::MatrixBase<Temporary> & tmp)
98 Eigen::SimplicialCholeskyBase<SparseCholeskySolver>, SparseCholeskySolver>::
value,
99 "The solver is not a base of SimplicialCholeskyBase.");
102 const CholeskyWrapper & wrapper =
reinterpret_cast<const CholeskyWrapper &
>(solver);
103 wrapper.
_solve_impl(
mat, dest.const_cast_derived(), tmp.derived());
109 template<
typename _Scalar,
int _Options,
class _SparseCholeskyDecomposition>
122 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Options>
Vector;
123 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Options>
DenseMatrix;
126 template<
typename _Scalar,
int _Options,
class SparseCholeskyDecomposition>
128 :
DelassusOperatorBase<DelassusOperatorSparseTpl<_Scalar, _Options, SparseCholeskyDecomposition>>
144 template<
typename MatrixDerived>
156 template<
typename VectorLike>
159 for (Eigen::DenseIndex k = 0; k <
size(); ++k)
175 template<
typename MatrixLike>
182 template<
typename MatrixLike>
184 solve(
const Eigen::MatrixBase<MatrixLike> & mat)
const
191 template<
typename MatrixDerivedIn,
typename MatrixDerivedOut>
193 const Eigen::MatrixBase<MatrixDerivedIn> & x,
194 const Eigen::MatrixBase<MatrixDerivedOut> &
res)
const
196 res.const_cast_derived() =
x;
197 llt._solve_impl(x,
res.const_cast_derived());
200 template<
typename MatrixIn,
typename MatrixOut>
201 void applyOnTheRight(
202 const Eigen::MatrixBase<MatrixIn> & x,
const Eigen::MatrixBase<MatrixOut> & res_)
const
204 MatrixOut &
res = res_.const_cast_derived();
209 template<
typename MatrixDerived>
211 operator*(
const Eigen::MatrixBase<MatrixDerived> & x)
const
216 ReturnType
res(
x.rows(),
x.cols());
217 applyOnTheRight(x,
res);
221 Eigen::DenseIndex
size()
const
225 Eigen::DenseIndex
rows()
const
229 Eigen::DenseIndex
cols()
const
244 identity_matrix.setIdentity();
260 #endif // ifndef __pinocchio_algorithm_delassus_operator_sparse_hpp__