39 #include <eigen3/Eigen/Eigen> 151 virtual ~State() =
default;
171 virtual double&
value(
const std::size_t& _i) = 0;
174 virtual const double&
value(
const std::size_t& _i)
const = 0;
188 throw "function not supported for the instantiated class";
194 static StateSPtr stateNullPtr_ =
nullptr;
195 return stateNullPtr_;
208 for (
size_t i = 0; i < _vec.size(); ++i)
218 for (
size_t i = 0; i < (size_t)_vec.rows(); ++i)
230 throw "cannot copy from container of different size";
232 for (
size_t i = 0; i < _vec.size(); ++i)
244 throw "cannot copy from container of different size";
246 for (
size_t i = 0; i < (size_t)_vec.rows(); ++i)
257 static std::vector<double>&
plus(
State& _lhs,
State& _rhs, std::vector<double>& _ans)
261 throw "cannot add two containers of different sizes";
264 for (
size_t i = 0; i < _lhs.
valueSize(); ++i)
280 throw "cannot add two containers of different sizes";
283 for (
size_t i = 0; i < _lhs.
valueSize(); ++i)
300 throw "cannot add two containers of different sizes";
302 for (
size_t i = 0; i < _ans.
valueSize(); ++i)
314 static std::vector<double>&
minus(
State& _lhs,
State& _rhs, std::vector<double>& _ans)
318 throw "cannot add two containers of different sizes";
321 for (
size_t i = 0; i < _lhs.
valueSize(); ++i)
337 throw "cannot add two containers of different sizes";
340 for (
size_t i = 0; i < _lhs.
valueSize(); ++i)
357 throw "cannot add two containers of different sizes";
359 for (
size_t i = 0; i < _ans.
valueSize(); ++i)
372 for (
size_t i = 0; i < o.
valueSize(); i++)
374 os << (i == 0 ?
"[ " :
", ") << o.
value(i);
virtual void resize(const size_t &_i)
Resizes the array.
void toEIGENVec(Eigen::VectorXd &_vec)
Converts all the array values to an Eigen vector.
static State & plus(State &_lhs, State &_rhs, State &_ans)
Performs addition. Answer variable, left operand and right operand are required to have the same valu...
std::shared_ptr< State > StateSPtr
static Eigen::VectorXd & plus(State &_lhs, State &_rhs, Eigen::VectorXd &_ans)
Performs addition. Left and right operand are required to have the same valueSize.
virtual double & value(const std::size_t &_i)=0
Access state variable based on index _i.
static std::vector< double > & plus(State &_lhs, State &_rhs, std::vector< double > &_ans)
Performs addition. Left and right operand are required to have the same valueSize.
virtual void updateSize()
Performs internal manipulation when any of the underlying arrays are being resized.
std::unique_ptr< State const > StateConstUPtr
virtual StateSPtr & state(const std::size_t &_i)
Access sub-state based on index _i.
void fromEIGENVec(const Eigen::VectorXd &_vec)
Copies all values from an Eigen vector. The valueSize of the State object has to be equal with the Ei...
std::shared_ptr< State const > StateConstSPtr
virtual size_t stateSize() const
Size of the sub-states.
State & operator=(const State &)=default
virtual size_t valueSize() const =0
Size of the state variables.
static std::vector< double > & minus(State &_lhs, State &_rhs, std::vector< double > &_ans)
Performs substraction. Left and right operand are required to have the same valueSize.
Generic tree-like recursive structure that allows sub-structure access as well as ordered (array-like...
friend std::ostream & operator<<(std::ostream &os, const State &o)
prints the state value to an output stream.
std::unique_ptr< State > StateUPtr
void fromSTLVec(const std::vector< double > &_vec)
Copies all values from an STL vector. The valueSize of the State object has to be equal with the STL ...
static State & minus(State &_lhs, State &_rhs, State &_ans)
Performs substraction. Answer variable, left operand and right operand are required to have the same ...
void toSTLVec(std::vector< double > &_vec)
Converts all the array values to an STL vector.
void callRootUpdateSize()
Calls (if present) the parent updateSize procedure. Otherwise performs root updateSize.
State * parent_
Pointer to the parent State structure.
virtual StateSPtr cloneState() const =0
Clone-to-base-class-ptr function.
static Eigen::VectorXd & minus(State &_lhs, State &_rhs, Eigen::VectorXd &_ans)
Performs substraction. Left and right operand are required to have the same valueSize.