diff --git a/gtsam/nonlinear/Marginals.cpp b/gtsam/nonlinear/Marginals.cpp index 34d620bc2..6df7dfdac 100644 --- a/gtsam/nonlinear/Marginals.cpp +++ b/gtsam/nonlinear/Marginals.cpp @@ -73,6 +73,19 @@ Matrix Marginals::marginalInformation(Key variable) const { } } +/* ************************************************************************* */ +JointMarginal::JointMarginal(const JointMarginal& other) : + blockView_(fullMatrix_) { + *this = other; +} + +/* ************************************************************************* */ +JointMarginal& JointMarginal::operator=(const JointMarginal& rhs) { + indices_ = rhs.indices_; + blockView_.assignNoalias(rhs.blockView_); + return *this; +} + /* ************************************************************************* */ JointMarginal Marginals::jointMarginalCovariance(const std::vector& variables) const { JointMarginal info = jointMarginalInformation(variables); diff --git a/gtsam/nonlinear/Marginals.h b/gtsam/nonlinear/Marginals.h index 77bccdfd2..fe5d4b21d 100644 --- a/gtsam/nonlinear/Marginals.h +++ b/gtsam/nonlinear/Marginals.h @@ -102,6 +102,12 @@ public: Block operator()(Key iVariable, Key jVariable) const { return blockView_(indices_[iVariable], indices_[jVariable]); } + /** Copy constructor */ + JointMarginal(const JointMarginal& other); + + /** Assignment operator */ + JointMarginal& operator=(const JointMarginal& rhs); + protected: Matrix fullMatrix_; BlockView blockView_;