EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
KalmanFilter.h
Go to the documentation of this file.
1#pragma once
2
13
14#include <concepts>
15#include <expected>
16#include <optional>
17#include <type_traits>
18#include <utility>
19
33
34namespace Emrys
35{
36
37namespace internal
38{
39
43template <typename C>
44inline constexpr bool isKalmanState = Component<C> || (GaussianForm<Params<C>> && std::same_as<Density<Params<C>>, C>);
45
46} // namespace internal
47
53template <typename C>
54concept KalmanState = requires { requires internal::isKalmanState<C>; };
55
56namespace internal
57{
58
63template <typename C, typename M>
64[[nodiscard]] consteval auto
65kalmanUpdateType()
66{
67 if constexpr (isOtherGaussianForm<C>)
68 {
69 return std::type_identity<decltype(updateInPlace<false>(std::declval<C &>(), std::declval<M const &>()))>{};
70 }
71 else
72 {
73 using Measured =
74 typename decltype(Emrys::update(std::declval<C const &>(), std::declval<M const &>()))::value_type;
75 return std::type_identity<std::expected<
76 FilterUpdateWithScratch<
77 typename C::SpaceType,
78 typename Measured::MeasurementSpaceType,
79 Measured::BranchCount,
80 typename C::Scalar,
82 GaussianError>>{};
83 }
84}
85
86} // namespace internal
87
119template <KalmanState Component_, typename Model_, typename Method_ = DefaultMethodFor<Model_>>
121{
122 static_assert(
123 internal::predictsBy<Model_, Method_>,
124 "a filter with a fixed-step model predicts by the model's method"
125 );
126 static_assert(internal::checkPredictionMethod<Method_>());
127
129 static constexpr bool IsForm = internal::isOtherGaussianForm<Params<Component_>>;
130
131public:
132
135 using ModelType = Model_;
136 using MethodType = Method_;
138 static constexpr bool Reentrant = true;
139
141 template <Measurement M>
142 using UpdateType = typename decltype(internal::kalmanUpdateType<Params<Component_>, M>())::type;
143
145 template <Measurement M>
147
152 : m_model{std::move(model)}
153 , m_method{internal::predictionMethod(m_model, std::move(method))}
154 {}
155
157 [[nodiscard]] Model_ const &
158 model() const
159 {
160 return m_model;
161 }
162
164 [[nodiscard]] Model_ &
166 {
167 return m_model;
168 }
169
171 [[nodiscard]] Method_ const &
172 method() const
173 {
174 return m_method;
175 }
176
178 [[nodiscard]] bool
179 partitions(SpaceType const & space) const
180 {
181 return m_model.partitions(space);
182 }
183
192 template <typename... Inputs>
193 requires(!isFixedStep<Model_>)
194 [[nodiscard]] auto
195 predict(Params<Component_> & state, TimeStep<Scalar> auto const & dt, Inputs const &... inputs) const
196 {
197 return internal::predictInPlace(m_method, state, m_model, internal::toScalarTime<Scalar>(dt), inputs...);
198 }
199
203 template <typename... Inputs>
204 requires isFixedStep<Model_>
205 [[nodiscard]] auto
206 predict(Params<Component_> & state, Inputs const &... inputs) const
207 {
208 return internal::predictInPlace(state, m_model, inputs...);
209 }
210
216 template <typename... Inputs>
217 requires(!isFixedStep<Model_> && !IsForm)
219 predictJoint(Params<Component_> & state, TimeStep<Scalar> auto const & dt, Inputs const &... inputs) const
220 {
221 auto joint = Emrys::predictJoint(m_method, state, m_model, dt, inputs...);
222 state = joint.predicted;
223 return joint;
224 }
225
230 template <typename... Inputs>
231 requires(isFixedStep<Model_> && !IsForm)
233 predictJoint(Params<Component_> & state, Inputs const &... inputs) const
234 {
235 auto joint = Emrys::predictJoint(state, m_model, inputs...);
236 state = joint.predicted;
237 return joint;
238 }
239
252 template <Measurement M, typename Policy = reductions::Collapse>
253 requires(
255 && !internal::isLinearizedAbout<Policy>
256 )
257 [[nodiscard]] UpdateType<M>
258 update(Params<Component_> & state, M const & measurement, Policy const & policy = {}) const
259 {
260 return updateAbout(state, measurement, internal::NoReference{}, policy);
261 }
262
270 template <Measurement M, typename Reference, typename Policy = reductions::Collapse>
271 requires(IsForm || ReductionPolicy<Policy, internal::MeasuredUpdate<Params<Component_>, M>, Params<Component_>>)
272 [[nodiscard]] UpdateType<M>
274 Params<Component_> & state,
275 M const & measurement,
276 LinearizedAbout<Reference> const & about,
277 Policy const & policy = {}
278 ) const
279 {
280 return updateAbout(state, measurement, about, policy);
281 }
282
291 template <Measurement M, typename Policy, typename Result>
292 requires(
293 (IsForm || ReductionPolicy<Policy, internal::MeasuredUpdate<Params<Component_>, M>, Params<Component_>>)
294 && !internal::isLinearizedAbout<Policy>
295 )
296 [[nodiscard]] std::expected<void, GaussianError>
297 update(Params<Component_> & state, M const & measurement, Policy const & policy, Result & result) const
298 {
299 return updateAboutInto(state, measurement, internal::NoReference{}, policy, result);
300 }
301
308 template <Measurement M, typename Reference, typename Policy, typename Result>
310 [[nodiscard]] std::expected<void, GaussianError>
312 Params<Component_> & state,
313 M const & measurement,
314 LinearizedAbout<Reference> const & about,
315 Policy const & policy,
316 Result & result
317 ) const
318 {
319 return updateAboutInto(state, measurement, about, policy, result);
320 }
321
322private:
323
327 template <Measurement M, typename Reference, typename Policy>
328 [[nodiscard]] UpdateType<M>
329 updateAbout(
330 Params<Component_> & state,
331 M const & measurement,
332 Reference const & reference,
333 Policy const & policy
334 ) const
335 {
336 constexpr bool Statistics = internal::policyReadsStatistics<Policy>;
337 if constexpr (IsForm)
338 {
339 static_assert(
340 internal::isOneBranchInPlacePolicy<Policy>,
341 "a square-root or information form has one branch and takes Collapse, Select, or a Gate over them; "
342 "a policy of the user's own is the covariance form's (decisions.md [gaussian-forms])"
343 );
344 return internal::updateInPlace<Statistics>(
345 state,
346 measurement,
347 reference,
348 internal::oneBranchAcceptor(policy)
349 );
350 }
351 else
352 {
353 using Measured = typename decltype(internal::updateBranches<Statistics>(state, measurement))::value_type;
354 if constexpr (internal::isOneBranchInPlacePolicy<Policy> && Measured::BranchCount == 1)
355 {
356 // One branch is its own collapse, and is the new state, conditioned where it is
357 // (decisions.md [borrowed-intermediates]); a gate decides on its NIS before the state
358 // is written, so a rejection copies nothing [update-outcomes].
359 return internal::updateInPlace<Statistics>(
360 state,
361 measurement,
362 reference,
363 internal::oneBranchAcceptor(policy)
364 );
365 }
366 else if constexpr (Measured::BranchCount == std::dynamic_extent)
367 {
368 auto result = UpdateType<M>{};
369 auto const reduced = reduceBranches(state, measurement, reference, policy, *result);
370 if (!reduced)
371 {
372 return std::unexpected{reduced.error()};
373 }
374 return result;
375 }
376 else
377 {
378 auto measured = internal::updateBranches<Statistics>(state, measurement, reference);
379 if (!measured)
380 {
381 return std::unexpected{measured.error()};
382 }
383 // The policy writes what it keeps to the state, which it never reads.
384 auto out = internal::OneComponentOutput<Params<Component_>, Scalar>{state};
385 internal::reduceInto(policy, std::move(measured->branches), out);
386 auto result = internal::filterUpdate(std::move(*measured), out.added);
387 internal::MixtureEvidenceAccess::setLogKeptWeight(result, out.logWeight);
388 return result;
389 }
390 }
391 }
392
396 template <Measurement M, typename Reference, typename Policy, typename Result>
397 [[nodiscard]] std::expected<void, GaussianError>
398 updateAboutInto(
399 Params<Component_> & state,
400 M const & measurement,
401 Reference const & reference,
402 Policy const & policy,
403 Result & result
404 ) const
405 {
406 if constexpr (!IsForm && Result::BranchCount == std::dynamic_extent)
407 {
408 return reduceBranches(state, measurement, reference, policy, result);
409 }
410 else
411 {
412 auto updated = updateAbout(state, measurement, reference, policy);
413 if (!updated)
414 {
415 return std::unexpected{updated.error()};
416 }
417 result = std::move(*updated);
418 return {};
419 }
420 }
421
428 template <Measurement M, typename Reference, typename Policy, typename Result>
429 [[nodiscard]] std::expected<void, GaussianError>
430 reduceBranches(
431 Params<Component_> & state,
432 M const & measurement,
433 Reference const & reference,
434 Policy const & policy,
435 Result & result
436 ) const
437 {
438 constexpr bool Statistics = internal::policyReadsStatistics<Policy>;
439 auto const measured = internal::updateBranchesInto<Statistics>(state, measurement, result.measured, reference);
440 if (!measured)
441 {
442 return measured;
443 }
444 // The policy writes what it keeps to the state, which it never reads.
445 auto out = internal::OneComponentOutput<Params<Component_>, Scalar>{state};
446 internal::reduceInto(policy, std::move(result.measured.branches), out);
447 internal::filterUpdateInto(result.measured, out.added, result);
448 internal::MixtureEvidenceAccess::setLogKeptWeight(result, out.logWeight);
449 return {};
450 }
451
452 Model_ m_model;
453 EMRYS_FILTER_NO_UNIQUE_ADDRESS Method_ m_method;
454};
455
456namespace internal
457{
458
464template <KalmanState Component_, typename Model, typename Method, typename Allocator>
465struct RecursionFor
466{
467 using type = KalmanRecursion<Component_, Model, Method>;
468};
469
471template <KalmanState Component_, typename Model, typename Method, typename Allocator>
472using RecursionForType = typename RecursionFor<Component_, Model, Method, Allocator>::type;
473
474} // namespace internal
475
551template <
552 KalmanState Component_,
553 typename Model_,
554 typename Method_ = DefaultMethodFor<Model_>,
556 typename Upkeep_ = upkeep::None>
557 requires std::same_as<typename Recursion_::ModelType, Model_>
558 && std::same_as<typename Recursion_::MethodType, Method_>
560 : public internal::HeldUpkeep<KalmanFilter<Component_, Model_, Method_, Recursion_, Upkeep_>, Upkeep_>
561{
562 using UpkeepBase = internal::HeldUpkeep<KalmanFilter, Upkeep_>;
563
565 static constexpr bool IsForm = internal::isOtherGaussianForm<Params<Component_>>;
566
567public:
568
571 using ModelType = Model_;
572 using MethodType = Method_;
574 using RecursionType = Recursion_;
575
581 Model_ model,
584 std::type_identity_t<Upkeep_> upkeep = {}
585 )
586 : UpkeepBase{std::move(upkeep)}
587 , m_recursion{std::move(model), std::move(method)}
588 , m_state{std::move(state)}
589 {
590 internal::assertPartitions(m_recursion.model(), m_state.space());
591 }
592
596 KalmanFilter(Model_ model, Params<Component_> state, std::type_identity_t<Upkeep_> upkeep)
597 requires(!std::same_as<Upkeep_, Emrys::upkeep::None>)
598 : KalmanFilter{std::move(model), std::move(state), MethodFor<Model_, Method_>{}, std::move(upkeep)}
599 {}
600
605 KalmanFilter(Recursion_ recursion, StateType state, std::type_identity_t<Upkeep_> upkeep = {})
606 : UpkeepBase{std::move(upkeep)}
607 , m_recursion{std::move(recursion)}
608 , m_state{std::move(state)}
609 {
610 internal::assertPartitions(m_recursion.model(), m_state.space());
611 }
612
614 [[nodiscard]] StateType const &
615 state() const
616 {
617 return m_state;
618 }
619
624 [[nodiscard]] StateType &
626 {
627 return m_state;
628 }
629
633 void
635 {
636 internal::assertPartitions(m_recursion.model(), state.space());
637 m_state = std::move(state);
638 }
639
641 [[nodiscard]] RecursionType const &
642 recursion() const
643 {
644 return m_recursion;
645 }
646
648 [[nodiscard]] Model_ const &
649 model() const
650 {
651 return m_recursion.model();
652 }
653
655 [[nodiscard]] Model_ &
657 {
658 return m_recursion.model();
659 }
660
662 [[nodiscard]] Method_ const &
663 method() const
664 {
665 return m_recursion.method();
666 }
667
678 template <typename... Inputs>
679 requires(!isFixedStep<Model_>)
680 [[nodiscard]] auto
681 predict(TimeStep<Scalar> auto const & dt, Inputs const &... inputs)
682 {
683 return m_recursion.predict(m_state, internal::toScalarTime<Scalar>(dt), inputs...);
684 }
685
689 template <typename... Inputs>
690 requires(isFixedStep<Model_> && !internal::leadsWithSteps<Inputs...>)
691 [[nodiscard]] auto
692 predict(Inputs const &... inputs)
693 {
694 internal::rejectTimeStep<Inputs...>();
695 return m_recursion.predict(m_state, inputs...);
696 }
697
704 template <typename... Inputs>
705 requires isFixedStep<Model_>
706 [[nodiscard]] auto
707 predict(Steps steps, Inputs const &... inputs)
708 {
709 EMRYS_FILTER_ASSERT(steps.count >= 0 && "the number of steps must be nonnegative");
710 if constexpr (IsForm)
711 {
712 using Result = decltype(m_recursion.predict(m_state, inputs...));
713 for (Eigen::Index i = 0; i < steps.count; ++i)
714 {
715 if (Result result = m_recursion.predict(m_state, inputs...); !result)
716 {
717 return result;
718 }
719 }
720 return Result{};
721 }
722 else
723 {
724 for (Eigen::Index i = 0; i < steps.count; ++i)
725 {
726 m_recursion.predict(m_state, inputs...);
727 }
728 }
729 }
730
736 template <typename... Inputs>
737 requires(!isFixedStep<Model_> && !IsForm)
739 predictJoint(TimeStep<Scalar> auto const & dt, Inputs const &... inputs)
740 {
741 return m_recursion.predictJoint(m_state, dt, inputs...);
742 }
743
748 template <typename... Inputs>
749 requires(isFixedStep<Model_> && !IsForm && !internal::leadsWithSteps<Inputs...>)
751 predictJoint(Inputs const &... inputs)
752 {
753 internal::rejectTimeStep<Inputs...>();
754 return m_recursion.predictJoint(m_state, inputs...);
755 }
756
769 template <Measurement M, typename Policy = reductions::Collapse>
770 requires(!internal::isLinearizedAbout<Policy>)
771 [[nodiscard]] auto
772 update(M const & measurement, Policy const & policy = {})
773 {
774 return m_recursion.update(m_state, measurement, policy);
775 }
776
784 template <Measurement M, typename Reference, typename Policy = reductions::Collapse>
785 [[nodiscard]] auto
786 update(M const & measurement, LinearizedAbout<Reference> const & about, Policy const & policy = {})
787 {
788 return m_recursion.update(m_state, measurement, about, policy);
789 }
790
798 template <Measurement M, typename Policy, typename Result>
799 requires(!internal::isLinearizedAbout<Policy>)
800 [[nodiscard]] std::expected<void, GaussianError>
801 update(M const & measurement, Policy const & policy, Result & result)
802 {
803 return m_recursion.update(m_state, measurement, policy, result);
804 }
805
811 template <Measurement M, typename Reference, typename Policy, typename Result>
812 [[nodiscard]] std::expected<void, GaussianError>
813 update(M const & measurement, LinearizedAbout<Reference> const & about, Policy const & policy, Result & result)
814 {
815 return m_recursion.update(m_state, measurement, about, policy, result);
816 }
817
818private:
819
820 RecursionType m_recursion;
821 StateType m_state;
822};
823
825template <typename P, typename Model>
826 requires KalmanState<Density<P>> && (!Recursion<Model>)
827KalmanFilter(Model, P) -> KalmanFilter<
828 Density<P>,
829 internal::BoundStep<Model, typename P::SpaceType, typename P::Scalar>,
830 DefaultMethodFor<Model>>;
831
832template <typename P, Recursion R>
833 requires KalmanState<Density<P>> && std::same_as<typename R::StateType, P>
834KalmanFilter(R, P) -> KalmanFilter<Density<P>, typename R::ModelType, typename R::MethodType, R>;
835
836// A third argument is a method or an upkeep, told apart by its type.
837template <typename P, typename Model, typename X>
838 requires KalmanState<Density<P>> && (!Recursion<Model>)
839KalmanFilter(Model, P, X) -> KalmanFilter<
840 Density<P>,
841 internal::BoundStep<Model, typename P::SpaceType, typename P::Scalar>,
842 internal::MethodArgumentFor<Model, X>,
843 KalmanRecursion<
844 Density<P>,
845 internal::BoundStep<Model, typename P::SpaceType, typename P::Scalar>,
846 internal::MethodArgumentFor<Model, X>>,
847 internal::UpkeepArgumentFor<X>>;
848
849template <typename P, typename Model, typename Method, typename U>
850 requires KalmanState<Density<P>>
851KalmanFilter(Model, P, Method, U) -> KalmanFilter<
852 Density<P>,
853 internal::BoundStep<Model, typename P::SpaceType, typename P::Scalar>,
854 Method,
855 KalmanRecursion<Density<P>, internal::BoundStep<Model, typename P::SpaceType, typename P::Scalar>, Method>,
856 U>;
857
858template <typename P, Recursion R, typename U>
859 requires KalmanState<Density<P>> && std::same_as<typename R::StateType, P> && internal::UpkeepArgument<U>
860KalmanFilter(R, P, U) -> KalmanFilter<Density<P>, typename R::ModelType, typename R::MethodType, R, U>;
862
863} // namespace Emrys
864
865#ifndef EMRYS_FILTER_NO_IO
866
867namespace Emrys
868{
869
870namespace internal
871{
872
874template <typename Component_, typename Model_, typename Method_, typename Recursion_, typename Upkeep_>
875void
876describe(
877 std::ostream & stream,
878 KalmanFilter<Component_, Model_, Method_, Recursion_, Upkeep_> const & filter,
879 Indent indent
880)
881{
882 describeFilter(stream, "Kalman filter", filter.state(), indent);
883}
884
885} // namespace internal
886
887} // namespace Emrys
888
889#endif // EMRYS_FILTER_NO_IO
What a container of several Gaussians needs of each one (decisions.md [component-first]): the Compone...
The upkeep a filter holds (decisions.md [upkeep]): internal::HeldUpkeep, the base that gives every fi...
The prediction and update steps of the square-root and information forms of the Gaussian (decisions....
What the four forms of the Gaussian share (decisions.md [gaussian-forms], [form-densities]): the Gaus...
The Gaussian: its parameters GaussianParams, the Gaussian that evaluates the density,...
The macros every header includes first.
The update of a Gaussian by a measurement (decisions.md [templated-measurements], [weighted-branches]...
Printing: operator<< and std::formatter for every distribution, every filter (which prints its name a...
Process models as functions with reads and writes (decisions.md [model-policies], [continuous-time-no...
The Recursion concept (decisions.md [filters-and-recursions], [user-extension-points]): what a Kalman...
Reducing an update's branches (decisions.md [weighted-branches], [reduction-policies],...
The Space concept and what every continuous space shares (decisions.md [sizes-and-dimensions]): the t...
Propagating a distribution through a function (decisions.md [method-per-measurement],...
auto predict(Inputs const &... inputs)
Moves the state forward by the fixed-step model's step, with inputs passed as in Emrys::predict(),...
Definition KalmanFilter.h:692
PredictedJoint< SpaceType, Scalar > predictJoint(Inputs const &... inputs)
Moves the state forward as predict(inputs...) does with a fixed-step model.
Definition KalmanFilter.h:751
auto update(M const &measurement, Policy const &policy={})
Conditions the state on measurement, by the measurement's own method, and reduces the branches to the...
Definition KalmanFilter.h:772
std::expected< void, GaussianError > update(M const &measurement, Policy const &policy, Result &result)
As update(measurement, policy), but into result, the update inside the std::expected that update() re...
Definition KalmanFilter.h:801
KalmanFilter(Recursion_ recursion, StateType state, std::type_identity_t< Upkeep_ > upkeep={})
A filter that runs recursion, the library's or one of the user's own (see Recursion),...
Definition KalmanFilter.h:605
auto predict(TimeStep< Scalar > auto const &dt, Inputs const &... inputs)
Moves the state forward by dt, any TimeStep (see Time steps), through the process model,...
Definition KalmanFilter.h:681
KalmanFilter(Model_ model, Params< Component_ > state, MethodFor< Model_, Method_ > method={}, std::type_identity_t< Upkeep_ > upkeep={})
A filter with process model model, initial state state, prediction method method, and upkeep upkeep,...
Definition KalmanFilter.h:580
Model_ & model()
Definition KalmanFilter.h:656
void setState(StateType state)
Replaces the state estimate, as when reinitializing, with one whose space the process model's writes ...
Definition KalmanFilter.h:634
StateType & state()
Definition KalmanFilter.h:625
PredictedJoint< SpaceType, Scalar > predictJoint(TimeStep< Scalar > auto const &dt, Inputs const &... inputs)
Moves the state forward as predict(dt, inputs...) does.
Definition KalmanFilter.h:739
std::expected< void, GaussianError > update(M const &measurement, LinearizedAbout< Reference > const &about, Policy const &policy, Result &result)
As update(measurement, about, policy), but into result, as update(measurement, policy,...
Definition KalmanFilter.h:813
auto update(M const &measurement, LinearizedAbout< Reference > const &about, Policy const &policy={})
Conditions the state on measurement as update(measurement, policy) does, with the measurement lineari...
Definition KalmanFilter.h:786
KalmanFilter(Model_ model, Params< Component_ > state, std::type_identity_t< Upkeep_ > upkeep)
A filter with process model model, initial state state, the default prediction method,...
Definition KalmanFilter.h:596
auto predict(Steps steps, Inputs const &... inputs)
Moves the state forward by steps of the fixed-step model, as that many calls of predict(inputs....
Definition KalmanFilter.h:707
The Kalman filter's steps over one component, without the state: a process model and a prediction met...
Definition KalmanFilter.h:121
Model_ & model()
Definition KalmanFilter.h:165
Params< Component_ > StateType
the state the steps act on
Definition KalmanFilter.h:137
UpdateType< M > update(Params< Component_ > &state, M const &measurement, LinearizedAbout< Reference > const &about, Policy const &policy={}) const
Conditions state on measurement as update(state, measurement, policy) does, with the measurement line...
Definition KalmanFilter.h:273
PredictedJoint< SpaceType, Scalar > predictJoint(Params< Component_ > &state, TimeStep< Scalar > auto const &dt, Inputs const &... inputs) const
Moves state forward as predict(state, dt, inputs...) does.
Definition KalmanFilter.h:219
UpdateType< M > update(Params< Component_ > &state, M const &measurement, Policy const &policy={}) const
Conditions state on measurement, by the measurement's own method, and reduces the branches to the new...
Definition KalmanFilter.h:258
std::expected< void, GaussianError > update(Params< Component_ > &state, M const &measurement, LinearizedAbout< Reference > const &about, Policy const &policy, Result &result) const
update(state, measurement, about, policy) into result, as update(state, measurement,...
Definition KalmanFilter.h:311
auto predict(Params< Component_ > &state, Inputs const &... inputs) const
Moves state forward by the fixed-step model's step, with inputs passed as in Emrys::predict(),...
Definition KalmanFilter.h:206
typename Params< Component_ >::Scalar Scalar
the scalar type
Definition KalmanFilter.h:133
Model_ ModelType
the process model
Definition KalmanFilter.h:135
KalmanRecursion(Model_ model, MethodFor< Model_, Method_ > method={})
The recursion with process model model and prediction method method; a fixed-step model carries its o...
Definition KalmanFilter.h:151
bool partitions(SpaceType const &space) const
Definition KalmanFilter.h:179
typename Params< Component_ >::SpaceType SpaceType
the state space
Definition KalmanFilter.h:134
std::expected< void, GaussianError > update(Params< Component_ > &state, M const &measurement, Policy const &policy, Result &result) const
update(state, measurement, policy) into result, a ResultType: the form every recursion has,...
Definition KalmanFilter.h:297
static constexpr bool Reentrant
Definition KalmanFilter.h:138
Model const & model() const
Definition KalmanFilter.h:158
Method_ MethodType
the prediction method
Definition KalmanFilter.h:136
typename UpdateType< M >::value_type ResultType
What update() with M fills when given a result: the FilterUpdate of UpdateType.
Definition KalmanFilter.h:146
auto predict(Params< Component_ > &state, TimeStep< Scalar > auto const &dt, Inputs const &... inputs) const
Moves state forward by dt, any TimeStep (see Time steps), through the process model,...
Definition KalmanFilter.h:195
Method const & method() const
Definition KalmanFilter.h:172
typename decltype(internal::kalmanUpdateType< Params< Component_ >, M >())::type UpdateType
What update() with M returns: a FilterUpdate in a std::expected (decisions.md [innovation-cholesky]).
Definition KalmanFilter.h:142
PredictedJoint< SpaceType, Scalar > predictJoint(Params< Component_ > &state, Inputs const &... inputs) const
Moves state forward as predict(state, inputs...) does with a fixed-step model.
Definition KalmanFilter.h:233
What a KalmanFilter holds and a KalmanRecursion acts on: a Component, such as a Gaussian,...
Definition KalmanFilter.h:54
A Recursion whose steps act on the parameters of the component Component_, the constraint a filter ov...
Definition Recursion.h:87
A reduction policy for a filter that keeps a State per update: it reduces an update's branches to at ...
Definition Reduction.h:632
A step of time that converts to Scalar: Scalar itself, or any type with a TimeTraits,...
Definition Time.h:128
std::allocator< std::byte > DefaultAllocator
The allocator a type with a run-time count uses unless given one.
Definition Allocation.h:47
#define EMRYS_FILTER_NO_UNIQUE_ADDRESS
Assertion used for programmer errors (misuse of the API).
Definition Macros.h:38
NumericError GaussianError
Reasons a Gaussian, in any of its forms (decisions.md [gaussian-forms]), can fail to give a density,...
Definition NumericError.h:45
typename ParamsOf< D >::type Params
The parameters of the density D: GaussianParams for a Gaussian, and D itself for a distribution whose...
Definition Params.h:42
typename internal::DefaultMethodOf< Model >::type DefaultMethodFor
The prediction method of a filter with process model Model, unless it is given one: Linearized,...
Definition ProcessModel.h:3220
constexpr bool isFixedStep
Whether Model is a FixedStepModel, whose predictions take no time step.
Definition ProcessModel.h:2776
PredictedJoint< typename Prior::SpaceType, typename Prior::Scalar > predictJoint(Method const &method, Prior const &prior, Model const &model, TimeStep< typename Prior::Scalar > auto const &time, Args const &... args)
Definition ProcessModel.h:3362
std::expected< CategoricalUpdate< Space, Scalar >, WeightError > update(CategoricalParams< Space, Scalar > const &prior, E const &emission)
Definition Emission.h:97
std::conditional_t< isFixedStep< Model >, ModelsMethod, Method > MethodFor
The type of a filter constructor's method argument: Method, or ModelsMethod for a fixed-step Model,...
Definition ProcessModel.h:3236
The upkeep operations, each made by its factory (decisions.md [policy-factories], [upkeep]): the acti...
Definition Upkeep.h:380
Where a step linearizes its input: a point, or a distribution, in place of the input's own mean and s...
Definition TransformArgs.h:156
One prediction step as a joint: the Gaussian the step started from, the Gaussian it predicted,...
Definition ProcessModel.h:2817
A count of a fixed-step model's steps, for predict(Steps{n}).
Definition Time.h:136
Eigen::Index count
the number of steps, at least zero
Definition Time.h:137
The upkeep a filter holds when it is given none: it takes any state, changes nothing,...
Definition Upkeep.h:889