add helpful constructors
parent
bd30bef1a3
commit
f9e3280d75
|
|
@ -50,6 +50,19 @@ TableDistribution::TableDistribution(
|
|||
table_(TableFactor(keys, potentials)) {}
|
||||
|
||||
/* ************************************************************************** */
|
||||
TableDistribution::TableDistribution(const DiscreteKeys& keys,
|
||||
const std::vector<double>& 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;
|
||||
|
|
|
|||
|
|
@ -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<double>& potentials);
|
||||
|
||||
/**
|
||||
* Construct from DiscreteKeys and std::vector.
|
||||
*/
|
||||
TableDistribution(const DiscreteKeys& keys,
|
||||
const std::vector<double>& potentials);
|
||||
|
||||
/**
|
||||
* Construct from single DiscreteKey and std::vector.
|
||||
*/
|
||||
TableDistribution(const DiscreteKey& key,
|
||||
const std::vector<double>& 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).
|
||||
|
|
|
|||
Loading…
Reference in New Issue