Added dims() and swap() functions to VectorValues
parent
abd6795f5b
commit
ad53c20b0d
|
@ -45,6 +45,14 @@ VectorValues VectorValues::Zero(const VectorValues& x) {
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
vector<size_t> VectorValues::dims() const {
|
||||||
|
std::vector<size_t> 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) {
|
void VectorValues::insert(Index j, const Vector& value) {
|
||||||
// Make sure j does not already exist
|
// Make sure j does not already exist
|
||||||
|
@ -188,4 +196,10 @@ VectorValues VectorValues::permute(const Permutation& permutation) const {
|
||||||
return lhs;
|
return lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
void VectorValues::swap(VectorValues& other) {
|
||||||
|
this->values_.swap(other.values_);
|
||||||
|
this->maps_.swap(other.maps_);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -134,6 +134,9 @@ namespace gtsam {
|
||||||
/** Return the summed dimensionality of all variables. */
|
/** Return the summed dimensionality of all variables. */
|
||||||
size_t dim() const { return values_.rows(); }
|
size_t dim() const { return values_.rows(); }
|
||||||
|
|
||||||
|
/** Return the dimension of each vector in this container */
|
||||||
|
std::vector<size_t> dims() const;
|
||||||
|
|
||||||
/** Check whether a variable with index \c j exists. */
|
/** Check whether a variable with index \c j exists. */
|
||||||
bool exists(Index j) const { return j < size() && maps_[j].rows() > 0; }
|
bool exists(Index j) const { return j < size() && maps_[j].rows() > 0; }
|
||||||
|
|
||||||
|
@ -296,6 +299,11 @@ namespace gtsam {
|
||||||
*/
|
*/
|
||||||
VectorValues permute(const Permutation& permutation) const;
|
VectorValues permute(const Permutation& permutation) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swap the data in this VectorValues with another.
|
||||||
|
*/
|
||||||
|
void swap(VectorValues& other);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue