Minor change to shortcut
parent
2d0ce1c3ca
commit
bfc033d3f7
|
@ -113,7 +113,7 @@ namespace gtsam {
|
||||||
|
|
||||||
static const bool debug = false;
|
static const bool debug = false;
|
||||||
|
|
||||||
BayesNet<ConditionalType> p_S_R; //shortcut P(S|R)
|
BayesNet<ConditionalType> p_S_R; //shortcut P(S|R) This is empty now
|
||||||
|
|
||||||
//Check if the ShortCut already exists
|
//Check if the ShortCut already exists
|
||||||
if(!cachedShortcut_){
|
if(!cachedShortcut_){
|
||||||
|
@ -122,11 +122,7 @@ namespace gtsam {
|
||||||
// in which case we return an empty Bayes net.
|
// in which case we return an empty Bayes net.
|
||||||
|
|
||||||
derived_ptr parent(parent_.lock());
|
derived_ptr parent(parent_.lock());
|
||||||
|
if (R.get() != this && parent != R) {
|
||||||
if (R.get() == this || parent == R) {
|
|
||||||
BayesNet<ConditionalType> empty;
|
|
||||||
return empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The root conditional
|
// The root conditional
|
||||||
FactorGraph<FactorType> p_R(BayesNet<ConditionalType>(R->conditional()));
|
FactorGraph<FactorType> p_R(BayesNet<ConditionalType>(R->conditional()));
|
||||||
|
@ -201,12 +197,14 @@ namespace gtsam {
|
||||||
// Undo the permutation
|
// Undo the permutation
|
||||||
if(debug) toBack.print("toBack: ");
|
if(debug) toBack.print("toBack: ");
|
||||||
p_S_R.permuteWithInverse(toBack);
|
p_S_R.permuteWithInverse(toBack);
|
||||||
|
}
|
||||||
|
|
||||||
assertInvariants();
|
|
||||||
cachedShortcut_ = p_S_R;
|
cachedShortcut_ = p_S_R;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
p_S_R = *cachedShortcut_;
|
p_S_R = *cachedShortcut_; // return the cached version
|
||||||
|
|
||||||
|
assertInvariants();
|
||||||
|
|
||||||
// return the shortcut P(S|R)
|
// return the shortcut P(S|R)
|
||||||
return p_S_R;
|
return p_S_R;
|
||||||
|
|
Loading…
Reference in New Issue