22template<
typename Scalar,
typename StateKeyType>
35template<
typename Scalar,
typename StateKeyType,
typename MeasKeyType>
39 dx(all) = (H(all, all).transpose() * H(all, all)).inverse() * H(all, all).transpose() * dz(all);
48template<
typename Scalar,
typename StateKeyType,
typename MeasKeyType>
52 dx(all) = (H(all, all).transpose() * W(all, all) * H(all, all)).inverse() * H(all, all).transpose() * W(all, all) * dz(all);
60template<
typename Scalar,
typename StateKeyType,
typename MeasKeyType>
61KeyedLeastSquaresResult<Scalar, StateKeyType>
65 auto m =
static_cast<int>(H.
rows());
67 auto n =
static_cast<int>(H.
cols());
71 Q(all, all) = (H(all, all).transpose() * H(all, all)).inverse();
75 dx(all) = Q(all, all) * H(all, all).transpose() * dz(all);
76 LOG_DATA(
"dx = {}", dx(all).transpose());
79 double RSS = std::pow(dz(all).norm(), 2);
87 double sigma2 = RSS /
static_cast<double>(dof);
91 Q(all, all) *= sigma2;
92 LOG_DATA(
"variance = \n{}", Q(all, all));
94 return { .solution = dx, .variance = Q };
102template<
typename Scalar,
typename StateKeyType,
typename MeasKeyType>
103KeyedLeastSquaresResult<Scalar, StateKeyType>
107 auto m =
static_cast<int>(H.
rows());
109 auto n =
static_cast<int>(H.
cols());
113 Q(all, all) = (H(all, all).transpose() * W(all, all) * H(all, all)).inverse();
118 dx(all) = Q(all, all) * H(all, all).transpose() * W(all, all) * dz(all);
119 LOG_DATA(
"dx = {}", dx(all).transpose());
122 double RSS = dz(all).transpose() * W(all, all) * dz(all);
130 double sigma2 = RSS /
static_cast<double>(dof);
134 Q(all, all) *= sigma2;
135 LOG_DATA(
"Covariance matrix = \n{}", Q(all, all));
137 return { .solution = dx, .variance = Q };
KeyedLeastSquaresResult< Scalar, StateKeyType > solveLinearLeastSquaresUncertainties(const KeyedMatrixX< Scalar, MeasKeyType, StateKeyType > &H, const KeyedVectorX< Scalar, MeasKeyType > &dz)
Finds the "least squares" solution for the equation .
Definition KeyedLeastSquares.hpp:62
KeyedVectorX< Scalar, StateKeyType > solveLinearLeastSquares(const KeyedMatrixX< Scalar, MeasKeyType, StateKeyType > &H, const KeyedVectorX< Scalar, MeasKeyType > &dz)
Finds the "least squares" solution for the equation .
Definition KeyedLeastSquares.hpp:36
KeyedVectorX< Scalar, StateKeyType > solveWeightedLinearLeastSquares(const KeyedMatrixX< Scalar, MeasKeyType, StateKeyType > &H, const KeyedMatrixX< Scalar, MeasKeyType, MeasKeyType > &W, const KeyedVectorX< Scalar, MeasKeyType > &dz)
Finds the "weighted least squares" solution (see LeastSquares.hpp)
Definition KeyedLeastSquares.hpp:49
KeyedLeastSquaresResult< Scalar, StateKeyType > solveWeightedLinearLeastSquaresUncertainties(const KeyedMatrixX< Scalar, MeasKeyType, StateKeyType > &H, const KeyedMatrixX< Scalar, MeasKeyType, MeasKeyType > &W, const KeyedVectorX< Scalar, MeasKeyType > &dz)
Finds the "weighted least squares" solution.
Definition KeyedLeastSquares.hpp:104
#define LOG_DATA
All output which occurs repeatedly every time observations are received.
Definition Logger.hpp:29
Dynamic sized KeyedMatrix.
Definition KeyedMatrix.hpp:2055
Dynamic sized KeyedVector.
Definition KeyedMatrix.hpp:1569
const std::vector< ColKeyType > & colKeys() const
Returns the col keys.
Definition KeyedMatrix.hpp:221
decltype(auto) cols() const
Return the cols of the underlying Eigen matrix.
Definition KeyedMatrix.hpp:218
decltype(auto) rows() const
Return the rows of the underlying Eigen matrix.
Definition KeyedMatrix.hpp:74
Least Squares Uncertainties return value.
Definition KeyedLeastSquares.hpp:24
KeyedMatrixX< Scalar, StateKeyType, StateKeyType > variance
Least squares variance.
Definition KeyedLeastSquares.hpp:26
KeyedVectorX< Scalar, StateKeyType > solution
Least squares solution.
Definition KeyedLeastSquares.hpp:25
Matrix which can be accessed by keys.