gtsam 4.1.1
gtsam
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
52 class GTSAM_EXPORT Signature {
53
54 public:
55
57 typedef std::vector<double> Row;
58 typedef std::vector<Row> Table;
59
60 private:
61
63 DiscreteKey key_;
64
66 DiscreteKeys parents_;
67
68 // the given CPT specification string
69 boost::optional<std::string> spec_;
70
71 // the CPT as parsed, if successful
72 boost::optional<Table> table_;
73
74 public:
75
77 Signature(const DiscreteKey& key);
78
80 const DiscreteKey& key() const {
81 return key_;
82 }
83
85 const DiscreteKeys& parents() const {
86 return parents_;
87 }
88
90 DiscreteKeys discreteKeys() const;
91
93 KeyVector indices() const;
94
95 // the CPT as parsed, if successful
96 const boost::optional<Table>& table() const {
97 return table_;
98 }
99
100 // the CPT as a vector of doubles, with key's values most rapidly changing
101 std::vector<double> cpt() const;
102
104 Signature& operator,(const DiscreteKey& parent);
105
107 Signature& operator=(const std::string& spec);
108
110 Signature& operator=(const Table& table);
111
113 GTSAM_EXPORT friend std::ostream& operator <<(std::ostream &os, const Signature &s);
114 };
115
120 GTSAM_EXPORT Signature operator|(const DiscreteKey& key, const DiscreteKey& parent);
121
127 GTSAM_EXPORT Signature operator%(const DiscreteKey& key, const std::string& parent);
128
133 GTSAM_EXPORT Signature operator%(const DiscreteKey& key, const Signature::Table& parent);
134
135}
specialized key for discrete variables
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:208
Signature operator%(const DiscreteKey &key, const string &parent)
Helper function to create Signature objects example: Signature s(D % "99/1"); Uses string parser,...
Definition: Signature.cpp:213
std::pair< Key, size_t > DiscreteKey
Key type for discrete conditionals Includes name and cardinality.
Definition: DiscreteKey.h:34
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition: DiscreteKey.h:37
Signature for a discrete conditional density, used to construct conditionals.
Definition: Signature.h:52
std::vector< double > Row
Data type for the CPT.
Definition: Signature.h:57
const DiscreteKey & key() const
the variable key
Definition: Signature.h:80
const DiscreteKeys & parents() const
the parent keys
Definition: Signature.h:85