codac
codac::TrajectoryVector Class Reference

n-dimensional trajectory $\mathbf{x}(\cdot)$, defined as a temporal map of vector values More...

#include <codac_TrajectoryVector.h>

Inheritance diagram for codac::TrajectoryVector:
[legend]
Collaboration diagram for codac::TrajectoryVector:
[legend]

## Public Member Functions

Definition
TrajectoryVector (int n)
Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$. More...

TrajectoryVector (const Interval &tdomain, const TFunction &f)
Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from an analytic expression. More...

TrajectoryVector (const Interval &tdomain, const TFunction &f, double timestep)
Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from an analytic expression, and transforms it as a map of values (sampling procedure) More...

TrajectoryVector (const std::map< double, Vector > &m_map_values)
Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from a map of vector values. More...

TrajectoryVector (const std::vector< std::map< double, double > > &v_map_values)
Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from a vector of maps of scalar values. More...

TrajectoryVector (const std::list< double > &list_t, const std::list< Vector > &list_x)
Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from a list of vector values. More...

TrajectoryVector (std::initializer_list< Trajectory > list)
Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from a list of Trajectory objects. More...

TrajectoryVector (const TrajectoryVector &traj)
Creates a copy of a n-dimensional trajectory $\mathbf{x}(\cdot)$. More...

TrajectoryVector (int n, const Trajectory &x)
Creates a n-dimensional trajectory with all the components initialized to $x(\cdot)$. More...

~TrajectoryVector ()
TrajectoryVector destructor.

const TrajectoryVectoroperator= (const TrajectoryVector &x)
Returns a copy of a TrajectoryVector. More...

int size () const
Returns the dimension of the trajectory. More...

const Interval tdomain () const
Returns the temporal definition domain of this trajectory. More...

void resize (int n)
Resizes this TrajectoryVector. More...

const TrajectoryVector subvector (int start_index, int end_index) const
Returns a subvector of this TrajectoryVector. More...

void put (int start_index, const TrajectoryVector &subvec)
Puts a subvector into this TrajectoryVector at a given position. More...

Accessing values
const IntervalVector codomain () const
Returns the box of feasible values. More...

Trajectoryoperator[] (int index)
Returns the ith Trajectory of this TrajectoryVector. More...

const Trajectoryoperator[] (int index) const
Returns a const reference to the ith Trajectory of this TrajectoryVector. More...

const Vector operator() (double t) const
Returns the evaluation of this trajectory at $t$. More...

const IntervalVector operator() (const Interval &t) const
Returns the interval evaluation of this trajectory over $[t]$. More...

const Vector first_value () const
Returns the value $\mathbf{x}(t_0)$. More...

const Vector last_value () const
Returns the value $\mathbf{x}(t_f)$. More...

Tests
bool not_defined () const
Tests whether this trajectory is defined or not. More...

bool operator== (const TrajectoryVector &x) const
Returns true if this trajectory is equal to $\mathbf{x}(\cdot)$. More...

bool operator!= (const TrajectoryVector &x) const
Returns true if this trajectory is different from $\mathbf{x}(\cdot)$. More...

Setting values
void set (const Vector &y, double t)
Sets a value $\mathbf{y}$ at $t$: $\mathbf{x}(t)=\mathbf{y}$. More...

TrajectoryVectortruncate_tdomain (const Interval &tdomain)
Truncates the tdomain of $\mathbf{x}(\cdot)$. More...

TrajectoryVectorshift_tdomain (double a)
Shifts the tdomain $[t_0,t_f]$ of $\mathbf{x}(\cdot)$. More...

bool same_tdomain_forall_components () const
Checks whether all the Trajectory components have the same tdomain or not. More...

TrajectoryVectorsample (double timestep)
Transforms an analytic trajectory as a map of values. More...

TrajectoryVectorsample (const Trajectory &x)
Samples this trajectory so that it will share the same sampling of $x(\cdot)$. More...

TrajectoryVectorsample (const TrajectoryVector &x)
Samples this trajectory so that it will share the same sampling of $\mathbf{x}(\cdot)$. More...

TrajectoryVectormake_continuous ()
Makes a trajectory continuous by avoiding infinite slopes. More...

Integration
const TrajectoryVector primitive (const Vector &c) const
Computes an approximative primitive of $\mathbf{x}(\cdot)$. More...

const TrajectoryVector primitive (const Vector &c, double timestep) const
Computes an approximative primitive of $\mathbf{x}(\cdot)$ with some time discretization $\delta$. More...

const TrajectoryVector diff () const
Differentiates this trajectory vector. More...

Assignments operators
const TrajectoryVectoroperator+= (double x)
Operates +=. More...

const TrajectoryVectoroperator+= (const Trajectory &x)
Operates +=. More...

const TrajectoryVectoroperator+= (const Vector &x)
Operates +=. More...

const TrajectoryVectoroperator+= (const TrajectoryVector &x)
Operates +=. More...

const TrajectoryVectoroperator-= (double x)
Operates -=. More...

const TrajectoryVectoroperator-= (const Trajectory &x)
Operates -=. More...

const TrajectoryVectoroperator-= (const Vector &x)
Operates -=. More...

const TrajectoryVectoroperator-= (const TrajectoryVector &x)
Operates -=. More...

const TrajectoryVectoroperator*= (double x)
Operates *=. More...

const TrajectoryVectoroperator*= (const Trajectory &x)
Operates *=. More...

const TrajectoryVectoroperator/= (double x)
Operates /=. More...

const TrajectoryVectoroperator/= (const Trajectory &x)
Operates /=. More...

Public Member Functions inherited from codac::DynamicalItem
virtual ~DynamicalItem ()
DynamicalItem destructor.

## Protected Member Functions

TrajectoryVector ()
Creates an undefined n-dimensional trajectory. More...

const IntervalVector codomain_box () const
Returns the box $\mathbf{x}([t_0,t_f])$. More...

## Protected Attributes

int m_n = 0
dimension of this trajectory

Trajectorym_v_trajs = nullptr
array of components (scalar trajectories)

## Friends

void deserialize_TrajectoryVector (std::ifstream &bin_file, TrajectoryVector *&traj)
Creates a TrajectoryVector object from a binary file. More...

## String

std::ostream & operator<< (std::ostream &str, const TrajectoryVector &x)
Displays a synthesis of this trajectory. More...

const std::string class_name () const
Returns the name of this class. More...

## Additional Inherited Members

Static Public Member Functions inherited from codac::DynamicalItem
static bool valid_tdomain (const Interval &tdomain)
Verifies that this interval is a feasible tdomain. More...

## Detailed Description

n-dimensional trajectory $\mathbf{x}(\cdot)$, defined as a temporal map of vector values

Note
Use Trajectory for the one-dimensional case

## ◆ TrajectoryVector() [1/10]

 codac::TrajectoryVector::TrajectoryVector ( int n )
explicit

Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$.

Parameters
 n dimension of this trajectory

## ◆ TrajectoryVector() [2/10]

 codac::TrajectoryVector::TrajectoryVector ( const Interval & tdomain, const TFunction & f )

Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from an analytic expression.

Parameters
 tdomain temporal domain $[t_0,t_f]$ f TFunction object defining the trajectory: $\mathbf{x}(t)=\mathbf{f}(t)$

## ◆ TrajectoryVector() [3/10]

 codac::TrajectoryVector::TrajectoryVector ( const Interval & tdomain, const TFunction & f, double timestep )

Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from an analytic expression, and transforms it as a map of values (sampling procedure)

Parameters
 tdomain temporal domain $[t_0,t_f]$ f TFunction object defining the trajectory: $\mathbf{x}(t)=\mathbf{f}(t)$ timestep sampling value $\delta$ for the temporal discretization (double)

## ◆ TrajectoryVector() [4/10]

 codac::TrajectoryVector::TrajectoryVector ( const std::map< double, Vector > & m_map_values )
explicit

Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from a map of vector values.

Parameters
 m_map_values map defining the trajectory: $\mathbf{x}(t)=\mathbf{y}$

## ◆ TrajectoryVector() [5/10]

 codac::TrajectoryVector::TrajectoryVector ( const std::vector< std::map< double, double > > & v_map_values )
explicit

Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from a vector of maps of scalar values.

Parameters
 v_map_values set of map defining the trajectory: $\mathbf{x}(t)=\mathbf{y}$

## ◆ TrajectoryVector() [6/10]

 codac::TrajectoryVector::TrajectoryVector ( const std::list< double > & list_t, const std::list< Vector > & list_x )
explicit

Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from a list of vector values.

Values and datations are separated into two lists.

Parameters
 list_t list of time keys list_x list of vector values

## ◆ TrajectoryVector() [7/10]

 codac::TrajectoryVector::TrajectoryVector ( std::initializer_list< Trajectory > list )

Creates a n-dimensional trajectory $\mathbf{x}(\cdot)$ from a list of Trajectory objects.

Parameters
 list list of $x_i(\cdot)$ trajectories

## ◆ TrajectoryVector() [8/10]

 codac::TrajectoryVector::TrajectoryVector ( const TrajectoryVector & traj )

Creates a copy of a n-dimensional trajectory $\mathbf{x}(\cdot)$.

Parameters
 traj TrajectoryVector to be duplicated

## ◆ TrajectoryVector() [9/10]

 codac::TrajectoryVector::TrajectoryVector ( int n, const Trajectory & x )

Creates a n-dimensional trajectory with all the components initialized to $x(\cdot)$.

Parameters
 n dimension of this trajectory x Trajectory to be copied for all the components

## ◆ TrajectoryVector() [10/10]

 codac::TrajectoryVector::TrajectoryVector ( )
protected

Creates an undefined n-dimensional trajectory.

Note
Constructor necessary for the deserialize_TrajectoryVector method

## ◆ operator=()

 const TrajectoryVector& codac::TrajectoryVector::operator= ( const TrajectoryVector & x )

Returns a copy of a TrajectoryVector.

Parameters
 x the TrajectoryVector object to be copied
Returns
a new TrajectoryVector object with same values/definition

## ◆ size()

 int codac::TrajectoryVector::size ( ) const
virtual

Returns the dimension of the trajectory.

Returns
n

Implements codac::DynamicalItem.

## ◆ tdomain()

 const Interval codac::TrajectoryVector::tdomain ( ) const
virtual

Returns the temporal definition domain of this trajectory.

Returns
an Interval object $[t_0,t_f]$

Implements codac::DynamicalItem.

## ◆ resize()

 void codac::TrajectoryVector::resize ( int n )

Resizes this TrajectoryVector.

Note
If the size is increased, the existing components are not modified and the new ones are set to empty trajectories
Parameters
 n the new size to be set

## ◆ subvector()

 const TrajectoryVector codac::TrajectoryVector::subvector ( int start_index, int end_index ) const

Returns a subvector of this TrajectoryVector.

Parameters
 start_index first component index of the subvector to be returned end_index last component index of the subvector to be returned
Returns
a TrajectoryVector extracted from this TrajectoryVector

## ◆ put()

 void codac::TrajectoryVector::put ( int start_index, const TrajectoryVector & subvec )

Puts a subvector into this TrajectoryVector at a given position.

Parameters
 start_index position where the subvector will be put subvec the TrajectoryVector to put from start_index

## ◆ codomain()

 const IntervalVector codac::TrajectoryVector::codomain ( ) const

Returns the box of feasible values.

Returns
an IntervalVector object $\mathbf{x}([t_0,t_f])$

## ◆ operator[]() [1/2]

 Trajectory& codac::TrajectoryVector::operator[] ( int index )

Returns the ith Trajectory of this TrajectoryVector.

Parameters
 index the index of this ith component
Returns
a reference to the ith component

## ◆ operator[]() [2/2]

 const Trajectory& codac::TrajectoryVector::operator[] ( int index ) const

Returns a const reference to the ith Trajectory of this TrajectoryVector.

Parameters
 index the index of this ith component
Returns
a const reference to the ith component

## ◆ operator()() [1/2]

 const Vector codac::TrajectoryVector::operator() ( double t ) const

Returns the evaluation of this trajectory at $t$.

Note
Be careful, if the trajectory is defined from an analytic function, then an approximation will be made (since the TFunction returns a boxed evaluation, while the expected returned value is a real here). Please use the operator(Interval(double)) for a reliable evaluation.
Parameters
 t the temporal key (double, must belong to the trajectory's tdomain)
Returns
real vector value $\mathbf{x}(t)$

## ◆ operator()() [2/2]

 const IntervalVector codac::TrajectoryVector::operator() ( const Interval & t ) const

Returns the interval evaluation of this trajectory over $[t]$.

Parameters
 t the subtdomain (Interval, must be a subset of the trajectory's tdomain)
Returns
IntervalVector envelope $\mathbf{x}([t])$

## ◆ first_value()

 const Vector codac::TrajectoryVector::first_value ( ) const

Returns the value $\mathbf{x}(t_0)$.

Returns
real value $\mathbf{x}(t_0)$

## ◆ last_value()

 const Vector codac::TrajectoryVector::last_value ( ) const

Returns the value $\mathbf{x}(t_f)$.

Returns
real value $\mathbf{x}(t_f)$

## ◆ not_defined()

 bool codac::TrajectoryVector::not_defined ( ) const

Tests whether this trajectory is defined or not.

Returns
false in case of non-empty map, or definition from a TFunction object, true otherwise

## ◆ operator==()

 bool codac::TrajectoryVector::operator== ( const TrajectoryVector & x ) const

Returns true if this trajectory is equal to $\mathbf{x}(\cdot)$.

Parameters
 x the TrajectoryVector object
Returns
true in case of equality

## ◆ operator!=()

 bool codac::TrajectoryVector::operator!= ( const TrajectoryVector & x ) const

Returns true if this trajectory is different from $\mathbf{x}(\cdot)$.

Parameters
 x the TrajectoryVector object
Returns
true in case of difference

## ◆ set()

 void codac::TrajectoryVector::set ( const Vector & y, double t )

Sets a value $\mathbf{y}$ at $t$: $\mathbf{x}(t)=\mathbf{y}$.

Parameters
 y local vector value of the trajectory t the temporal key (double, must belong to the trajectory's tdomain)

## ◆ truncate_tdomain()

 TrajectoryVector& codac::TrajectoryVector::truncate_tdomain ( const Interval & tdomain )

Truncates the tdomain of $\mathbf{x}(\cdot)$.

Note
The new tdomain must be a subset of the old one
Parameters
 tdomain new temporal domain $[t_0,t_f]$
Returns
a reference to this trajectory

## ◆ shift_tdomain()

 TrajectoryVector& codac::TrajectoryVector::shift_tdomain ( double a )

Shifts the tdomain $[t_0,t_f]$ of $\mathbf{x}(\cdot)$.

Note
If the trajectory is defined from a map of values, the key of each value will be shifted. In case of a definition from an analytic function, only the tdomain will be changed.
Parameters
 a the offset value so that $[t_0,t_f]:=[t_0-a,t_f-a]$
Returns
a reference to this trajectory

## ◆ same_tdomain_forall_components()

 bool codac::TrajectoryVector::same_tdomain_forall_components ( ) const

Checks whether all the Trajectory components have the same tdomain or not.

Returns
true in case of temporal consistency

## ◆ sample() [1/3]

 TrajectoryVector& codac::TrajectoryVector::sample ( double timestep )

Transforms an analytic trajectory as a map of values.

Note
Sampling only available for trajectories firstly defined as analytic functions
Parameters
 timestep sampling value $\delta$ for the temporal discretization (double)
Returns
a reference to this trajectory

## ◆ sample() [2/3]

 TrajectoryVector& codac::TrajectoryVector::sample ( const Trajectory & x )

Samples this trajectory so that it will share the same sampling of $x(\cdot)$.

Note
If the trajectory is defined as an analytic function, then the object is transformed into a map of values and the TFunction object is deleted.
The previous sampling of this trajectory is preserved
Parameters
 x the Trajectory from which the new sampling will come from
Returns
a reference to this trajectory

## ◆ sample() [3/3]

 TrajectoryVector& codac::TrajectoryVector::sample ( const TrajectoryVector & x )

Samples this trajectory so that it will share the same sampling of $\mathbf{x}(\cdot)$.

Note
If the trajectory is defined as an analytic function, then the object is transformed into a map of values and the TFunction object is deleted.
The previous sampling of this trajectory is preserved
Parameters
 x the TrajectoryVector from which the new sampling will come from
Returns
a reference to this trajectory

## ◆ make_continuous()

 TrajectoryVector& codac::TrajectoryVector::make_continuous ( )

Makes a trajectory continuous by avoiding infinite slopes.

Note
This is mainly used when angles are expressed between $[-\pi,\pi]$, which produces troublesome discontinuities. For instance, a tube directly built from such discontinuous trajectory will be made of very large slices, inducing unwanted pessimism.
The previous sampling of this trajectory is preserved
Returns
a reference to this trajectory

## ◆ primitive() [1/2]

 const TrajectoryVector codac::TrajectoryVector::primitive ( const Vector & c ) const

Computes an approximative primitive of $\mathbf{x}(\cdot)$.

Note
The trajectory must not be defined from an analytic function. Please use the other method with time discretization for such case.
Parameters
 c the constant of integration
Returns
a new TrajectoryVector object with the same temporal keys

## ◆ primitive() [2/2]

 const TrajectoryVector codac::TrajectoryVector::primitive ( const Vector & c, double timestep ) const

Computes an approximative primitive of $\mathbf{x}(\cdot)$ with some time discretization $\delta$.

Parameters
 c the constant of integration timestep sampling value $\delta$ for the temporal discretization (double)
Returns
a new TrajectoryVector object with the specified time discretization

## ◆ diff()

 const TrajectoryVector codac::TrajectoryVector::diff ( ) const

Differentiates this trajectory vector.

Note
If the trajectory is defined from an analytic function, the exact differentiation is returned. Otherwise, from a map of values, finite differences are computed.
Returns
a derivative trajectory vector

## ◆ operator+=() [1/4]

 const TrajectoryVector& codac::TrajectoryVector::operator+= ( double x )

Operates +=.

Parameters
 x double
Returns
(*this)+=x

## ◆ operator+=() [2/4]

 const TrajectoryVector& codac::TrajectoryVector::operator+= ( const Trajectory & x )

Operates +=.

Parameters
Returns
(*this)+=x

## ◆ operator+=() [3/4]

 const TrajectoryVector& codac::TrajectoryVector::operator+= ( const Vector & x )

Operates +=.

Parameters
 x Vector
Returns
(*this)+=x

## ◆ operator+=() [4/4]

 const TrajectoryVector& codac::TrajectoryVector::operator+= ( const TrajectoryVector & x )

Operates +=.

Parameters
Returns
(*this)+=x

## ◆ operator-=() [1/4]

 const TrajectoryVector& codac::TrajectoryVector::operator-= ( double x )

Operates -=.

Parameters
 x double
Returns
(*this)-=x

## ◆ operator-=() [2/4]

 const TrajectoryVector& codac::TrajectoryVector::operator-= ( const Trajectory & x )

Operates -=.

Parameters
Returns
(*this)-=x

## ◆ operator-=() [3/4]

 const TrajectoryVector& codac::TrajectoryVector::operator-= ( const Vector & x )

Operates -=.

Parameters
 x Vector
Returns
(*this)-=x

## ◆ operator-=() [4/4]

 const TrajectoryVector& codac::TrajectoryVector::operator-= ( const TrajectoryVector & x )

Operates -=.

Parameters
Returns
(*this)-=x

## ◆ operator*=() [1/2]

 const TrajectoryVector& codac::TrajectoryVector::operator*= ( double x )

Operates *=.

Parameters
 x double
Returns
(this)=x

## ◆ operator*=() [2/2]

 const TrajectoryVector& codac::TrajectoryVector::operator*= ( const Trajectory & x )

Operates *=.

Parameters
Returns
(this)=x

## ◆ operator/=() [1/2]

 const TrajectoryVector& codac::TrajectoryVector::operator/= ( double x )

Operates /=.

Parameters
 x double
Returns
(*this)/=x

## ◆ operator/=() [2/2]

 const TrajectoryVector& codac::TrajectoryVector::operator/= ( const Trajectory & x )

Operates /=.

Parameters
Returns
(*this)/=x

## ◆ class_name()

 const std::string codac::TrajectoryVector::class_name ( ) const
inlinevirtual

Returns the name of this class.

Note
Only used for some generic display method
Returns
the predefined name

Implements codac::DynamicalItem.

497 { return "TrajectoryVector"; };

## ◆ codomain_box()

 const IntervalVector codac::TrajectoryVector::codomain_box ( ) const
protectedvirtual

Returns the box $\mathbf{x}([t_0,t_f])$.

Note
Used for genericity purposes
Returns
the envelope of codomain values

Implements codac::DynamicalItem.

## ◆ operator<<

 std::ostream& operator<< ( std::ostream & str, const TrajectoryVector & x )
friend

Displays a synthesis of this trajectory.

Parameters
 str ostream x trajectory to be displayed
Returns
ostream

## ◆ deserialize_TrajectoryVector

 void deserialize_TrajectoryVector ( std::ifstream & bin_file, TrajectoryVector *& traj )
friend

Creates a TrajectoryVector object from a binary file.

The binary file has to be written by the serialize_TrajectoryVector() function.

Parameters
 bin_file binary file (ifstream object) traj TrajectoryVector object to be deserialized

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