make evaluate use the Assignment<Key> base class
parent
2cd2ab0a43
commit
9f88a360df
|
@ -129,9 +129,9 @@ namespace gtsam {
|
||||||
/// @name Standard Interface
|
/// @name Standard Interface
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
/// Calculate probability for given values `x`,
|
/// Calculate probability for given values,
|
||||||
/// is just look up in AlgebraicDecisionTree.
|
/// is just look up in AlgebraicDecisionTree.
|
||||||
double evaluate(const Assignment<Key>& values) const {
|
double evaluate(const Assignment<Key>& values) const override {
|
||||||
return ADT::operator()(values);
|
return ADT::operator()(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,9 @@ class GTSAM_EXPORT DiscreteFactor : public Factor {
|
||||||
virtual DiscreteFactor::shared_ptr operator/(
|
virtual DiscreteFactor::shared_ptr operator/(
|
||||||
const DiscreteFactor::shared_ptr& f) const = 0;
|
const DiscreteFactor::shared_ptr& f) const = 0;
|
||||||
|
|
||||||
|
/// Calculate probability for given values
|
||||||
|
virtual double evaluate(const Assignment<Key>& values) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of non-zero values contained in this factor.
|
* Get the number of non-zero values contained in this factor.
|
||||||
* It could be much smaller than `prod_{key}(cardinality(key))`.
|
* It could be much smaller than `prod_{key}(cardinality(key))`.
|
||||||
|
|
|
@ -135,7 +135,7 @@ bool TableFactor::equals(const DiscreteFactor& other, double tol) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
double TableFactor::operator()(const DiscreteValues& values) const {
|
double TableFactor::operator()(const Assignment<Key>& values) const {
|
||||||
// a b c d => D * (C * (B * (a) + b) + c) + d
|
// a b c d => D * (C * (B * (a) + b) + c) + d
|
||||||
uint64_t idx = 0, card = 1;
|
uint64_t idx = 0, card = 1;
|
||||||
for (auto it = sorted_dkeys_.rbegin(); it != sorted_dkeys_.rend(); ++it) {
|
for (auto it = sorted_dkeys_.rbegin(); it != sorted_dkeys_.rend(); ++it) {
|
||||||
|
|
|
@ -169,14 +169,17 @@ class GTSAM_EXPORT TableFactor : public DiscreteFactor {
|
||||||
// /// @name Standard Interface
|
// /// @name Standard Interface
|
||||||
// /// @{
|
// /// @{
|
||||||
|
|
||||||
/// Calculate probability for given values `x`,
|
/// Calculate probability for given values,
|
||||||
/// is just look up in TableFactor.
|
/// is just look up in TableFactor.
|
||||||
double evaluate(const DiscreteValues& values) const {
|
double evaluate(const Assignment<Key>& values) const override {
|
||||||
return operator()(values);
|
return operator()(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluate probability distribution, sugar.
|
/// Evaluate probability distribution, sugar.
|
||||||
double operator()(const DiscreteValues& values) const override;
|
double operator()(const Assignment<Key>& values) const;
|
||||||
|
double operator()(const DiscreteValues& values) const override {
|
||||||
|
return operator()(Assignment<Key>(values));
|
||||||
|
}
|
||||||
|
|
||||||
/// Calculate error for DiscreteValues `x`, is -log(probability).
|
/// Calculate error for DiscreteValues `x`, is -log(probability).
|
||||||
double error(const DiscreteValues& values) const override;
|
double error(const DiscreteValues& values) const override;
|
||||||
|
|
Loading…
Reference in New Issue