13 #include <type_traits>
29 template <
typename CovMatrix_t,
signed int NumIter = 1>
32 static bool validate(CovMatrix_t& covariance) {
33 if (covariance.hasNaN()) {
36 size_t nIteration = 0;
37 while (nIteration < NumIter) {
41 Eigen::JacobiSVD<CovMatrix_t> svdCov(
42 covariance, Eigen::ComputeFullU | Eigen::ComputeFullV);
43 CovMatrix_t S = svdCov.singularValues().asDiagonal();
44 CovMatrix_t V = svdCov.matrixV();
45 CovMatrix_t
H = V * S * V.transpose();
46 covariance = (covariance + H) / 2;
56 if (covariance.hasNaN()) {
59 Eigen::LDLT<CovMatrix_t> ldltCov(covariance);
60 return ldltCov.isPositive();
65 if (covariance.hasNaN()) {
68 Eigen::LLT<CovMatrix_t> lltCov(covariance);
69 return lltCov.info() == Eigen::Success ?
true :
false;