Loading...
Searching...
No Matches
Signature.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <string>
#include <vector>
#include <boost/optional.hpp>
#include <gtsam/discrete/DiscreteKey.h>
namespace gtsam {
class GTSAM_EXPORT Signature {
public:
typedef std::vector<double> Row;
typedef std::vector<Row> Table;
private:
DiscreteKey key_;
DiscreteKeys parents_;
// the given CPT specification string
boost::optional<std::string> spec_;
// the CPT as parsed, if successful
boost::optional<Table> table_;
public:
Signature(const DiscreteKey& key, const DiscreteKeys& parents,
const Table& table);
Signature(const DiscreteKey& key, const DiscreteKeys& parents,
const std::string& spec);
Signature(const DiscreteKey& key);
const DiscreteKey& key() const { return key_; }
const DiscreteKeys& parents() const { return parents_; }
DiscreteKeys discreteKeys() const;
KeyVector indices() const;
// the CPT as parsed, if successful
const boost::optional<Table>& table() const { return table_; }
// the CPT as a vector of doubles, with key's values most rapidly changing
std::vector<double> cpt() const;
Signature& operator,(const DiscreteKey& parent);
Signature& operator=(const std::string& spec);
Signature& operator=(const Table& table);
GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os,
const Signature& s);
};
GTSAM_EXPORT Signature operator|(const DiscreteKey& key, const DiscreteKey& parent);
GTSAM_EXPORT Signature operator%(const DiscreteKey& key, const std::string& parent);
GTSAM_EXPORT Signature operator%(const DiscreteKey& key, const Signature::Table& parent);
}
DiscreteKey.h
specialized key for discrete variables
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Key type for discrete variables.
Definition DiscreteKey.h:36
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:86
gtsam::operator|
Signature operator|(const DiscreteKey &key, const DiscreteKey &parent)
Helper function to create Signature objects example: Signature s = D | E;.
Definition Signature.cpp:178
gtsam::operator%
Signature operator%(const DiscreteKey &key, const string &parent)
Helper function to create Signature objects example: Signature s(D % "99/1");.
Definition Signature.cpp:183
gtsam::DiscreteKeys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition DiscreteKey.h:39
gtsam::Signature
Signature for a discrete conditional density, used to construct conditionals.
Definition Signature.h:54
gtsam::Signature::Row
std::vector< double > Row
Data type for the CPT.
Definition Signature.h:59
gtsam::Signature::key
const DiscreteKey & key() const
the variable key
Definition Signature.h:115
gtsam::Signature::Signature
Signature(const DiscreteKey &key, const DiscreteKeys &parents, const Table &table)
Construct from key, parents, and a Signature::Table specifying the conditional probability table (CPT...
Definition Signature.cpp:82
gtsam::Signature::parents
const DiscreteKeys & parents() const
the parent keys
Definition Signature.h:118