EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
Discrete spaces

A discrete space is a finite set of values, such as a maneuver regime, a sensor's inlier/outlier state, or the cells of a grid. More...

Concepts

concept  Emrys::DiscreteSpace
 A type usable as a discrete space: a finite set of values.

Classes

struct  Emrys::Finite< Cardinality_, MaxCardinality_ >
 Cardinality_ unnamed values, 0 to Cardinality_ - 1, such as the cells of a grid; or a number set at run time, at most MaxCardinality_, if Cardinality_ is Eigen::Dynamic. More...
struct  Emrys::Named< Values >
 Values named by the tag types Values, in order: struct Maneuver : Named<Cruise, Turn> {};. More...
class  Emrys::DiscreteProduct< Axes >
 The product of the discrete spaces Axes: a value has one value in each axis. More...
struct  Emrys::AxisIndex< Path, N >
 An index in each leaf axis of the axis named by the path Path (a tag or a TagPath), as at() makes it, for valueOf(). More...

Functions

template<typename Path, std::integral... I>
constexpr AxisIndex< Path, sizeof...(I)> Emrys::at (I... indices)
template<typename... Values, DiscreteSpace S, typename... Paths, std::size_t... N>
constexpr Eigen::Index Emrys::valueOf (S const &space, AxisIndex< Paths, N > const &... indices)
template<DiscreteSpace S, typename... Values, typename... Paths, std::size_t... N>
requires FixedSizeSpace<S>
constexpr Eigen::Index Emrys::valueOf (AxisIndex< Paths, N > const &... indices)
 valueOf(space, indices...) in the FixedSizeSpace S, named as the first template argument: valueOf<Mode, Turn, Outlier>() (decisions.md [space-storage]).

Detailed Description

A discrete space is a finite set of values, such as a maneuver regime, a sensor's inlier/outlier state, or the cells of a grid.

It is a family separate from Spaces: its values have no differences or means, only probabilities, which stay in a real Scalar.

The leaf types are Finite, a number of unnamed values, and Named, whose values are tag types. DiscreteProduct combines axes, so a value of a product has one value in each, as a Composite has one block of coordinates for each of its blocks. Axes are named by tag types derived from a discrete space, as subspaces are:

struct Cruise {};
struct Turn {};
struct Maneuver : Named<Cruise, Turn> {};
struct Inlier {};
struct Outlier {};
struct Sensor : Named<Inlier, Outlier> {};
using Mode = DiscreteProduct<Maneuver, Sensor>; // 4 values
The product of the discrete spaces Axes: a value has one value in each axis.
Definition Discrete.h:247
Values named by the tag types Values, in order: struct Maneuver : Named<Cruise, Turn> {}...
Definition Discrete.h:195

A value is stored as its flat index in [0, cardinality()). In a DiscreteProduct, the last axis varies fastest, as in a C array, so the value of Mode with Maneuver at m and Sensor at s is 2 * m + s. A nested DiscreteProduct flattens the same way, so grouping axes doesn't change the flat index. valueOf() gives the flat index of named values, and DiscreteProduct::value() and DiscreteProduct::coordinates() convert between a flat index and one index per axis.

An axis is addressed by tag path, as a subspace is (Maneuver, or TagPath<Outer, Maneuver> when it appears more than once); a named value by its tag, or by a TagPath ending in it (TagPath<Sensor, Outlier>) when several axes share it.

Categorical is the distribution over a discrete space, and MarkovChain moves one forward in time.

Function Documentation

◆ at()

template<typename Path, std::integral... I>
AxisIndex< Path, sizeof...(I)> Emrys::at ( I... indices)
nodiscardconstexpr
Returns
the value with index indices in the axis named by the path Path, for valueOf(): one index for an axis, at<Cell>(3), or one per leaf axis, in order, for a product, at<GridCells<Position>>(3, 7). It is how an axis without names, such as a Finite one, is given its value, and a Named axis takes it too, for an index known only at run time.

◆ valueOf()

template<typename... Values, DiscreteSpace S, typename... Paths, std::size_t... N>
Eigen::Index Emrys::valueOf ( S const & space,
AxisIndex< Paths, N > const &... indices )
nodiscardconstexpr
Returns
the flat index of the value of space with the named values Values and the indices indices (see at()), which together give each leaf axis its value once, in any order. A named value is a value's tag, or a TagPath ending in one when several axes share it: valueOf<Turn, Outlier>(Mode{}), valueOf<Turn>(space, at<Cell>(3)). Naming an axis twice or leaving one out doesn't compile, and an index out of range is asserted.