diff --git a/matrix/filter.hpp b/matrix/filter.hpp index e202bb8827..53fc99d92a 100644 --- a/matrix/filter.hpp +++ b/matrix/filter.hpp @@ -6,17 +6,20 @@ namespace matrix { template void kalman_correct( - const Matrix & P, + const SquareMatrix & P, const Matrix & C, - const Matrix & R, + const SquareMatrix & R, const Vector &r, Vector & dx, + SquareMatrix & dP, float & beta ) { SquareMatrix S_I = SquareMatrix(C*P*C.T() + R).I(); - dx = P*C.T()*S_I*r; + Matrix K = P*C.T()*S_I; + dx = K*r; beta = Scalar(r.T()*S_I*r); + dP = K*C*P*(-1); } }; // namespace matrix