gtsam  4.1.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 #include <gtsam/inference/Key.h>
23 
24 #include <map>
25 #include <string>
26 #include <vector>
27 
28 namespace gtsam {
29 
34  typedef std::pair<Key,size_t> DiscreteKey;
35 
37  struct DiscreteKeys: public std::vector<DiscreteKey> {
38 
41  }
42 
44  DiscreteKeys(const DiscreteKey& key) {
45  push_back(key);
46  }
47 
49  DiscreteKeys(const std::vector<DiscreteKey>& keys) :
50  std::vector<DiscreteKey>(keys) {
51  }
52 
54  GTSAM_EXPORT DiscreteKeys(const std::vector<int>& cs);
55 
57  GTSAM_EXPORT KeyVector indices() const;
58 
60  GTSAM_EXPORT std::map<Key,size_t> cardinalities() const;
61 
64  push_back(key);
65  return *this;
66  }
67  }; // DiscreteKeys
68 
70  GTSAM_EXPORT DiscreteKeys operator&(const DiscreteKey& key1, const DiscreteKey& key2);
71 }
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Key type for discrete conditionals Includes name and cardinality.
Definition: DiscreteKey.h:34
gtsam::DiscreteKeys::DiscreteKeys
DiscreteKeys(const DiscreteKey &key)
Construct from a key.
Definition: DiscreteKey.h:44
gtsam::DiscreteKeys::DiscreteKeys
DiscreteKeys()
Default constructor.
Definition: DiscreteKey.h:40
gtsam::DiscreteKeys::DiscreteKeys
DiscreteKeys(const std::vector< DiscreteKey > &keys)
Construct from a vector of keys.
Definition: DiscreteKey.h:49
gtsam
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
global_includes.h
Included from all GTSAM files.
gtsam::DiscreteKeys::operator&
DiscreteKeys & operator&(const DiscreteKey &key)
Add a key (non-const!)
Definition: DiscreteKey.h:63
gtsam::DiscreteKeys::cardinalities
GTSAM_EXPORT std::map< Key, size_t > cardinalities() const
Return a map from index to cardinality.
Definition: DiscreteKey.cpp:41
gtsam::operator&
DiscreteKeys operator&(const DiscreteKey &key1, const DiscreteKey &key2)
Create a list from two keys.
Definition: DiscreteKey.cpp:49
Key.h
gtsam::DiscreteKeys::indices
GTSAM_EXPORT KeyVector indices() const
Return a vector of indices.
Definition: DiscreteKey.cpp:34
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
gtsam::DiscreteKeys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:37