34class GTSAM_EXPORT DiscreteValues :
public Assignment<Key> {
36 using Base = Assignment<Key>;
40 using Assignment::Assignment;
43 DiscreteValues() =
default;
46 explicit DiscreteValues(
const Base& a) : Base(a) {}
49 DiscreteValues(std::initializer_list<std::pair<const Key, size_t>> init)
50 : Assignment<Key>{init} {}
57 void print(
const std::string& s =
"",
58 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
61 bool equals(
const DiscreteValues& x,
double tol = 1e-9)
const;
68 std::pair<iterator, bool> insert(
const value_type& value ){
69 return Base::insert(value);
74 DiscreteValues& insert(
const DiscreteValues& values);
79 DiscreteValues&
update(
const DiscreteValues& values);
95 using Names = std::map<Key, std::vector<std::string>>;
108 const Names& names = {})
const;
118 const Names& names = {})
const;
specialized key for discrete variables
An assignment from labels to a discrete value index (size_t).
Global functions in a separate testing namespace.
Definition chartTesting.h:28
string html(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of html.
Definition DiscreteValues.cpp:134
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
Definition DiscreteValues.cpp:129
std::vector< DiscreteValues > cartesianProduct(const DiscreteKeys &keys)
Free version of CartesianProduct.
Definition DiscreteValues.h:124
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
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
static std::vector< Derived > CartesianProduct(const std::vector< std::pair< Key, size_t > > &keys)
Definition Assignment.h:89
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition DiscreteKey.h:39
A map from keys to values.
Definition DiscreteValues.h:34
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const
Output as a markdown table.
Definition DiscreteValues.cpp:87
std::map< Key, std::vector< std::string > > Names
Translation table from values to strings.
Definition DiscreteValues.h:95
static std::string Translate(const Names &names, Key key, size_t index)
Translate an integer index value for given key to a string.
Definition DiscreteValues.cpp:77
DiscreteValues & update(const DiscreteValues &values)
For all key/value pairs in values, replace values with corresponding keys in this object with those i...
Definition DiscreteValues.cpp:63
static std::vector< DiscreteValues > CartesianProduct(const DiscreteKeys &keys)
Return a vector of DiscreteValues, one for each possible combination of values.
Definition DiscreteValues.h:85
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print required by Testable.
Definition DiscreteValues.cpp:31
bool equals(const DiscreteValues &x, double tol=1e-9) const
equals required by Testable for unit testing.
Definition DiscreteValues.cpp:40
The Factor::error simply extracts the.