Go to the documentation of this file.
26 #include <Eigen/Sparse>
35 #if GTSAM_ENABLE_BOOST_SERIALIZATION
38 #include <boost/serialization/nvp.hpp>
43 class DiscreteConditional;
79 size_t keyValueForIndex(
Key target_key,
uint64_t index)
const;
95 const std::vector<double>&
table);
99 const std::string&
table);
131 template <
class SOURCE>
140 TableFactor(
const DiscreteKeys&
keys,
const DecisionTreeFactor& dtf);
141 TableFactor(
const DecisionTreeFactor& dtf);
144 TableFactor(
const DiscreteKeys&
keys,
const DecisionTree<Key, double>& dtree);
147 explicit TableFactor(
const DiscreteConditional&
c);
158 const std::string&
s =
"TableFactor:\n",
199 static double safe_div(
const double&
a,
const double&
b);
203 return apply(
f, safe_div);
284 std::unordered_map<uint64_t, AssignValList> createMap(
305 shared_ptr combine(
size_t nrFrontals, Binary op)
const;
313 shared_ptr combine(
const Ordering&
keys, Binary op)
const;
316 std::vector<std::pair<DiscreteValues, double>> enumerate()
const;
356 const Names&
names = {})
const override;
366 const Names&
names = {})
const override;
381 #if GTSAM_ENABLE_BOOST_SERIALIZATION
383 friend class boost::serialization::access;
384 template <
class ARCHIVE>
385 void serialize(ARCHIVE& ar,
const unsigned int ) {
386 ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
387 ar& BOOST_SERIALIZATION_NVP(sparse_table_);
388 ar& BOOST_SERIALIZATION_NVP(denominators_);
389 ar& BOOST_SERIALIZATION_NVP(sorted_dkeys_);
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
Serialization for matrices.
DiscreteFactor::shared_ptr sum(size_t nrFrontals) const override
Create new factor by summing all values with the same separator values.
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)
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)
DiscreteFactor::shared_ptr sum(const Ordering &keys) const override
Create new factor by summing all values with the same separator values.
DiscreteFactor::shared_ptr max(const Ordering &keys) const override
Create new factor by maximizing over all values with the same separator.
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.
uint64_t nrValues() const override
static double max(const double &a, const double &b)
std::vector< std::pair< DiscreteValues, double > > AssignValList
Eigen::SparseVector< double > sparseTable() const
Getter for the underlying sparse vector.
TableFactor(const DiscreteKey &key, const std::vector< double > &row)
Single-key specialization, with vector of doubles.
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
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE CwiseBinaryOp< internal::scalar_quotient_op< Scalar, typename OtherDerived::Scalar >, const Derived, const OtherDerived > operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
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.
DiscreteFactor::shared_ptr max(size_t nrFrontals) const override
Create new factor by maximizing over all values with the same separator.
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 Tue Jan 7 2025 04:05:13