diff --git a/gtsam/discrete/TableDistribution.cpp b/gtsam/discrete/TableDistribution.cpp index b74acbbd1..6669cea4a 100644 --- a/gtsam/discrete/TableDistribution.cpp +++ b/gtsam/discrete/TableDistribution.cpp @@ -50,6 +50,19 @@ TableDistribution::TableDistribution( table_(TableFactor(keys, potentials)) {} /* ************************************************************************** */ +TableDistribution::TableDistribution(const DiscreteKeys& keys, + const std::vector& potentials) + : BaseConditional(keys.size(), keys, DecisionTreeFactor(keys, ADT())), + table_(TableFactor(keys, potentials)) {} + +/* ************************************************************************** */ +TableDistribution::TableDistribution(const DiscreteKeys& keys, + const std::string& potentials) + : BaseConditional(keys.size(), keys, DecisionTreeFactor(keys, ADT())), + table_(TableFactor(keys, potentials)) {} + +/* ************************************************************************** + */ TableDistribution::TableDistribution(const TableFactor& joint, const TableFactor& marginal) : BaseConditional(joint.size() - marginal.size(), @@ -72,12 +85,6 @@ void TableDistribution::print(const string& s, for (const_iterator it = beginFrontals(); it != endFrontals(); ++it) { cout << formatter(*it) << " "; } - if (nrParents()) { - cout << "| "; - for (const_iterator it = beginParents(); it != endParents(); ++it) { - cout << formatter(*it) << " "; - } - } cout << "):\n"; table_.print("", formatter); cout << endl; diff --git a/gtsam/discrete/TableDistribution.h b/gtsam/discrete/TableDistribution.h index a1c463e0e..655774f04 100644 --- a/gtsam/discrete/TableDistribution.h +++ b/gtsam/discrete/TableDistribution.h @@ -62,12 +62,35 @@ class GTSAM_EXPORT TableDistribution : public DiscreteConditional { TableDistribution(const TableFactor& f); /** - * Construct from DiscreteKeys and SparseVector, taking the first - * `nFrontals` keys as frontals, in the order given. + * Construct from DiscreteKeys and SparseVector. */ TableDistribution(const DiscreteKeys& keys, const Eigen::SparseVector& potentials); + /** + * Construct from DiscreteKeys and std::vector. + */ + TableDistribution(const DiscreteKeys& keys, + const std::vector& potentials); + + /** + * Construct from single DiscreteKey and std::vector. + */ + TableDistribution(const DiscreteKey& key, + const std::vector& potentials) + : TableDistribution(DiscreteKeys(key), potentials) {} + + /** + * Construct from DiscreteKey and std::string. + */ + TableDistribution(const DiscreteKeys& key, const std::string& potentials); + + /** + * Construct from single DiscreteKey and std::string. + */ + TableDistribution(const DiscreteKey& key, const std::string& potentials) + : TableDistribution(DiscreteKeys(key), potentials) {} + /** * @brief construct P(X|Y) = f(X,Y)/f(Y) from f(X,Y) and f(Y) * Assumes but *does not check* that f(Y)=sum_X f(X,Y).