diff --git a/gtsam/linear/VectorValues.cpp b/gtsam/linear/VectorValues.cpp index 15925c644..fd7f2757c 100644 --- a/gtsam/linear/VectorValues.cpp +++ b/gtsam/linear/VectorValues.cpp @@ -45,6 +45,14 @@ VectorValues VectorValues::Zero(const VectorValues& x) { return cloned; } +/* ************************************************************************* */ +vector VectorValues::dims() const { + std::vector result(this->size()); + for(Index j = 0; j < this->size(); ++j) + result[j] = this->dim(j); + return result; +} + /* ************************************************************************* */ void VectorValues::insert(Index j, const Vector& value) { // Make sure j does not already exist @@ -188,4 +196,10 @@ VectorValues VectorValues::permute(const Permutation& permutation) const { return lhs; } +/* ************************************************************************* */ +void VectorValues::swap(VectorValues& other) { + this->values_.swap(other.values_); + this->maps_.swap(other.maps_); +} + } \ No newline at end of file diff --git a/gtsam/linear/VectorValues.h b/gtsam/linear/VectorValues.h index 463080db9..aa9c1aa6d 100644 --- a/gtsam/linear/VectorValues.h +++ b/gtsam/linear/VectorValues.h @@ -134,6 +134,9 @@ namespace gtsam { /** Return the summed dimensionality of all variables. */ size_t dim() const { return values_.rows(); } + /** Return the dimension of each vector in this container */ + std::vector dims() const; + /** Check whether a variable with index \c j exists. */ bool exists(Index j) const { return j < size() && maps_[j].rows() > 0; } @@ -296,6 +299,11 @@ namespace gtsam { */ VectorValues permute(const Permutation& permutation) const; + /** + * Swap the data in this VectorValues with another. + */ + void swap(VectorValues& other); + /// @} private: