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

First and second moments (mean and covariance) of a distribution. More...

#include <EmrysFilter/Distributions/Moments.h>

Public Types

using Scalar = Scalar_
 the scalar type
using Index = Eigen::Index
 Eigen's index type.
using SpaceType = Space_
 the space the mean lives in
using VectorType = ValueVector<Space_, Scalar>
 a value, such as the mean
using DifferenceVectorType = DifferenceVector<Space_, Scalar>
 a difference, such as a residual
using MatrixType = DifferenceMatrix<Space_, Space_, Scalar>
 a matrix over differences, such as the covariance

Public Member Functions

 Moments (Index valueDimension, Index differenceDimension)
 Constructs moments with valueDimension coordinates in the mean and differenceDimension in the covariance, with uninitialized contents.
 Moments (Space_ const &space)
 Constructs moments sized for space, with uninitialized contents.
template<MatrixExpression Mean, CovarianceExpression Cov>
 Moments (Mean &&mean, Cov &&cov)
 Constructs moments from mean and cov, moving either one passed as an rvalue of the stored type.
Index valueDimension () const
Index differenceDimension () const
void resize (Index valueDimension, Index differenceDimension)
 Resizes the mean to valueDimension coordinates and the covariance to differenceDimension rows and columns.
void resize (Space_ const &space)
 Resizes the mean and covariance for space.
VectorType const & mean () const
MatrixType const & covarianceLower () const
VectorType & mean ()
MatrixType & covarianceLower ()
template<typename Path>
auto mean () const
template<typename Path>
auto covarianceLower () const
template<typename RowPath, typename ColPath>
auto covarianceLower () const
template<typename Path>
decltype(auto) mean ()
template<typename Path>
decltype(auto) covarianceLower ()

Static Public Attributes

static constexpr int ValueDimensionAtCompileTime = valueDimensionAtCompileTime<Space_>
 the length of a value, or Eigen::Dynamic
static constexpr int MaxValueDimensionAtCompileTime = maxValueDimensionAtCompileTime<Space_>
 a bound on the length of a value, or Eigen::Dynamic
static constexpr int DifferenceDimensionAtCompileTime = valueDimensionAtCompileTime<DifferenceSpace<Space_>>
 the length of a difference and the rows of a covariance, or Eigen::Dynamic
static constexpr int MaxDifferenceDimensionAtCompileTime = maxValueDimensionAtCompileTime<DifferenceSpace<Space_>>
 a bound on the length of a difference, or Eigen::Dynamic

Detailed Description

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

First and second moments (mean and covariance) of a distribution.

The mean is a value in the space, with valueDimension() coordinates, and the covariance is over its differences, with differenceDimension() rows and columns (see Spaces). See covariance matrix.

Template Parameters
Space_space of the mean (see Spaces), which sets the dimensions and the storage bounds. The space is part of the type only: none is stored, and the mean is not normalized.
Scalar_scalar type, double by default

No invariants are enforced: the covariance is not required to be symmetric or positive definite. Like Eigen matrices, fixed-size Moments are uninitialized by default. The covariance is read through covarianceLower(), the name every type with a stored covariance gives it, since what reads it reads only the lower triangle.

Constructor & Destructor Documentation

◆ Moments()

template<Space Space_, RealScalar Scalar_ = double>
template<MatrixExpression Mean, CovarianceExpression Cov>
Emrys::Moments< Space_, Scalar_ >::Moments ( Mean && mean,
Cov && cov )
inline

Constructs moments from mean and cov, moving either one passed as an rvalue of the stored type.

cov may be a diagonal, its variances.

Member Function Documentation

◆ covarianceLower() [1/5]

template<Space Space_, RealScalar Scalar_ = double>
template<typename Path>
decltype(auto) Emrys::Moments< Space_, Scalar_ >::covarianceLower ( )
inlinenodiscard
Returns
the writable covariance of the block named by Path; see covarianceLower<Path>().

◆ covarianceLower() [2/5]

template<Space Space_, RealScalar Scalar_ = double>
MatrixType & Emrys::Moments< Space_, Scalar_ >::covarianceLower ( )
inlinenodiscard
Returns
the covariance, to change it

◆ covarianceLower() [3/5]

template<Space Space_, RealScalar Scalar_ = double>
template<typename RowPath, typename ColPath>
auto Emrys::Moments< Space_, Scalar_ >::covarianceLower ( ) const
inlinenodiscard
Returns
the cross-covariance of the blocks named by RowPath and ColPath, as stored.

◆ covarianceLower() [4/5]

template<Space Space_, RealScalar Scalar_ = double>
template<typename Path>
auto Emrys::Moments< Space_, Scalar_ >::covarianceLower ( ) const
inlinenodiscard
Returns
the covariance of the block named by Path (see mean<Path>()), at its rows of differences (see diffIdx()). Unlike GaussianParams::covariance<Path>(), it reads the entries as stored, since Moments needn't be symmetric.

◆ covarianceLower() [5/5]

template<Space Space_, RealScalar Scalar_ = double>
MatrixType const & Emrys::Moments< Space_, Scalar_ >::covarianceLower ( ) const
inlinenodiscard
Returns
the covariance, over differences

◆ differenceDimension()

template<Space Space_, RealScalar Scalar_ = double>
Index Emrys::Moments< Space_, Scalar_ >::differenceDimension ( ) const
inlinenodiscard
Returns
the number of rows and columns of the covariance

◆ mean() [1/4]

template<Space Space_, RealScalar Scalar_ = double>
template<typename Path>
decltype(auto) Emrys::Moments< Space_, Scalar_ >::mean ( )
inlinenodiscard
Returns
the writable entries of the mean in the block named by Path; see mean<Path>().

◆ mean() [2/4]

template<Space Space_, RealScalar Scalar_ = double>
VectorType & Emrys::Moments< Space_, Scalar_ >::mean ( )
inlinenodiscard
Returns
the mean, to change it

◆ mean() [3/4]

template<Space Space_, RealScalar Scalar_ = double>
template<typename Path>
auto Emrys::Moments< Space_, Scalar_ >::mean ( ) const
inlinenodiscard
Returns
the entries of the mean in the block named by the path Path (a tag or a TagPath): a lazy expression, or a coefficient for a single coordinate. Moments store no space, so the path resolves at compile time, as idx() does: no resizable block may precede it.

◆ mean() [4/4]

template<Space Space_, RealScalar Scalar_ = double>
VectorType const & Emrys::Moments< Space_, Scalar_ >::mean ( ) const
inlinenodiscard
Returns
the mean

◆ resize() [1/2]

template<Space Space_, RealScalar Scalar_ = double>
void Emrys::Moments< Space_, Scalar_ >::resize ( Index valueDimension,
Index differenceDimension )
inline

Resizes the mean to valueDimension coordinates and the covariance to differenceDimension rows and columns.

Contents are unspecified afterward.

◆ resize() [2/2]

template<Space Space_, RealScalar Scalar_ = double>
void Emrys::Moments< Space_, Scalar_ >::resize ( Space_ const & space)
inline

Resizes the mean and covariance for space.

Contents are unspecified afterward.

◆ valueDimension()

template<Space Space_, RealScalar Scalar_ = double>
Index Emrys::Moments< Space_, Scalar_ >::valueDimension ( ) const
inlinenodiscard
Returns
the number of coordinates of the mean

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