diff --git a/gtsam/discrete/DiscreteConditional.cpp b/gtsam/discrete/DiscreteConditional.cpp index ca8f13ca3..f9d3823d6 100644 --- a/gtsam/discrete/DiscreteConditional.cpp +++ b/gtsam/discrete/DiscreteConditional.cpp @@ -192,7 +192,14 @@ namespace gtsam { return sampled; return 0; - } + } + + /* ******************************************************************************** */ + void DiscreteConditional::permuteWithInverse(const Permutation& inversePermutation){ + IndexConditional::permuteWithInverse(inversePermutation); + Potentials::permute(inversePermutation); + } + /* ******************************************************************************** */ diff --git a/gtsam/discrete/DiscreteConditional.h b/gtsam/discrete/DiscreteConditional.h index f6603c195..6c724bf7f 100644 --- a/gtsam/discrete/DiscreteConditional.h +++ b/gtsam/discrete/DiscreteConditional.h @@ -111,6 +111,11 @@ namespace gtsam { /// sample in place, stores result in partial solution void sampleInPlace(Values& parentsValues) const; + /** + * Permutes both IndexConditional and Potentials. + */ + void permuteWithInverse(const Permutation& inversePermutation); + /// @} };