From 531c380db098b66909c091e57b1c85432f31e256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Sol=C3=A0?= <jsola@iri.upc.edu> Date: Wed, 6 May 2020 20:17:54 +0200 Subject: [PATCH] VectorComposite new contructor from structure --- include/core/state_block/state_composite.h | 1 + src/state_block/state_composite.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/core/state_block/state_composite.h b/include/core/state_block/state_composite.h index 14867387c..f0bfc5cfe 100644 --- a/include/core/state_block/state_composite.h +++ b/include/core/state_block/state_composite.h @@ -29,6 +29,7 @@ class VectorComposite : public std::unordered_map < std::string, Eigen::VectorXd { public: VectorComposite() {}; + VectorComposite(const StateStructure& _s); VectorComposite(const VectorComposite & v) : unordered_map<string, VectorXd>(v){}; /** * \brief Construct from Eigen::VectorXd and structure diff --git a/src/state_block/state_composite.cpp b/src/state_block/state_composite.cpp index d0618799c..673458e34 100644 --- a/src/state_block/state_composite.cpp +++ b/src/state_block/state_composite.cpp @@ -24,6 +24,17 @@ VectorComposite::VectorComposite(const VectorXd& _v, const StateStructure& _stru } } +VectorComposite::VectorComposite (const StateStructure& _s) +{ + for (const auto& ckey : _s) + { + const auto& key = string(1,ckey); // ckey is char + this->emplace(key,VectorXd(0)); + } +} + + + unsigned int VectorComposite::size(const StateStructure &_structure) const { unsigned int size = 0; -- GitLab