diff --git a/include/core/state_block/state_composite.h b/include/core/state_block/state_composite.h index 14867387c0d0d579cd3d35370846f201ad1ca4e1..f0bfc5cfe58832605fb36c70c622f2174c974e6c 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 d0618799c899fb294cddc60eb4b8671e7345a72f..673458e340d8efc1fbdbe494ea8ba50b75bbc427 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;