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

The equal-weight components of a grid over some coordinates of a space, made one at a time when read: what uniformComponents() returns. More...

#include <EmrysFilter/Distributions/UniformMixture.h>

Classes

struct  Element
 One component: its log-weight and its mean and covariance. More...

Public Types

using Scalar = Scalar_
 the scalar type
using Index = Eigen::Index
 Eigen's index type.
using SpaceType = Space_
 the space the components live in
using MomentsType = Moments<Space_, Scalar_>
 a component's mean and covariance
using VectorType = typename MomentsType::VectorType
 a value, such as a mean
using MatrixType = typename MomentsType::MatrixType
 a matrix over differences
using CountsType
 A count of cells per coordinate, zero for a coordinate that is not gridded.
using value_type = Element
 an element, made when read
using const_iterator = internal::ElementIterator<UniformGrid>
 iterates the elements
using iterator = const_iterator
 iterates the elements; they are read-only

Public Member Functions

 UniformGrid (SpaceType space, VectorType corner, VectorType width, CountsType counts, MatrixType covariance, Scalar relativeWidth)
 The grid in space over the coordinates i with counts(i) > 0, counts(i) cells across width(i) from corner(i).
SpaceType const & space () const
Index valueDimension () const
Index size () const
CountsType const & counts () const
Element operator[] (Index k) const
const_iterator begin () const
const_iterator end () const

Detailed Description

template<Space Space_, RealScalar Scalar_ = double>
class Emrys::UniformGrid< Space_, Scalar_ >

The equal-weight components of a grid over some coordinates of a space, made one at a time when read: what uniformComponents() returns.

A coordinate i with counts()(i) \( = N_i > 0 \) is gridded: its interval from \( \ell_i \) with width \( w_i \) is cut into \( N_i \) cells, and the components' means sit at the cells' centers, \( \ell_i + (j + \tfrac12) w_i / N_i \), with variance \( (c w_i / N_i)^2 \), where \( c \) is the relative width. Every other coordinate keeps its mean, and its rows and columns of the covariance, in every component. Component k is at the cell whose indices are k's digits in the mixed radix of the counts, the first gridded coordinate varying fastest, as a grid's flat cell index does.

It is a random-access range of size() elements, each a log-weight of \( -\log \prod_i N_i \) and the component's Moments, so GaussianMixtureParams::assign() fills a mixture from it:

prior.assign(uniformComponents(box, Eigen::Array2i{16, 16})); // within the capacity, allocates nothing
MixtureParams< Gaussian< Space_, Scalar_ >, Allocator_ > GaussianMixtureParams
A Mixture of Gaussians in covariance form, the spelling for the common case (decisions....
Definition Mixture.h:2072
UniformGrid< S, Scalar > uniformComponents(Uniform< S, Scalar > const &uniform, Eigen::DenseBase< CountsDerived > const &counts, std::type_identity_t< Scalar > relativeWidth=Scalar(0.6))
Definition UniformMixture.h:362
The most elements a container will hold, reserved once: a mixture's components or a particle set's pa...
Definition Allocation.h:54

A filter's starting state is made the same way, with the capacity or allocator the filter needs, and moved into the filter.

The mixture must be in space(); the elements carry no space, so the mixture's is the one the components take. The grid holds its values and borrows nothing, and its iterators borrow it.

Member Typedef Documentation

◆ CountsType

template<Space Space_, RealScalar Scalar_ = double>
using Emrys::UniformGrid< Space_, Scalar_ >::CountsType
Initial value:
internal::IndexVector<MomentsType::ValueDimensionAtCompileTime, MomentsType::MaxValueDimensionAtCompileTime>

A count of cells per coordinate, zero for a coordinate that is not gridded.

Constructor & Destructor Documentation

◆ UniformGrid()

template<Space Space_, RealScalar Scalar_ = double>
Emrys::UniformGrid< Space_, Scalar_ >::UniformGrid ( SpaceType space,
VectorType corner,
VectorType width,
CountsType counts,
MatrixType covariance,
Scalar relativeWidth )
inline

The grid in space over the coordinates i with counts(i) > 0, counts(i) cells across width(i) from corner(i).

corner holds the other coordinates' means, and covariance their rows and columns; a gridded coordinate's rows and columns must be zero, and its diagonal entry is set from relativeWidth. At least one coordinate is gridded.

Member Function Documentation

◆ begin()

template<Space Space_, RealScalar Scalar_ = double>
const_iterator Emrys::UniformGrid< Space_, Scalar_ >::begin ( ) const
inlinenodiscard
Returns
an iterator at the first component

◆ counts()

template<Space Space_, RealScalar Scalar_ = double>
CountsType const & Emrys::UniformGrid< Space_, Scalar_ >::counts ( ) const
inlinenodiscard
Returns
the count of cells along each coordinate, zero for one that is not gridded

◆ end()

template<Space Space_, RealScalar Scalar_ = double>
const_iterator Emrys::UniformGrid< Space_, Scalar_ >::end ( ) const
inlinenodiscard
Returns
an iterator past the last component

◆ operator[]()

template<Space Space_, RealScalar Scalar_ = double>
Element Emrys::UniformGrid< Space_, Scalar_ >::operator[] ( Index k) const
inlinenodiscard
Returns
component k

◆ size()

template<Space Space_, RealScalar Scalar_ = double>
Index Emrys::UniformGrid< Space_, Scalar_ >::size ( ) const
inlinenodiscard
Returns
the number of components, the product of the gridded coordinates' counts

◆ space()

template<Space Space_, RealScalar Scalar_ = double>
SpaceType const & Emrys::UniformGrid< Space_, Scalar_ >::space ( ) const
inlinenodiscard
Returns
the space the components live in

◆ valueDimension()

template<Space Space_, RealScalar Scalar_ = double>
Index Emrys::UniformGrid< Space_, Scalar_ >::valueDimension ( ) const
inlinenodiscard
Returns
the length of a component's mean

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