gtsam 4.2.0
gtsam
Loading...
Searching...
No Matches
Signature.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#include <string>
21#include <vector>
22#include <boost/optional.hpp>
24
25namespace gtsam {
26
54 class GTSAM_EXPORT Signature {
55
56 public:
57
59 typedef std::vector<double> Row;
60 typedef std::vector<Row> Table;
61
62 private:
63
65 DiscreteKey key_;
66
68 DiscreteKeys parents_;
69
70 // the given CPT specification string
71 boost::optional<std::string> spec_;
72
73 // the CPT as parsed, if successful
74 boost::optional<Table> table_;
75
76 public:
88 Signature(const DiscreteKey& key, const DiscreteKeys& parents,
89 const Table& table);
90
102 Signature(const DiscreteKey& key, const DiscreteKeys& parents,
103 const std::string& spec);
104
112 Signature(const DiscreteKey& key);
113
115 const DiscreteKey& key() const { return key_; }
116
118 const DiscreteKeys& parents() const { return parents_; }
119
121 DiscreteKeys discreteKeys() const;
122
124 KeyVector indices() const;
125
126 // the CPT as parsed, if successful
127 const boost::optional<Table>& table() const { return table_; }
128
129 // the CPT as a vector of doubles, with key's values most rapidly changing
130 std::vector<double> cpt() const;
131
133 Signature& operator,(const DiscreteKey& parent);
134
136 Signature& operator=(const std::string& spec);
137
139 Signature& operator=(const Table& table);
140
142 GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os,
143 const Signature& s);
144 };
145
150 GTSAM_EXPORT Signature operator|(const DiscreteKey& key, const DiscreteKey& parent);
151
156 GTSAM_EXPORT Signature operator%(const DiscreteKey& key, const std::string& parent);
157
162 GTSAM_EXPORT Signature operator%(const DiscreteKey& key, const Signature::Table& parent);
163
164}
specialized key for discrete variables
std::pair< Key, size_t > DiscreteKey
Key type for discrete variables.
Definition DiscreteKey.h:36
Global functions in a separate testing namespace.
Definition chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:86
Signature operator|(const DiscreteKey &key, const DiscreteKey &parent)
Helper function to create Signature objects example: Signature s = D | E;.
Definition Signature.cpp:178
Signature operator%(const DiscreteKey &key, const string &parent)
Helper function to create Signature objects example: Signature s(D % "99/1");.
Definition Signature.cpp:183
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition DiscreteKey.h:39
Signature for a discrete conditional density, used to construct conditionals.
Definition Signature.h:54
std::vector< double > Row
Data type for the CPT.
Definition Signature.h:59
const DiscreteKey & key() const
the variable key
Definition Signature.h:115
const DiscreteKeys & parents() const
the parent keys
Definition Signature.h:118