Go to the documentation of this file.
25 #include <Eigen/Sparse>
36 class DiscreteConditional;
72 size_t keyValueForIndex(
Key target_key,
uint64_t index)
const;
88 const std::vector<double>&
table);
92 const std::string&
table);
125 template <
class SOURCE>
134 TableFactor(
const DiscreteKeys&
keys,
const DecisionTreeFactor& dtf);
135 TableFactor(
const DecisionTreeFactor& dtf);
138 TableFactor(
const DiscreteKeys&
keys,
const DecisionTree<Key, double>& dtree);
141 explicit TableFactor(
const DiscreteConditional&
c);
152 const std::string&
s =
"TableFactor:\n",
160 double evaluate(
const Assignment<Key>&
values)
const override;
173 static double safe_div(
const double&
a,
const double&
b);
177 return apply(
f, safe_div);
254 std::unordered_map<uint64_t, AssignValList> createMap(
275 shared_ptr combine(
size_t nrFrontals, Binary op)
const;
283 shared_ptr combine(
const Ordering&
keys, Binary op)
const;
286 std::vector<std::pair<DiscreteValues, double>> enumerate()
const;
320 const Names&
names = {})
const override;
330 const Names&
names = {})
const override;
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
shared_ptr max(size_t nrFrontals) const
Create new factor by maximizing over all values with the same separator.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
TableFactor operator/(const TableFactor &f) const
divide by factor f (safely)
Eigen::SparseVector< double > sparse_table_
SparseVector of nonzero probabilities.
TableFactor(const DiscreteKeys &keys, const std::vector< double > &table)
shared_ptr sum(size_t nrFrontals) const
Create new factor by summing all values with the same separator values.
const KeyFormatter & formatter
Variable ordering for the elimination algorithm.
DiscreteKeys is a set of keys that can be assembled using the & operator.
DiscreteFactor Base
Typedef to base class.
static double mul(const double &a, const double &b)
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Point2 operator*(double s, const Point2 &p)
multiply with scalar
TableFactor(const DiscreteKeys &keys, const std::string &table)
void print(const Matrix &A, const string &s, ostream &stream)
DiscreteKeys sorted_dkeys_
Sorted DiscreteKeys to use internally.
const MATRIX::ConstRowXpr row(const MATRIX &A, size_t j)
TableFactor(const DiscreteKey &key, SOURCE table)
Single-key specialization.
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
static double max(const double &a, const double &b)
std::vector< std::pair< DiscreteValues, double > > AssignValList
shared_ptr max(const Ordering &keys) const
Create new factor by maximizing over all values with the same separator.
TableFactor(const DiscreteKey &key, const std::vector< double > &row)
Single-key specialization, with vector of doubles.
shared_ptr sum(const Ordering &keys) const
Create new factor by summing all values with the same separator values.
specialized key for discrete variables
const gtsam::Symbol key('X', 0)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
TableFactor operator*(const TableFactor &f) const
multiply two TableFactors
static double add(const double &a, const double &b)
std::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
std::pair< Key, size_t > DiscreteKey
std::map< Key, size_t > denominators_
Map of Keys and their denominators used in keyValueForIndex.
DecisionTree< L, Y > apply(const DecisionTree< L, Y > &f, const typename DecisionTree< L, Y >::Unary &op)
Apply unary operator op to DecisionTree f.
Eigen::SparseVector< double >::InnerIterator SparseIt
DiscreteKey discreteKey(size_t i) const
Return ith key in keys_ as a DiscreteKey.
unsigned __int64 uint64_t
string html(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of html.
std::uint64_t Key
Integer nonlinear key type.
static const T & choose(int layout, const T &col, const T &row)
std::shared_ptr< TableFactor > shared_ptr
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:14:23