Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qlibs::nState Class Reference

A numerical state object. More...

#include <numa.hpp>

Inheritance diagram for qlibs::nState:
qlibs::pidController

Public Member Functions

virtual ~nState ()
 
 nState (const real_t x0=0.0_re, const real_t sn_1=0.0_re, const real_t sn_2=0.0_re) noexcept
 Constructor for the state object.
 
void init (const real_t x0=0.0_re, const real_t sn_1=0.0_re, const real_t sn_2=0.0_re) noexcept
 Initialize the state object.
 
real_t integrate (const real_t s, const real_t dt, const bool bUpdate=true) noexcept
 Perform a numerical integration step.
 
real_t derive (const real_t s, const real_t dt, const bool bUpdate=true) noexcept
 Perform a numerical derivation step by using the delta rule.
 
void setIntegrationMethod (integrationMethod m) noexcept
 Set integration method .
 
void setDerivationMethod (derivationMethod m) noexcept
 Set derivation method.
 
real_t operator() (void) const noexcept
 Get the value of the state.
 

Detailed Description

A numerical state object.

A numerical state object can be used to compute in real-time the numerical approximations of integral and derivative operations for data values sampled periodically.

Constructor & Destructor Documentation

◆ ~nState()

virtual qlibs::nState::~nState ( )
inlinevirtual

◆ nState()

qlibs::nState::nState ( const real_t x0 = 0.0_re,
const real_t sn_1 = 0.0_re,
const real_t sn_2 = 0.0_re )
inlinenoexcept

Constructor for the state object.

Parameters
[in]x0initial condition at time t(0)
[in]sn_1initial condition at time (t-1)
[in]sn_2initial condition at time (t-2)
Returns
none

Member Function Documentation

◆ derive()

real_t nState::derive ( const real_t s,
const real_t dt,
const bool bUpdate = true )
noexcept

Perform a numerical derivation step by using the delta rule.

Parameters
[in]sThe input signal
[in]dtThe time-step given in seconds.
[in]bUpdateFlag to update the states ( true by default).
Returns
The current value of the derivation step.

◆ init()

void nState::init ( const real_t x0 = 0.0_re,
const real_t sn_1 = 0.0_re,
const real_t sn_2 = 0.0_re )
noexcept

Initialize the state object.

Parameters
[in]x0initial condition at time t(0)
[in]sn_1initial condition at time (t-1)
[in]sn_2initial condition at time (t-2)
Returns
none

◆ integrate()

real_t nState::integrate ( const real_t s,
const real_t dt,
const bool bUpdate = true )
noexcept

Perform a numerical integration step.

Parameters
[in]sThe input signal
[in]dtThe time-step given in seconds.
[in]bUpdateFlag to update the states ( true by default).
Returns
The current value of the integration step.

◆ operator()()

real_t qlibs::nState::operator() ( void ) const
inlinenoexcept

Get the value of the state.

Returns
The current value of the state.

◆ setDerivationMethod()

void qlibs::nState::setDerivationMethod ( derivationMethod m)
inlinenoexcept

Set derivation method.

Parameters
[in]mThe desired derivation method. Use one of the following:

DERIVATION_2POINTS : (default) Derivative using two points.

DERIVATION_BACKWARD : Derivative using the three-point backward-difference.

DERIVATION_FORWARD : Derivative using the three-point forward-difference.

Returns
true on success, otherwise return false.

◆ setIntegrationMethod()

void qlibs::nState::setIntegrationMethod ( integrationMethod m)
inlinenoexcept

Set integration method .

Parameters
[in]mThe desired integration method. Use one of the following:

INTEGRATION_RECTANGULAR : Integrate using the Rectangular rule.

INTEGRATION_TRAPEZOIDAL : (default) Integrate using the Trapezoidal rule.

INTEGRATION_SIMPSON : Integrate using the Simpson's 1/3 rule.

INTEGRATION_QUADRATIC : Integrate using a parabola fit to three points.

Returns
true on success, otherwise return false.