DiscreteDistribution.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 
18 #pragma once
19 
21 
22 #include <string>
23 #include <vector>
24 
25 namespace gtsam {
26 
33 class GTSAM_EXPORT DiscreteDistribution : public DiscreteConditional {
34  public:
36 
39 
42 
45  : Base(f.size(), f) {}
46 
52  explicit DiscreteDistribution(const Signature& s) : Base(s) {}
53 
60  DiscreteDistribution(const DiscreteKey& key, const std::vector<double>& spec)
61  : DiscreteDistribution(Signature(key, {}, Signature::Table{spec})) {}
62 
69  DiscreteDistribution(const DiscreteKey& key, const std::string& spec)
70  : DiscreteDistribution(Signature(key, {}, spec)) {}
71 
75 
77  void print(
78  const std::string& s = "Discrete Prior: ",
79  const KeyFormatter& formatter = DefaultKeyFormatter) const override;
80 
84 
86  double operator()(size_t value) const;
87 
89  // TODO(dellaert): does not play well with wrapper!
90  // using Base::operator();
91 
93  std::vector<double> pmf() const;
94 
96 };
97 // DiscreteDistribution
98 
99 // traits
100 template <>
101 struct traits<DiscreteDistribution> : public Testable<DiscreteDistribution> {};
102 
103 } // namespace gtsam
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
const gtsam::Symbol key('X', 0)
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
const KeyFormatter & formatter
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
DiscreteDistribution(const DiscreteKey &key, const std::string &spec)
std::vector< Row > Table
Definition: Signature.h:60
DiscreteDistribution()
Default constructor needed for serialization.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
RealScalar s
DiscreteDistribution(const Signature &s)
DiscreteDistribution(const DiscreteKey &key, const std::vector< double > &spec)
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
traits
Definition: chartTesting.h:28
DiscreteDistribution(const DecisionTreeFactor &f)
Constructor from factor.
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:38
internal::enable_if< internal::valid_indexed_view_overload< RowIndices, ColIndices >::value &&internal::traits< typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::ReturnAsIndexedView, typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::type operator()(const RowIndices &rowIndices, const ColIndices &colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:10