New constructor
parent
26890652c4
commit
4cba05a2f7
|
@ -38,11 +38,9 @@ namespace gtsam {
|
||||||
return js;
|
return js;
|
||||||
}
|
}
|
||||||
|
|
||||||
map<Key,size_t> DiscreteKeys::cardinalities() const {
|
map<Key, size_t> DiscreteKeys::cardinalities() const {
|
||||||
map<Key,size_t> cs;
|
map<Key, size_t> cs;
|
||||||
cs.insert(begin(),end());
|
cs.insert(begin(), end());
|
||||||
// for(const DiscreteKey& key: *this)
|
|
||||||
// cs.insert(key);
|
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key type for discrete conditionals
|
* Key type for discrete variables.
|
||||||
* Includes name and cardinality
|
* Includes Key and cardinality.
|
||||||
*/
|
*/
|
||||||
using DiscreteKey = std::pair<Key,size_t>;
|
using DiscreteKey = std::pair<Key,size_t>;
|
||||||
|
|
||||||
|
@ -45,6 +45,11 @@ namespace gtsam {
|
||||||
/// Construct from a key
|
/// Construct from a key
|
||||||
explicit DiscreteKeys(const DiscreteKey& key) { push_back(key); }
|
explicit DiscreteKeys(const DiscreteKey& key) { push_back(key); }
|
||||||
|
|
||||||
|
/// Construct from cardinalities.
|
||||||
|
explicit DiscreteKeys(std::map<Key, size_t> cardinalities) {
|
||||||
|
for (auto&& kv : cardinalities) emplace_back(kv);
|
||||||
|
}
|
||||||
|
|
||||||
/// Construct from a vector of keys
|
/// Construct from a vector of keys
|
||||||
DiscreteKeys(const std::vector<DiscreteKey>& keys) :
|
DiscreteKeys(const std::vector<DiscreteKey>& keys) :
|
||||||
std::vector<DiscreteKey>(keys) {
|
std::vector<DiscreteKey>(keys) {
|
||||||
|
|
Loading…
Reference in New Issue