smooth_feedback
Control and estimation on Lie groups
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Attributes | List of all members
smooth::feedback::Mesh< _Kmin, _Kmax > Class Template Reference

Collocation mesh of interval [0, 1]. More...

#include <mesh.hpp>

Public Member Functions

 Mesh ()
 Create a mesh consisting of a single interval [0, 1]. More...
 
 Mesh (const std::size_t n, const std::size_t k=Kmin)
 Create a mesh consisting of a n intervals of equal size over [0, 1]. More...
 
std::size_t N_ivals () const
 Number of intervals in mesh. More...
 
std::size_t N_colloc () const
 Number of collocation points in mesh. More...
 
std::size_t N_colloc_ival (std::size_t i) const
 Number of collocation points in interval i. More...
 
void refine_ph (std::size_t i, std::size_t D)
 Refine interval using the ph strategy. More...
 
void refine_errors (std::ranges::sized_range auto &&errs, double target_err)
 Refine intervals in mesh to satisfy a target error criterion. More...
 
void set_N_colloc_ival (std::size_t i, std::size_t K)
 Set the number of collocation points in interval i to K. More...
 
auto interval_nodes (std::size_t i) const
 Interval nodes (as range of doubles). More...
 
auto all_nodes () const
 Nodes (as range of doubles). More...
 
auto interval_weights (std::size_t i) const
 Interval weights (as range of doubles) More...
 
auto all_weights () const
 Weights (as range of doubles) More...
 
Eigen::MatrixXd interval_diffmat (std::size_t i) const
 Interval differentiation matrix w.r.t. [0, 1] timescale. More...
 
std::pair< double, MatMap > interval_diffmat_unscaled (std::size_t i) const
 Interval differentiation matrix (unscaled). More...
 
Eigen::MatrixXd interval_intmat (std::size_t i) const
 Interval integration matrix w.r.t. [0, 1] timescale. More...
 
std::size_t interval_find (double t) const
 Find interval index that contains t. More...
 
void increase_degrees ()
 Increase the degree of all intervals by one (up to maximal degree Kmax + 1) More...
 
void decrease_degrees ()
 Decrease the degree of all intervals by one (down to minimal degree Kmin) More...
 
template<smooth::RnType RetT>
RetT eval (double t, std::ranges::range auto &&r, std::size_t p=0, bool extend=true) const
 Evaluate a function. More...
 

Static Public Attributes

static constexpr auto Kmin = _Kmin
 Minimal number of collocation points per interval. More...
 
static constexpr auto Kmax = _Kmax
 Maximal number of collocation points per interval. More...
 

Detailed Description

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
requires (_Kmin <= _Kmax)
class smooth::feedback::Mesh< _Kmin, _Kmax >

Collocation mesh of interval [0, 1].

Template Parameters
_Kminminimal number of collocation points per interval
_Kmaxmaximal number of collocation points per interval

[0, 1] is divided into non-overlapping intervals I_i, and each interval I_i has K_i LGR collocation points.

Definition at line 62 of file mesh.hpp.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
smooth::feedback::Mesh< _Kmin, _Kmax >::Mesh ( )
inline

Create a mesh consisting of a single interval [0, 1].

Parameters
Kminminimal polynomial degree in mesh
Kmaxmaximal polynomial degree in mesh
Note
It must hold that kKmin <= Kmin <= Kmax <= kKmax, where kKmin and kKmax are compile-time constants that define which LGR nodes to pre-compute.
Allocates heap memory.

Definition at line 83 of file mesh.hpp.

◆ Mesh() [2/2]

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
smooth::feedback::Mesh< _Kmin, _Kmax >::Mesh ( const std::size_t  n,
const std::size_t  k = Kmin 
)
inline

Create a mesh consisting of a n intervals of equal size over [0, 1].

Parameters
nnumber of intervals. If n==0, only a single interval is created.
kpolynomial degree for all intervals
Note
Allocates heap memory.

Definition at line 93 of file mesh.hpp.

Member Function Documentation

◆ all_nodes()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
auto smooth::feedback::Mesh< _Kmin, _Kmax >::all_nodes ( ) const
inline

Nodes (as range of doubles).

Note
Includes extra point at 1, i.e. size of returned range is equal to N_colloc()+1
The result is an input range

Definition at line 239 of file mesh.hpp.

◆ all_weights()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
auto smooth::feedback::Mesh< _Kmin, _Kmax >::all_weights ( ) const
inline

Weights (as range of doubles)

Note
Includes zero weight at 1, i.e. size of returned range is equal to N_colloc()+1
The result is an input range

Definition at line 287 of file mesh.hpp.

◆ decrease_degrees()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
void smooth::feedback::Mesh< _Kmin, _Kmax >::decrease_degrees ( )
inline

Decrease the degree of all intervals by one (down to minimal degree Kmin)

Definition at line 417 of file mesh.hpp.

◆ eval()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
template<smooth::RnType RetT>
RetT smooth::feedback::Mesh< _Kmin, _Kmax >::eval ( double  t,
std::ranges::range auto &&  r,
std::size_t  p = 0,
bool  extend = true 
) const
inline

Evaluate a function.

Template Parameters
RetTreturn value type
Parameters
ttime value in [0, 1]
rvalues for the collocation points (size N [extend=false] or N+1 [extend=true])
pderivative to evaluate
extendset to true if a value is provided for t=+1

Definition at line 433 of file mesh.hpp.

◆ increase_degrees()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
void smooth::feedback::Mesh< _Kmin, _Kmax >::increase_degrees ( )
inline

Increase the degree of all intervals by one (up to maximal degree Kmax + 1)

Definition at line 409 of file mesh.hpp.

◆ interval_diffmat()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
Eigen::MatrixXd smooth::feedback::Mesh< _Kmin, _Kmax >::interval_diffmat ( std::size_t  i) const
inline

Interval differentiation matrix w.r.t. [0, 1] timescale.

Returns a \( (K+1 \times K) \) matrix \( D \) s.t.

\[ \begin{bmatrix} y'(\tau_{i, 0}) & y'(\tau_{i, 1}) & \cdots & y'(\tau_{i, K-1}) \end{bmatrix} = \begin{bmatrix} y(\tau_{i, 0}) & y(\tau_{i, 1}) & \cdots & y(\tau_{i, K}) \end{bmatrix} D \]

, where \( y(\cdot) \in \mathbb{R}^{d \times 1} \) is a Lagrange polynomial in interval i.

Note
Allocates heap memory for return value.

Definition at line 312 of file mesh.hpp.

◆ interval_diffmat_unscaled()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
std::pair< double, MatMap > smooth::feedback::Mesh< _Kmin, _Kmax >::interval_diffmat_unscaled ( std::size_t  i) const
inline

Interval differentiation matrix (unscaled).

Returns a Map D_us and a scalar alpha s.t. D = alpha * D_us

See also
interval_diffmat

Definition at line 343 of file mesh.hpp.

◆ interval_find()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
std::size_t smooth::feedback::Mesh< _Kmin, _Kmax >::interval_find ( double  t) const
inline

Find interval index that contains t.

Definition at line 396 of file mesh.hpp.

◆ interval_intmat()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
Eigen::MatrixXd smooth::feedback::Mesh< _Kmin, _Kmax >::interval_intmat ( std::size_t  i) const
inline

Interval integration matrix w.r.t. [0, 1] timescale.

Returns a \( (K \times K) \) matrix \( I \) s.t.

\[ \begin{bmatrix} y(\tau_{i, 1}) & y(\tau_{i, 2}) & \cdots & y(\tau_{i, K}) \end{bmatrix} = y(\tau_{i, 0}) \begin{bmatrix} 1 & \ldots & 1 \end{bmatrix} + \begin{bmatrix} \dot y(\tau_{i, 0}) & \dot y(\tau_{i, 1}) & \cdots & \dot y(\tau_{i, K-1}) \end{bmatrix} I \]

, where \( y(\cdot) \in \mathbb{R}^{d \times 1} \) is a Lagrange polynomial in interval i.

Note
Allocates heap memory for return value.
Performs a matrix inverse.

Definition at line 387 of file mesh.hpp.

◆ interval_nodes()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
auto smooth::feedback::Mesh< _Kmin, _Kmax >::interval_nodes ( std::size_t  i) const
inline

Interval nodes (as range of doubles).

Note
Includes extra point at 1, i.e. size of returned range is equal to N_colloc_ival()+1

Definition at line 208 of file mesh.hpp.

◆ interval_weights()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
auto smooth::feedback::Mesh< _Kmin, _Kmax >::interval_weights ( std::size_t  i) const
inline

Interval weights (as range of doubles)

Note
Includes zero weight at 1, i.e. size of returned range is equal to N_colloc_ival()+1

Definition at line 256 of file mesh.hpp.

◆ N_colloc()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
std::size_t smooth::feedback::Mesh< _Kmin, _Kmax >::N_colloc ( ) const
inline

Number of collocation points in mesh.

Definition at line 114 of file mesh.hpp.

◆ N_colloc_ival()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
std::size_t smooth::feedback::Mesh< _Kmin, _Kmax >::N_colloc_ival ( std::size_t  i) const
inline

Number of collocation points in interval i.

Note
This is also equal to the polynomial degree inside interval i, since the polynomial is fitted with an "extra" point belonging to the subsequent interval.

Definition at line 126 of file mesh.hpp.

◆ N_ivals()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
std::size_t smooth::feedback::Mesh< _Kmin, _Kmax >::N_ivals ( ) const
inline

Number of intervals in mesh.

Definition at line 109 of file mesh.hpp.

◆ refine_errors()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
void smooth::feedback::Mesh< _Kmin, _Kmax >::refine_errors ( std::ranges::sized_range auto &&  errs,
double  target_err 
)
inline

Refine intervals in mesh to satisfy a target error criterion.

Parameters
errsrelative errors for all intervals (
See also
mesh_dyn_error())
Parameters
target_errtarget relative error

Definition at line 174 of file mesh.hpp.

◆ refine_ph()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
void smooth::feedback::Mesh< _Kmin, _Kmax >::refine_ph ( std::size_t  i,
std::size_t  D 
)
inline

Refine interval using the ph strategy.

Parameters
iindex of interval to refine
Dtarget number of collocation points in refined interval

If D > Kmax, or current degree > Kmax then the interval is divided into n = max(2, ceil(D / Kmin)) intervals with deg Kmin If D < current degree, then nothing is done. If D <= Kmax, then the polynomial degree is increased to D.

Note
May allocate heap memory due to vector resizing if the number of intervals is increased.

Definition at line 145 of file mesh.hpp.

◆ set_N_colloc_ival()

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
void smooth::feedback::Mesh< _Kmin, _Kmax >::set_N_colloc_ival ( std::size_t  i,
std::size_t  K 
)
inline

Set the number of collocation points in interval i to K.

Parameters
iinterval index
Knumber of collocation points s.t. (Kmin <= K <= Kmax + 1)

Definition at line 196 of file mesh.hpp.

Member Data Documentation

◆ Kmax

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
constexpr auto smooth::feedback::Mesh< _Kmin, _Kmax >::Kmax = _Kmax
staticconstexpr

Maximal number of collocation points per interval.

Definition at line 70 of file mesh.hpp.

◆ Kmin

template<std::size_t _Kmin = 5, std::size_t _Kmax = 10>
constexpr auto smooth::feedback::Mesh< _Kmin, _Kmax >::Kmin = _Kmin
staticconstexpr

Minimal number of collocation points per interval.

Definition at line 68 of file mesh.hpp.


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