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

What a step of time may be (decisions.md [time-steps]). More...

Concepts

concept  Emrys::TimeStep
 A step of time that converts to Scalar: Scalar itself, or any type with a TimeTraits, such as a floating-point number or a std::chrono::duration.

Classes

struct  Emrys::TimeTraits< Time >
 How a time type converts to a scalar, as a static member template toScalar<Scalar>(t) returning Scalar, in the unit of the parameters of the models it steps. More...
struct  Emrys::TimeTraits< Time >
 A floating-point number, taken as it is and converted to the scalar. More...
struct  Emrys::TimeTraits< std::chrono::duration< Rep, Period > >
 A std::chrono::duration, converted to seconds in the scalar by its period. More...
struct  Emrys::Steps
 A count of a fixed-step model's steps, for predict(Steps{n}). More...

Detailed Description

What a step of time may be (decisions.md [time-steps]).

A filter's predict(dt), the free predict(), a FixedStepModel, and a ContinuousTimeMarkovChain take their step as any TimeStep and convert it once, at that boundary, to their own Scalar; everything below, a process model's blocks included, takes a Scalar, so a float filter does its time arithmetic in float:

using namespace std::chrono_literals;
filter.predict(0.01); // in the unit of the model's parameters
filter.predict(10ms); // 0.01 seconds, bitwise: 10 / 1000 in the filter's scalar
  • A floating-point number is taken as it is, converted to the scalar with Scalar(dt). The scalar itself, such as an autodiff or multiprecision type, passes through unchanged.
  • A std::chrono::duration converts to seconds as its count times its period, computed in the scalar: Scalar(count) divided by the period's denominator, or times its numerator. An integer clock is a duration with its own period, such as std::chrono::duration<std::int64_t, std::ratio<1, 90000>>, and converts the same way.
  • An integer is not a time step: it would read as a time where a count of steps was meant. A fixed-step model advances by a count as predict(Steps{n}).
  • Another type becomes one by specializing TimeTraits, in a unit it chooses.

The library does no arithmetic that needs a unit of time: a block combines the step with its own continuous-time parameters, such as a spectral density, a time constant, or a chain's rates, so the step must be in the unit those are in, whatever it is. A duration is the one case where the library converts, and it converts to seconds, the unit std::chrono states every period in: a model stepped by durations has its parameters per second. Passing a duration to a model whose parameters are per hour gives wrong results the library cannot see.