EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
Emrys::GaussianHistory< Space_, Scalar_, Allocator_ > Class Template Reference

The record of a Kalman filter's forward pass that a smoother runs backward over: one PredictedJoint per prediction, each with room for its smoothed Gaussian. More...

#include <EmrysFilter/Smoothers/GaussianHistory.h>

Classes

struct  Step
 One recorded prediction and its smoothed Gaussian. More...

Public Types

using Scalar = Scalar_
 the scalar type
using SpaceType = Space_
 the state space
using GaussianType = GaussianParams<Space_, Scalar_>
 the smoothed Gaussian's type
using JointType = PredictedJoint<Space_, Scalar_>
 what each step records
using allocator_type = Allocator_
 the allocator the steps come from
using Index = Eigen::Index
 Eigen's index type.
using const_iterator = typename ListType::const_iterator
 iterates the steps, oldest first

Public Member Functions

 GaussianHistory ()=default
 An empty history that keeps every step.
 GaussianHistory (Allocator_ const &allocator)
 An empty history that keeps every step, with nodes from allocator.
 GaussianHistory (Lag lag, Allocator_ const &allocator={})
 An empty history that keeps the newest lag steps, with nodes from allocator.
 GaussianHistory (GaussianHistory const &other)
 Copies the steps into nodes from other's allocator (see Allocation).
 GaussianHistory (GaussianHistory const &other, Allocator_ const &allocator)
 Copies other's steps into nodes from allocator.
 GaussianHistory (GaussianHistory &&other)=default
 Takes other's steps.
 GaussianHistory (GaussianHistory &&other, Allocator_ const &allocator)
 Moves other's steps into nodes from allocator, taking its nodes when the allocators are equal.
GaussianHistory & operator= (GaussianHistory const &other)=default
 Copies other's steps and lag.
GaussianHistory & operator= (GaussianHistory &&other)=default
 Takes other's steps and lag, as std::list's move assignment does.
allocator_type get_allocator () const
std::optional< Index > lag () const
Index size () const
bool empty () const
Step const & front () const
Step const & back () const
const_iterator begin () const
const_iterator end () const
void push (JointType joint)
 Records joint as the newest step.
void smooth (GaussianType const &latest)
 Fills every step's smoothed Gaussian by smoothStep(), from the newest back, given latest, the filter's state after the newest step: its posterior \( p(x_N \mid z_{1:N}) \), which is its own smoothed Gaussian.
void clear ()
 Drops every step, keeping the lag.

Detailed Description

template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
class Emrys::GaussianHistory< Space_, Scalar_, Allocator_ >

The record of a Kalman filter's forward pass that a smoother runs backward over: one PredictedJoint per prediction, each with room for its smoothed Gaussian.

The caller keeps it, outside the filter (decisions.md [smoothing]): push() records the PredictedJoint a filter's predictJoint() returns, and smooth() takes the filter's current state, the latest posterior, and fills every step's smoothed Gaussian by smoothStep(), from the newest step back. Updates between predictions need no recording: a step's filtered Gaussian is the posterior at the moment of the prediction that follows them.

for (auto const & z : measurements)
{
history.push(filter.predictJoint(dt));
if (!filter.update(fix(z))) { break; }
}
history.smooth(filter.state());
for (auto const & step : history) { use(step.smoothed); } // x_{k|N}, oldest first
GaussianHistory()=default
An empty history that keeps every step.
void push(JointType joint)
Records joint as the newest step.
Definition GaussianHistory.h:321
void smooth(GaussianType const &latest)
Fills every step's smoothed Gaussian by smoothStep(), from the newest back, given latest,...
Definition GaussianHistory.h:344

Without a Lag it keeps every step, for fixed-interval smoothing. With a Lag of \( L \) it keeps the newest \( L \), for fixed-lag smoothing: once full, each push() reuses the oldest step's node for the new one, so it allocates nothing after the first \( L \), and after smooth() the oldest step, front(), holds \( \hat x_{k-L \mid k} \).

Fixed-lag smoothing as the backward pass over the window is that of Särkkä (2013), chapter 10, which costs \( O(L) \) backward steps per filter step; the history doesn't keep the smoothed Gaussians between calls, since a new measurement changes every one of them.

The steps live in a std::list from the allocator, one node per step, so recording never moves the steps already recorded, and a growing history asks its allocator for one node per push(), never for a larger block to copy into. Nothing else is allocated for a bounded space.

Template Parameters
Space_the state space
Scalar_scalar type, double by default
Allocator_allocator for the steps, re-bound to the list's nodes (see Allocation)
See also
smoothStep(), PredictedJoint, KalmanFilter::predictJoint(), Smoothers

Member Function Documentation

◆ back()

template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
Step const & Emrys::GaussianHistory< Space_, Scalar_, Allocator_ >::back ( ) const
inlinenodiscard
Returns
the newest step; the history must not be empty

◆ begin()

template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
const_iterator Emrys::GaussianHistory< Space_, Scalar_, Allocator_ >::begin ( ) const
inlinenodiscard
Returns
an iterator to the oldest step

◆ empty()

template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
bool Emrys::GaussianHistory< Space_, Scalar_, Allocator_ >::empty ( ) const
inlinenodiscard
Returns
whether no step is recorded

◆ end()

template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
const_iterator Emrys::GaussianHistory< Space_, Scalar_, Allocator_ >::end ( ) const
inlinenodiscard
Returns
an iterator past the newest step

◆ front()

template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
Step const & Emrys::GaussianHistory< Space_, Scalar_, Allocator_ >::front ( ) const
inlinenodiscard
Returns
the oldest step kept; the history must not be empty

◆ get_allocator()

template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
allocator_type Emrys::GaussianHistory< Space_, Scalar_, Allocator_ >::get_allocator ( ) const
inlinenodiscard
Returns
the allocator the steps come from

◆ lag()

template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
std::optional< Index > Emrys::GaussianHistory< Space_, Scalar_, Allocator_ >::lag ( ) const
inlinenodiscard
Returns
the most steps a fixed-lag history keeps, or nothing if it keeps every step

◆ push()

template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
void Emrys::GaussianHistory< Space_, Scalar_, Allocator_ >::push ( JointType joint)
inline

Records joint as the newest step.

A full fixed-lag history drops its oldest step and reuses its node.

◆ size()

template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
Index Emrys::GaussianHistory< Space_, Scalar_, Allocator_ >::size ( ) const
inlinenodiscard
Returns
the number of steps recorded, at most lag()

The documentation for this class was generated from the following file: