EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
Emrys::ParticleSetMarginal< Source, Selection, SubSpace > Class Template Reference

Read-only view of a subset of the state entries of a ParticleSet. More...

#include <EmrysFilter/Distributions/ParticleSet.h>

Classes

struct  Element
 One particle's log-weight, as in the source, and the selected entries of its state. More...

Public Types

using Scalar = typename Source::Scalar
 the scalar type
using Index = Eigen::Index
 Eigen's index type.
using SpaceType = SubSpace
 the selected block's space
using allocator_type = typename Source::allocator_type
 the source's allocator
using ParamsType = ParticleSet<SubSpace, Scalar, allocator_type>
 what copy() returns
using MatrixType = typename ParamsType::MatrixType
 a matrix over the marginal's differences
using WeightArrayType = typename ParamsType::WeightArrayType
 one entry per particle
using LogWeightsType = typename Source::LogWeightsType
 the source's log-weights map
using IndexVectorType
 The selected state entries' indices.
using DifferenceIndexVectorType
 The selected bandwidth rows' indices.
using StateType = decltype(std::declval<Source const &>().state(Index{})(std::declval<IndexVectorType const &>()))
 The selected entries of one particle's state, a lazy expression that reads the source.
using value_type = Element
 an element, made when read
using const_iterator = internal::ElementIterator<ParticleSetMarginal>
 iterates the particles
using iterator = const_iterator
 iterates the particles; they are read-only

Public Member Functions

 ParticleSetMarginal (Source const &source, Selection const &selection, SubSpace space)
 Selects selection's coordinates, which form space.
SubSpace const & space () const
allocator_type get_allocator () const
Index size () const
Index valueDimension () const
Index differenceDimension () const
IndexVectorType const & indices () const
DifferenceIndexVectorType const & differenceIndices () const
auto states () const
auto state (Index i) const
LogWeightsType logWeights () const
Scalar logWeight (Index i) const
Element operator[] (Index i) const
const_iterator begin () const
const_iterator end () const
std::optional< MatrixType > bandwidth () const
ParamsType copy () const
ParamsType copy (allocator_type const &allocator) const
 copy() with storage from allocator.

Static Public Attributes

static constexpr int ValueDimensionAtCompileTime = valueDimensionAtCompileTime<SubSpace>
 the length of a marginal state, or Eigen::Dynamic
static constexpr int MaxValueDimensionAtCompileTime = maxValueDimensionAtCompileTime<SubSpace>
 a bound on the length of a marginal state, or Eigen::Dynamic
static constexpr int DifferenceDimensionAtCompileTime = valueDimensionAtCompileTime<DifferenceSpace<SubSpace>>
 the length of a difference and the rows of the marginal bandwidth, or Eigen::Dynamic
static constexpr int MaxDifferenceDimensionAtCompileTime
 a bound on the length of a difference, or Eigen::Dynamic

Detailed Description

template<typename Source, typename Selection, typename SubSpace>
class Emrys::ParticleSetMarginal< Source, Selection, SubSpace >

Read-only view of a subset of the state entries of a ParticleSet.

Obtained from marginal(), and held by auto: its Selection is internal, so its type is never spelled, and a function that takes one takes it as a template parameter. It checks the source's shape. Weights are those of the source. A stored bandwidth is marginalized too, which keeps the kernel density estimate exact: the marginal of a KDE is the KDE of the marginal particles with bandwidth \( H_{aa} \).

It is a random-access range over the particles, as the marginal of a mixture is over the components (decisions.md [element-marginals]): each element, made when read, holds a particle's log-weight and the selected entries of its state, read in place, so iterating copies nothing.

for (auto const & [logWeight, position] : particles.marginal<Position>())
{
position.norm(); // the particle's position, read in place
}
Scalar logWeight(Index i) const
Definition ParticleSet.h:1966
Template Parameters
SourceParticleSet
Selectionan internal::Coordinates of the index sets of the selected block, from idx() for the states and diffIdx() for the bandwidth
SubSpacespace of the selected block

Member Typedef Documentation

◆ DifferenceIndexVectorType

template<typename Source, typename Selection, typename SubSpace>
using Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::DifferenceIndexVectorType
Initial value:
internal::IndexedSize<
decltype(Selection::differences),
Source::DifferenceDimensionAtCompileTime,
Source::MaxDifferenceDimensionAtCompileTime>

The selected bandwidth rows' indices.

◆ IndexVectorType

template<typename Source, typename Selection, typename SubSpace>
using Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::IndexVectorType
Initial value:
internal::IndexedSize<
decltype(Selection::values),
Source::ValueDimensionAtCompileTime,
Source::MaxValueDimensionAtCompileTime>

The selected state entries' indices.

Member Function Documentation

◆ bandwidth()

template<typename Source, typename Selection, typename SubSpace>
std::optional< MatrixType > Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::bandwidth ( ) const
inlinenodiscard
Returns
the marginal of the stored bandwidth, if the source has one

◆ begin()

template<typename Source, typename Selection, typename SubSpace>
const_iterator Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::begin ( ) const
inlinenodiscard
Returns
an iterator to the first particle's element

◆ copy()

template<typename Source, typename Selection, typename SubSpace>
ParamsType Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::copy ( ) const
inlinenodiscard
Returns
an independent ParticleSet holding this marginal, with the source's weights, the marginal of any stored bandwidth, and the source's allocator

◆ differenceDimension()

template<typename Source, typename Selection, typename SubSpace>
Index Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::differenceDimension ( ) const
inlinenodiscard
Returns
the number of rows and columns of the marginal bandwidth

◆ differenceIndices()

template<typename Source, typename Selection, typename SubSpace>
DifferenceIndexVectorType const & Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::differenceIndices ( ) const
inlinenodiscard
Returns
the source's bandwidth rows this marginal selects

◆ end()

template<typename Source, typename Selection, typename SubSpace>
const_iterator Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::end ( ) const
inlinenodiscard
Returns
an iterator past the last particle's element

◆ get_allocator()

template<typename Source, typename Selection, typename SubSpace>
allocator_type Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::get_allocator ( ) const
inlinenodiscard
Returns
the source's allocator

◆ indices()

template<typename Source, typename Selection, typename SubSpace>
IndexVectorType const & Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::indices ( ) const
inlinenodiscard
Returns
the source's state entries this marginal selects

◆ logWeight()

template<typename Source, typename Selection, typename SubSpace>
Scalar Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::logWeight ( Index i) const
inlinenodiscard
Returns
particle i's log-weight, as in the source

◆ logWeights()

template<typename Source, typename Selection, typename SubSpace>
LogWeightsType Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::logWeights ( ) const
inlinenodiscard
Returns
the source's log-weights, unchanged by the marginal

◆ operator[]()

template<typename Source, typename Selection, typename SubSpace>
Element Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::operator[] ( Index i) const
inlinenodiscard
Returns
particle i's log-weight and the selected entries of its state, which must not outlive this view

◆ size()

template<typename Source, typename Selection, typename SubSpace>
Index Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::size ( ) const
inlinenodiscard
Returns
the number of particles

◆ space()

template<typename Source, typename Selection, typename SubSpace>
SubSpace const & Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::space ( ) const
inlinenodiscard
Returns
the selected block's space, with its parameters and size

◆ state()

template<typename Source, typename Selection, typename SubSpace>
auto Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::state ( Index i) const
inlinenodiscard
Returns
the selected entries of particle i's state, as a lazy expression

◆ states()

template<typename Source, typename Selection, typename SubSpace>
auto Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::states ( ) const
inlinenodiscard
Returns
the selected rows of the source's states, as a lazy expression

◆ valueDimension()

template<typename Source, typename Selection, typename SubSpace>
Index Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::valueDimension ( ) const
inlinenodiscard
Returns
the number of coordinates of every marginal particle

Member Data Documentation

◆ MaxDifferenceDimensionAtCompileTime

template<typename Source, typename Selection, typename SubSpace>
int Emrys::ParticleSetMarginal< Source, Selection, SubSpace >::MaxDifferenceDimensionAtCompileTime
staticconstexpr
Initial value:
=
constexpr int maxValueDimensionAtCompileTime
The largest valid value dimension of Space, or Eigen::Dynamic if it is unbounded.
Definition Space.h:258

a bound on the length of a difference, or Eigen::Dynamic


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