filters: specialize three-state Kalman algebra - #871
Open
jordens wants to merge 1 commit into
Open
Conversation
This was referenced Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current statime Kalman filter implementation is very much vanilla textbook: three state with dense 3x3 f64 covariance data and calculations.
This implements specialized direct scalar updates instead.
It replaces general matrix operations with the equivalent scalar recurrences for
this fixed three-state model. The public filter behavior (API and quantitatively) is strictly unchanged. That assertion is unit-tested against the old dense algebra (which is kept around but does make the patch rather large): randomized tests cover prediction, every observation, and clock steering.
This has a significant impact on CPU load and code size: on the host, prediction plus all three observations is about 4.3x faster (21-25 ns instead of 93-109 ns here). On embedded STM32F7, the example uses 9.6 KiB less text; the update routine shrinks from about 1.9 KiB to 0.6 KiB.
I know statime is on hold for the big ntpd-rs work. I'm putting this out anyway because it may still become useful wherever the kalman filter ends up living.