Added dim function and removed commented out code

release/4.3a0
Richard Roberts 2012-02-10 19:48:06 +00:00
parent 965417ea1b
commit 6a125ed5cb
3 changed files with 13 additions and 7 deletions

View File

@ -58,12 +58,6 @@ namespace gtsam {
} }
}; };
// /* ************************************************************************* */
// template<class ValueType>
// ValueType& operator=(ValueType& lhs, const ValueAutomaticCasting& rhs) {
// lhs = rhs;
// }
/* ************************************************************************* */ /* ************************************************************************* */
template<typename ValueType> template<typename ValueType>
const ValueType& Values::at(const Symbol& j) const { const ValueType& Values::at(const Symbol& j) const {

View File

@ -175,6 +175,15 @@ namespace gtsam {
return result; return result;
} }
/* ************************************************************************* */
size_t Values::dim() const {
size_t result = 0;
BOOST_FOREACH(const ConstKeyValuePair& key_value, *this) {
result += key_value.second.dim();
}
return result;
}
/* ************************************************************************* */ /* ************************************************************************* */
Ordering::shared_ptr Values::orderingArbitrary(Index firstVar) const { Ordering::shared_ptr Values::orderingArbitrary(Index firstVar) const {
Ordering::shared_ptr ordering(new Ordering); Ordering::shared_ptr ordering(new Ordering);

View File

@ -255,9 +255,12 @@ namespace gtsam {
/** Remove all variables from the config */ /** Remove all variables from the config */
void clear() { values_.clear(); } void clear() { values_.clear(); }
/** Create an array of variable dimensions using the given ordering */ /** Create an array of variable dimensions using the given ordering (\f$ O(n) \f$) */
std::vector<size_t> dims(const Ordering& ordering) const; std::vector<size_t> dims(const Ordering& ordering) const;
/** Compute the total dimensionality of all values (\f$ O(n) \f$) */
size_t dim() const;
/** /**
* Generate a default ordering, simply in key sort order. To instead * Generate a default ordering, simply in key sort order. To instead
* create a fill-reducing ordering, use * create a fill-reducing ordering, use