add nrValues method
parent
7150f284a8
commit
d1d440ad34
|
@ -255,6 +255,12 @@ namespace gtsam {
|
|||
*/
|
||||
DecisionTreeFactor prune(size_t maxNrAssignments) const;
|
||||
|
||||
/**
|
||||
* Get the number of non-zero values contained in this factor.
|
||||
* It could be much smaller than `prod_{key}(cardinality(key))`.
|
||||
*/
|
||||
uint64_t nrValues() const override { return nrLeaves(); }
|
||||
|
||||
/// @}
|
||||
/// @name Wrapper support
|
||||
/// @{
|
||||
|
|
|
@ -113,6 +113,12 @@ class GTSAM_EXPORT DiscreteFactor : public Factor {
|
|||
|
||||
virtual DecisionTreeFactor toDecisionTreeFactor() const = 0;
|
||||
|
||||
/**
|
||||
* Get the number of non-zero values contained in this factor.
|
||||
* It could be much smaller than `prod_{key}(cardinality(key))`.
|
||||
*/
|
||||
virtual uint64_t nrValues() const = 0;
|
||||
|
||||
/// @}
|
||||
/// @name Wrapper support
|
||||
/// @{
|
||||
|
|
|
@ -324,6 +324,12 @@ class GTSAM_EXPORT TableFactor : public DiscreteFactor {
|
|||
*/
|
||||
TableFactor prune(size_t maxNrAssignments) const;
|
||||
|
||||
/**
|
||||
* Get the number of non-zero values contained in this factor.
|
||||
* It could be much smaller than `prod_{key}(cardinality(key))`.
|
||||
*/
|
||||
uint64_t nrValues() const override { return sparse_table_.nonZeros(); }
|
||||
|
||||
/// @}
|
||||
/// @name Wrapper support
|
||||
/// @{
|
||||
|
|
|
@ -72,6 +72,9 @@ class GTSAM_UNSTABLE_EXPORT AllDiff : public Constraint {
|
|||
/// Partially apply known values, domain version
|
||||
Constraint::shared_ptr partiallyApply(
|
||||
const Domains&) const override;
|
||||
|
||||
/// Get the number of non-zero values contained in this factor.
|
||||
uint64_t nrValues() const override { return 1; };
|
||||
};
|
||||
|
||||
} // namespace gtsam
|
||||
|
|
|
@ -96,6 +96,9 @@ class BinaryAllDiff : public Constraint {
|
|||
AlgebraicDecisionTree<Key> errorTree() const override {
|
||||
throw std::runtime_error("BinaryAllDiff::error not implemented");
|
||||
}
|
||||
|
||||
/// Get the number of non-zero values contained in this factor.
|
||||
uint64_t nrValues() const override { return 1; };
|
||||
};
|
||||
|
||||
} // namespace gtsam
|
||||
|
|
|
@ -49,7 +49,7 @@ class GTSAM_UNSTABLE_EXPORT Domain : public Constraint {
|
|||
/// Erase a value, non const :-(
|
||||
void erase(size_t value) { values_.erase(value); }
|
||||
|
||||
size_t nrValues() const { return values_.size(); }
|
||||
uint64_t nrValues() const override { return values_.size(); }
|
||||
|
||||
bool isSingleton() const { return nrValues() == 1; }
|
||||
|
||||
|
|
|
@ -77,6 +77,9 @@ class GTSAM_UNSTABLE_EXPORT SingleValue : public Constraint {
|
|||
/// Partially apply known values, domain version
|
||||
Constraint::shared_ptr partiallyApply(
|
||||
const Domains& domains) const override;
|
||||
|
||||
/// Get the number of non-zero values contained in this factor.
|
||||
uint64_t nrValues() const override { return 1; };
|
||||
};
|
||||
|
||||
} // namespace gtsam
|
||||
|
|
Loading…
Reference in New Issue