remove const ref push_back
parent
c7e1c60224
commit
3dbb16a114
|
@ -111,28 +111,10 @@ class GTSAM_EXPORT HybridBayesNet : public BayesNet<HybridConditional> {
|
||||||
* @return IsSharedPtr<CONDITIONAL>
|
* @return IsSharedPtr<CONDITIONAL>
|
||||||
*/
|
*/
|
||||||
template <class CONDITIONAL>
|
template <class CONDITIONAL>
|
||||||
IsSharedPtr<CONDITIONAL> push_back(const CONDITIONAL &conditional) {
|
void push_back(std::shared_ptr<CONDITIONAL> conditional) {
|
||||||
factors_.push_back(std::make_shared<HybridConditional>(conditional));
|
factors_.push_back(std::make_shared<HybridConditional>(conditional));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Add a conditional to the Bayes net.
|
|
||||||
* Implicitly convert to a HybridConditional.
|
|
||||||
*
|
|
||||||
* E.g.
|
|
||||||
* hbn.push_back(DiscreteConditional(m, "1/1"));
|
|
||||||
* hbn.push_back(GaussianConditional(X(0), Vector1(0.0), I_1x1));
|
|
||||||
*
|
|
||||||
* @tparam CONDITIONAL Type of conditional. This is const ref version.
|
|
||||||
* @param conditional The conditional as a const reference.
|
|
||||||
* @return IsSharedPtr<CONDITIONAL>
|
|
||||||
*/
|
|
||||||
template <class CONDITIONAL>
|
|
||||||
IsNotSharedPtr<CONDITIONAL> push_back(const CONDITIONAL &conditional) {
|
|
||||||
auto cond_shared_ptr = std::make_shared<CONDITIONAL>(conditional);
|
|
||||||
push_back(cond_shared_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preferred: add a conditional directly using a pointer.
|
* Preferred: add a conditional directly using a pointer.
|
||||||
*
|
*
|
||||||
|
|
|
@ -228,12 +228,17 @@ static HybridBayesNet GetGaussianMixtureModel(double mu0, double mu1,
|
||||||
auto c0 = make_shared<GaussianConditional>(z, Vector1(mu0), I_1x1, model0),
|
auto c0 = make_shared<GaussianConditional>(z, Vector1(mu0), I_1x1, model0),
|
||||||
c1 = make_shared<GaussianConditional>(z, Vector1(mu1), I_1x1, model1);
|
c1 = make_shared<GaussianConditional>(z, Vector1(mu1), I_1x1, model1);
|
||||||
|
|
||||||
GaussianMixture gm({z}, {}, {m}, {c0, c1});
|
KeyVector frontalKeys{z}, continuousParents;
|
||||||
DiscreteConditional mixing(m, "0.5/0.5");
|
DiscreteKeys discreteParents{m};
|
||||||
|
std::vector<GaussianConditional::shared_ptr> conditionals = {c0, c1};
|
||||||
|
auto gm = make_shared<GaussianMixture>(frontalKeys, continuousParents,
|
||||||
|
discreteParents, conditionals);
|
||||||
|
|
||||||
HybridBayesNet hbn;
|
HybridBayesNet hbn;
|
||||||
hbn.push_back(gm);
|
hbn.push_back(gm);
|
||||||
hbn.push_back(mixing);
|
|
||||||
|
auto mixing = make_shared<DiscreteConditional>(m, "0.5/0.5");
|
||||||
|
hbn.emplace_shared<HybridConditional>(mixing);
|
||||||
|
|
||||||
return hbn;
|
return hbn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue