gtsam  4.0.0
gtsam
DiscreteKey.h
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 #pragma once
20 
21 #include <gtsam/global_includes.h>
22 
23 #include <map>
24 #include <string>
25 #include <vector>
26 
27 namespace gtsam {
28 
33  typedef std::pair<Key,size_t> DiscreteKey;
34 
36  struct DiscreteKeys: public std::vector<DiscreteKey> {
37 
40  }
41 
43  DiscreteKeys(const DiscreteKey& key) {
44  push_back(key);
45  }
46 
48  DiscreteKeys(const std::vector<DiscreteKey>& keys) :
49  std::vector<DiscreteKey>(keys) {
50  }
51 
53  GTSAM_EXPORT DiscreteKeys(const std::vector<int>& cs);
54 
56  GTSAM_EXPORT std::vector<Key> indices() const;
57 
59  GTSAM_EXPORT std::map<Key,size_t> cardinalities() const;
60 
62  DiscreteKeys& operator&(const DiscreteKey& key) {
63  push_back(key);
64  return *this;
65  }
66  }; // DiscreteKeys
67 
69  GTSAM_EXPORT DiscreteKeys operator&(const DiscreteKey& key1, const DiscreteKey& key2);
70 }
GTSAM_EXPORT std::map< Key, size_t > cardinalities() const
Return a map from index to cardinality.
Definition: DiscreteKey.cpp:41
Included from all GTSAM files.
GTSAM_EXPORT std::vector< Key > indices() const
Return a vector of indices.
Definition: DiscreteKey.cpp:34
DiscreteKeys(const std::vector< DiscreteKey > &keys)
Construct from a vector of keys.
Definition: DiscreteKey.h:48
STL namespace.
DiscreteKeys(const DiscreteKey &key)
Construct from a key.
Definition: DiscreteKey.h:43
DiscreteKeys()
Default constructor.
Definition: DiscreteKey.h:39
DiscreteKeys & operator&(const DiscreteKey &key)
Add a key (non-const!)
Definition: DiscreteKey.h:62
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:36
std::pair< Key, size_t > DiscreteKey
Key type for discrete conditionals Includes name and cardinality.
Definition: DiscreteKey.h:33
Global functions in a separate testing namespace.
Definition: chartTesting.h:28