DiscreteKey.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #include <iostream>
20 #include <boost/format.hpp> // for key names
21 #include "DiscreteKey.h"
22 
23 namespace gtsam {
24 
25  using namespace std;
26 
27  DiscreteKeys::DiscreteKeys(const vector<int>& cs) {
28  for (size_t i = 0; i < cs.size(); i++) {
29  string name = boost::str(boost::format("v%1%") % i);
30  push_back(DiscreteKey(i, cs[i]));
31  }
32  }
33 
35  KeyVector js;
36  for(const DiscreteKey& key: *this)
37  js.push_back(key.first);
38  return js;
39  }
40 
41  map<Key,size_t> DiscreteKeys::cardinalities() const {
42  map<Key,size_t> cs;
43  cs.insert(begin(),end());
44 // for(const DiscreteKey& key: *this)
45 // cs.insert(key);
46  return cs;
47  }
48 
50  DiscreteKeys keys(key1);
51  return keys & key2;
52  }
53 
54 }
DiscreteKeys()
Default constructor.
Definition: DiscreteKey.h:40
GTSAM_EXPORT KeyVector indices() const
Return a vector of indices.
Definition: DiscreteKey.cpp:34
Definition: Half.h:150
const Symbol key1('v', 1)
DiscreteKeys operator&(const DiscreteKey &key1, const DiscreteKey &key2)
Create a list from two keys.
Definition: DiscreteKey.cpp:49
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:34
GTSAM_EXPORT std::map< Key, size_t > cardinalities() const
Return a map from index to cardinality.
Definition: DiscreteKey.cpp:41
traits
Definition: chartTesting.h:28
specialized key for discrete variables
const Symbol key2('v', 2)
Annotation for function names.
Definition: attr.h:36
const KeyVector keys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:37


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:59