DiscreteValues.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 
18 #pragma once
19 
22 #include <gtsam/inference/Key.h>
23 
24 #include <map>
25 #include <string>
26 #include <vector>
27 
28 namespace gtsam {
29 
34 class GTSAM_EXPORT DiscreteValues : public Assignment<Key> {
35  public:
36  using Base = Assignment<Key>; // base class
37 
40  using Assignment::Assignment; // all constructors
41 
42  // Define the implicit default constructor.
43  DiscreteValues() = default;
44 
45  // Construct from assignment.
46  explicit DiscreteValues(const Base& a) : Base(a) {}
47 
48  // Construct from initializer list.
49  DiscreteValues(std::initializer_list<std::pair<const Key, size_t>> init)
50  : Assignment<Key>{init} {}
51 
55 
57  void print(const std::string& s = "",
58  const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
59 
61  bool equals(const DiscreteValues& x, double tol = 1e-9) const;
62 
66 
67  // insert in base class;
68  std::pair<iterator, bool> insert( const value_type& value ){
69  return Base::insert(value);
70  }
71 
75 
80 
85  static std::vector<DiscreteValues> CartesianProduct(
86  const DiscreteKeys& keys) {
87  return Base::CartesianProduct<DiscreteValues>(keys);
88  }
89 
93 
95  using Names = std::map<Key, std::vector<std::string>>;
96 
98  static std::string Translate(const Names& names, Key key, size_t index);
99 
107  std::string markdown(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
108  const Names& names = {}) const;
109 
117  std::string html(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
118  const Names& names = {}) const;
119 
121 };
122 
124 inline std::vector<DiscreteValues> cartesianProduct(const DiscreteKeys& keys) {
126 }
127 
129 std::string GTSAM_EXPORT markdown(const DiscreteValues& values,
130  const KeyFormatter& keyFormatter = DefaultKeyFormatter,
131  const DiscreteValues::Names& names = {});
132 
134 std::string GTSAM_EXPORT html(const DiscreteValues& values,
135  const KeyFormatter& keyFormatter = DefaultKeyFormatter,
136  const DiscreteValues::Names& names = {});
137 
138 // traits
139 template <>
140 struct traits<DiscreteValues> : public Testable<DiscreteValues> {};
141 
142 } // namespace gtsam
relicense.update
def update(text)
Definition: relicense.py:46
gtsam::markdown
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
Definition: DiscreteValues.cpp:130
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
different_sigmas::values
HybridValues values
Definition: testHybridBayesNet.cpp:245
gtsam::DiscreteKeys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:41
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
Key.h
gtsam::Assignment::Assignment
Assignment()=default
gtsam::DiscreteValues::DiscreteValues
DiscreteValues(const Base &a)
Definition: DiscreteValues.h:46
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
gtsam::DiscreteValues::CartesianProduct
static std::vector< DiscreteValues > CartesianProduct(const DiscreteKeys &keys)
Return a vector of DiscreteValues, one for each possible combination of values.
Definition: DiscreteValues.h:85
gtsam::KeyFormatter
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
Assignment.h
An assignment from labels to a discrete value index (size_t)
DiscreteValues
gtsam::Assignment
Definition: Assignment.h:37
DiscreteKey.h
specialized key for discrete variables
key
const gtsam::Symbol key('X', 0)
process_shonan_timing_results.names
dictionary names
Definition: process_shonan_timing_results.py:175
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
gtsam
traits
Definition: SFMdata.h:40
gtsam::Testable
Definition: Testable.h:152
gtsam::traits
Definition: Group.h:36
gtsam::DiscreteValues
Definition: DiscreteValues.h:34
gtsam::DiscreteValues::insert
std::pair< iterator, bool > insert(const value_type &value)
Definition: DiscreteValues.h:68
gtsam::DiscreteValues::DiscreteValues
DiscreteValues(std::initializer_list< std::pair< const Key, size_t >> init)
Definition: DiscreteValues.h:49
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::html
string html(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of html.
Definition: DiscreteValues.cpp:135
gtsam::DiscreteValues::Names
std::map< Key, std::vector< std::string > > Names
Translation table from values to strings.
Definition: DiscreteValues.h:95
gtsam::cartesianProduct
std::vector< DiscreteValues > cartesianProduct(const DiscreteKeys &keys)
Free version of CartesianProduct.
Definition: DiscreteValues.h:124
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
insert
A insert(1, 2)=0
init
Definition: TutorialInplaceLU.cpp:2
test_callbacks.value
value
Definition: test_callbacks.py:160


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:13