62 template<
class FACTOR,
class DERIVEDCONDITIONAL>
77 typedef std::pair<typename FACTOR::const_iterator, typename FACTOR::const_iterator>
ConstFactorRange;
78 struct ConstFactorRangeIterator {
81 ConstFactorRangeIterator() =
delete;
84 typename FACTOR::const_iterator begin()
const {
return range_.first; }
85 typename FACTOR::const_iterator end()
const {
return range_.second; }
86 size_t size()
const {
return std::distance(range_.first, range_.second); }
87 const auto& front()
const {
return *begin(); }
89 template <
class OTHER>
90 bool operator==(
const OTHER& rhs)
const {
91 if (this->size() != rhs.size())
return false;
92 if (this->size() == 0)
return true;
93 return std::equal(begin(), end(), rhs.begin(), rhs.end());
123 bool equals(
const This& c,
double tol = 1e-9)
const;
141 return asFactor().front();
143 throw std::invalid_argument(
"Requested Conditional::firstFrontalKey from a conditional with zero frontal keys");
182 typename FACTOR::const_iterator
beginFrontals()
const {
return asFactor().begin(); }
191 typename FACTOR::const_iterator
endParents()
const {
return asFactor().end(); }
206 typename FACTOR::iterator
endParents() {
return asFactor().end(); }
221 template <
class VALUES>
233 FACTOR& asFactor() {
return static_cast<FACTOR&
>(
static_cast<DERIVEDCONDITIONAL&
>(*this)); }
236 const FACTOR& asFactor()
const {
return static_cast<const FACTOR&
>(
static_cast<const DERIVEDCONDITIONAL&
>(*this)); }
238#if GTSAM_ENABLE_BOOST_SERIALIZATION
240 friend class boost::serialization::access;
241 template<
class ARCHIVE>
242 void serialize(ARCHIVE & ar,
const unsigned int ) {
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
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
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:37
static bool CheckInvariants(const DERIVEDCONDITIONAL &conditional, const VALUES &x)
Check invariants of this conditional, given the values x.
Definition Conditional-inst.h:69
size_t nrFrontals_
Definition Conditional.h:67
Key firstFrontalKey() const
Convenience function to get the first frontal key.
Definition Conditional.h:139
FACTOR::const_iterator endFrontals() const
Iterator pointing past the last frontal key.
Definition Conditional.h:185
FACTOR::iterator endParents()
Mutable iterator pointing past the last parent key.
Definition Conditional.h:206
FACTOR::iterator endFrontals()
Mutable iterator pointing past the last frontal key.
Definition Conditional.h:200
virtual double evaluate(const HybridValues &c) const
All conditional types need to implement an evaluate function, that yields a true probability.
Definition Conditional-inst.h:55
Parents parents() const
return a view of the parent keys
Definition Conditional.h:150
bool equals(const This &c, double tol=1e-9) const
check equality
Definition Conditional-inst.h:41
virtual double negLogConstant() const
All conditional types need to implement this as the negative log of the normalization constant to mak...
Definition Conditional-inst.h:62
std::pair< typename BaseFactor::const_iterator, typename BaseFactor::const_iterator > ConstFactorRange
Definition Conditional.h:77
double operator()(const HybridValues &x) const
Evaluate probability density, sugar.
Definition Conditional.h:165
virtual double logProbability(const HybridValues &c) const
All conditional types need to implement a logProbability function, for which exp(logProbability(x)) =...
Definition Conditional-inst.h:48
size_t nrFrontals() const
Definition Conditional.h:133
Conditional()
Empty Constructor to make serialization possible.
Definition Conditional.h:108
Conditional(size_t nrFrontals)
Constructor.
Definition Conditional.h:111
FACTOR::iterator beginParents()
Mutable iterator pointing to the first parent key.
Definition Conditional.h:203
size_t & nrFrontals()
Mutable version of nrFrontals.
Definition Conditional.h:194
FACTOR::iterator beginFrontals()
Mutable iterator pointing to first frontal key.
Definition Conditional.h:197
Frontals frontals() const
return a view of the frontal keys
Definition Conditional.h:147
FACTOR::const_iterator beginFrontals() const
Iterator pointing to first frontal key.
Definition Conditional.h:182
ConstFactorRangeIterator Parents
Definition Conditional.h:101
ConstFactorRangeIterator Frontals
Definition Conditional.h:98
size_t nrParents() const
return the number of parents
Definition Conditional.h:136
void print(const std::string &s="Conditional", const KeyFormatter &formatter=DefaultKeyFormatter) const
print with optional formatter
Definition Conditional-inst.h:30
FACTOR::const_iterator endParents() const
Iterator pointing past the last parent key.
Definition Conditional.h:191
FACTOR::const_iterator beginParents() const
Iterator pointing to the first parent key.
Definition Conditional.h:188