diff --git a/nonlinear/TupleValues-inl.h b/nonlinear/TupleValues-inl.h index f4e47b861..e6699b0c1 100644 --- a/nonlinear/TupleValues-inl.h +++ b/nonlinear/TupleValues-inl.h @@ -49,140 +49,140 @@ namespace gtsam { /* ************************************************************************* */ /** TupleValues 1 */ -template -TupleValues1::TupleValues1(const TupleValues1& config) : - TupleValuesEnd (config) {} +template +TupleValues1::TupleValues1(const TupleValues1& config) : + TupleValuesEnd (config) {} -template -TupleValues1::TupleValues1(const Values1& cfg1) : - TupleValuesEnd (cfg1) {} +template +TupleValues1::TupleValues1(const VALUES1& cfg1) : + TupleValuesEnd (cfg1) {} -template -TupleValues1::TupleValues1(const TupleValuesEnd& config) : - TupleValuesEnd(config) {} +template +TupleValues1::TupleValues1(const TupleValuesEnd& config) : + TupleValuesEnd(config) {} /* ************************************************************************* */ /** TupleValues 2 */ -template -TupleValues2::TupleValues2(const TupleValues2& config) : - TupleValues >(config) {} +template +TupleValues2::TupleValues2(const TupleValues2& config) : + TupleValues >(config) {} -template -TupleValues2::TupleValues2(const Values1& cfg1, const Values2& cfg2) : - TupleValues >( - cfg1, TupleValuesEnd(cfg2)) {} +template +TupleValues2::TupleValues2(const VALUES1& cfg1, const VALUES2& cfg2) : + TupleValues >( + cfg1, TupleValuesEnd(cfg2)) {} -template -TupleValues2::TupleValues2(const TupleValues >& config) : - TupleValues >(config) {} +template +TupleValues2::TupleValues2(const TupleValues >& config) : + TupleValues >(config) {} /* ************************************************************************* */ /** TupleValues 3 */ -template -TupleValues3::TupleValues3( - const TupleValues3& config) : - TupleValues > >(config) {} +template +TupleValues3::TupleValues3( + const TupleValues3& config) : + TupleValues > >(config) {} -template -TupleValues3::TupleValues3( - const Values1& cfg1, const Values2& cfg2, const Values3& cfg3) : - TupleValues > >( - cfg1, TupleValues >( - cfg2, TupleValuesEnd(cfg3))) {} +template +TupleValues3::TupleValues3( + const VALUES1& cfg1, const VALUES2& cfg2, const VALUES3& cfg3) : + TupleValues > >( + cfg1, TupleValues >( + cfg2, TupleValuesEnd(cfg3))) {} -template -TupleValues3::TupleValues3( - const TupleValues > >& config) : - TupleValues > >(config) {} +template +TupleValues3::TupleValues3( + const TupleValues > >& config) : + TupleValues > >(config) {} /* ************************************************************************* */ /** TupleValues 4 */ -template -TupleValues4::TupleValues4( - const TupleValues4& config) : - TupleValues > > >(config) {} +template +TupleValues4::TupleValues4( + const TupleValues4& config) : + TupleValues > > >(config) {} -template -TupleValues4::TupleValues4( - const Values1& cfg1, const Values2& cfg2, - const Values3& cfg3,const Values4& cfg4) : - TupleValues > > >( - cfg1, TupleValues > >( - cfg2, TupleValues >( - cfg3, TupleValuesEnd(cfg4)))) {} +template +TupleValues4::TupleValues4( + const VALUES1& cfg1, const VALUES2& cfg2, + const VALUES3& cfg3,const VALUES4& cfg4) : + TupleValues > > >( + cfg1, TupleValues > >( + cfg2, TupleValues >( + cfg3, TupleValuesEnd(cfg4)))) {} -template -TupleValues4::TupleValues4( - const TupleValues > > >& config) : - TupleValues > > >(config) {} +template +TupleValues4::TupleValues4( + const TupleValues > > >& config) : + TupleValues > > >(config) {} /* ************************************************************************* */ /** TupleValues 5 */ -template -TupleValues5::TupleValues5( - const TupleValues5& config) : - TupleValues > > > >(config) {} +template +TupleValues5::TupleValues5( + const TupleValues5& config) : + TupleValues > > > >(config) {} -template -TupleValues5::TupleValues5( - const Values1& cfg1, const Values2& cfg2, const Values3& cfg3, - const Values4& cfg4, const Values5& cfg5) : - TupleValues > > > >( - cfg1, TupleValues > > >( - cfg2, TupleValues > >( - cfg3, TupleValues >( - cfg4, TupleValuesEnd(cfg5))))) {} +template +TupleValues5::TupleValues5( + const VALUES1& cfg1, const VALUES2& cfg2, const VALUES3& cfg3, + const VALUES4& cfg4, const VALUES5& cfg5) : + TupleValues > > > >( + cfg1, TupleValues > > >( + cfg2, TupleValues > >( + cfg3, TupleValues >( + cfg4, TupleValuesEnd(cfg5))))) {} -template -TupleValues5::TupleValues5( - const TupleValues > > > >& config) : - TupleValues > > > >(config) {} +template +TupleValues5::TupleValues5( + const TupleValues > > > >& config) : + TupleValues > > > >(config) {} /* ************************************************************************* */ /** TupleValues 6 */ -template -TupleValues6::TupleValues6( - const TupleValues6& config) : - TupleValues > > > > >(config) {} +template +TupleValues6::TupleValues6( + const TupleValues6& config) : + TupleValues > > > > >(config) {} -template -TupleValues6::TupleValues6( - const Values1& cfg1, const Values2& cfg2, const Values3& cfg3, - const Values4& cfg4, const Values5& cfg5, const Values6& cfg6) : - TupleValues > > > > >( - cfg1, TupleValues > > > >( - cfg2, TupleValues > > >( - cfg3, TupleValues > >( - cfg4, TupleValues >( - cfg5, TupleValuesEnd(cfg6)))))) {} +template +TupleValues6::TupleValues6( + const VALUES1& cfg1, const VALUES2& cfg2, const VALUES3& cfg3, + const VALUES4& cfg4, const VALUES5& cfg5, const VALUES6& cfg6) : + TupleValues > > > > >( + cfg1, TupleValues > > > >( + cfg2, TupleValues > > >( + cfg3, TupleValues > >( + cfg4, TupleValues >( + cfg5, TupleValuesEnd(cfg6)))))) {} -template -TupleValues6::TupleValues6( - const TupleValues > > > > >& config) : - TupleValues > > > > >(config) {} +template +TupleValues6::TupleValues6( + const TupleValues > > > > >& config) : + TupleValues > > > > >(config) {} } diff --git a/nonlinear/TupleValues.h b/nonlinear/TupleValues.h index cb3ad6cbb..f87eebfa9 100644 --- a/nonlinear/TupleValues.h +++ b/nonlinear/TupleValues.h @@ -46,28 +46,28 @@ namespace gtsam { * for the arguments to be passed to the next config, while the specialized one * operates on the "first" config. TupleValuesEnd contains only the specialized version. */ - template - class TupleValues : public Testable > { + template + class TupleValues : public Testable > { protected: // Data for internal configs - Values1 first_; /// Arbitrary config - Values2 second_; /// A TupleValues or TupleValuesEnd, which wraps an arbitrary config + VALUES1 first_; /// Arbitrary config + VALUES2 second_; /// A TupleValues or TupleValuesEnd, which wraps an arbitrary config public: // typedefs for config subtypes - typedef class Values1::Key Key1; - typedef class Values1::Value Value1; + typedef class VALUES1::Key Key1; + typedef class VALUES1::Value Value1; /** default constructor */ TupleValues() {} /** Copy constructor */ - TupleValues(const TupleValues& config) : + TupleValues(const TupleValues& config) : first_(config.first_), second_(config.second_) {} /** Construct from configs */ - TupleValues(const Values1& cfg1, const Values2& cfg2) : + TupleValues(const VALUES1& cfg1, const VALUES2& cfg2) : first_(cfg1), second_(cfg2) {} /** Print */ @@ -77,7 +77,7 @@ namespace gtsam { } /** Equality with tolerance for keys and values */ - bool equals(const TupleValues& c, double tol=1e-9) const { + bool equals(const TupleValues& c, double tol=1e-9) const { return first_.equals(c.first_, tol) && second_.equals(c.second_, tol); } @@ -88,8 +88,8 @@ namespace gtsam { * @param key is the key - can be an int (second version) if the can can be initialized from an int * @param value is the value to insert */ - template - void insert(const Key& key, const Value& value) {second_.insert(key, value);} + template + void insert(const KEY& key, const VALUE& value) {second_.insert(key, value);} void insert(int key, const Value1& value) {first_.insert(Key1(key), value);} void insert(const Key1& key, const Value1& value) {first_.insert(key, value);} @@ -99,9 +99,9 @@ namespace gtsam { * Use update() to allow for changing existing values. * @param config is a full config to add */ - template - void insert(const TupleValues& config) { second_.insert(config); } - void insert(const TupleValues& config) { + template + void insert(const TupleValues& config) { second_.insert(config); } + void insert(const TupleValues& config) { first_.insert(config.first_); second_.insert(config.second_); } @@ -110,9 +110,9 @@ namespace gtsam { * Update function for whole configs - this will change existing values * @param config is a config to add */ - template - void update(const TupleValues& config) { second_.update(config); } - void update(const TupleValues& config) { + template + void update(const TupleValues& config) { second_.update(config); } + void update(const TupleValues& config) { first_.update(config.first_); second_.update(config.second_); } @@ -122,49 +122,49 @@ namespace gtsam { * @param key is the variable identifier * @param value is the variable value to update */ - template - void update(const Key& key, const Value& value) { second_.update(key, value); } + template + void update(const KEY& key, const VALUE& value) { second_.update(key, value); } void update(const Key1& key, const Value1& value) { first_.update(key, value); } /** * Insert a subconfig * @param config is the config to insert */ - template - void insertSub(const Cfg& config) { second_.insertSub(config); } - void insertSub(const Values1& config) { first_.insert(config); } + template + void insertSub(const CFG& config) { second_.insertSub(config); } + void insertSub(const VALUES1& config) { first_.insert(config); } /** erase an element by key */ - template - void erase(const Key& j) { second_.erase(j); } + template + void erase(const KEY& j) { second_.erase(j); } void erase(const Key1& j) { first_.erase(j); } /** clears the config */ void clear() { first_.clear(); second_.clear(); } /** determine whether an element exists */ - template - bool exists(const Key& j) const { return second_.exists(j); } + template + bool exists(const KEY& j) const { return second_.exists(j); } bool exists(const Key1& j) const { return first_.exists(j); } /** a variant of exists */ - template - boost::optional exists_(const Key& j) const { return second_.exists_(j); } + template + boost::optional exists_(const KEY& j) const { return second_.exists_(j); } boost::optional exists_(const Key1& j) const { return first_.exists_(j); } /** access operator */ - template - const typename Key::Value & operator[](const Key& j) const { return second_[j]; } + template + const typename KEY::Value & operator[](const KEY& j) const { return second_[j]; } const Value1& operator[](const Key1& j) const { return first_[j]; } /** at access function */ - template - const typename Key::Value & at(const Key& j) const { return second_.at(j); } + template + const typename KEY::Value & at(const KEY& j) const { return second_.at(j); } const Value1& at(const Key1& j) const { return first_.at(j); } /** direct config access */ - const Values1& config() const { return first_; } - const Values2& rest() const { return second_; } + const VALUES1& config() const { return first_; } + const VALUES2& rest() const { return second_; } /** zero: create VectorValues of appropriate structure */ VectorValues zero(const Ordering& ordering) const { @@ -203,19 +203,19 @@ namespace gtsam { } /** Expmap */ - TupleValues expmap(const VectorValues& delta, const Ordering& ordering) const { + TupleValues expmap(const VectorValues& delta, const Ordering& ordering) const { return TupleValues(first_.expmap(delta, ordering), second_.expmap(delta, ordering)); } /** logmap each element */ - VectorValues logmap(const TupleValues& cp, const Ordering& ordering) const { + VectorValues logmap(const TupleValues& cp, const Ordering& ordering) const { VectorValues delta(this->dims(ordering)); logmap(cp, ordering, delta); return delta; } /** logmap each element */ - void logmap(const TupleValues& cp, const Ordering& ordering, VectorValues& delta) const { + void logmap(const TupleValues& cp, const Ordering& ordering, VectorValues& delta) const { first_.logmap(cp.first_, ordering, delta); second_.logmap(cp.second_, ordering, delta); } @@ -239,8 +239,8 @@ namespace gtsam { private: /** Serialization function */ friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) { + template + void serialize(ARCHIVE & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP(first_); ar & BOOST_SERIALIZATION_NVP(second_); } @@ -253,48 +253,48 @@ namespace gtsam { * Do not use this class directly - it should only be used as a part * of a recursive structure */ - template - class TupleValuesEnd : public Testable > { + template + class TupleValuesEnd : public Testable > { protected: // Data for internal configs - Values first_; + VALUES first_; public: // typedefs - typedef class Values::Key Key1; - typedef class Values::Value Value1; + typedef class VALUES::Key Key1; + typedef class VALUES::Value Value1; TupleValuesEnd() {} - TupleValuesEnd(const TupleValuesEnd& config) : + TupleValuesEnd(const TupleValuesEnd& config) : first_(config.first_) {} - TupleValuesEnd(const Values& cfg) : + TupleValuesEnd(const VALUES& cfg) : first_(cfg) {} void print(const std::string& s = "") const { first_.print(); } - bool equals(const TupleValuesEnd& c, double tol=1e-9) const { + bool equals(const TupleValuesEnd& c, double tol=1e-9) const { return first_.equals(c.first_, tol); } void insert(const Key1& key, const Value1& value) {first_.insert(key, value); } void insert(int key, const Value1& value) {first_.insert(Key1(key), value);} - void insert(const TupleValuesEnd& config) {first_.insert(config.first_); } + void insert(const TupleValuesEnd& config) {first_.insert(config.first_); } - void update(const TupleValuesEnd& config) {first_.update(config.first_); } + void update(const TupleValuesEnd& config) {first_.update(config.first_); } void update(const Key1& key, const Value1& value) { first_.update(key, value); } - void insertSub(const Values& config) {first_.insert(config); } + void insertSub(const VALUES& config) {first_.insert(config); } const Value1& operator[](const Key1& j) const { return first_[j]; } - const Values& config() const { return first_; } + const VALUES& config() const { return first_; } void erase(const Key1& j) { first_.erase(j); } @@ -318,17 +318,17 @@ namespace gtsam { size_t dim() const { return first_.dim(); } - TupleValuesEnd expmap(const VectorValues& delta, const Ordering& ordering) const { + TupleValuesEnd expmap(const VectorValues& delta, const Ordering& ordering) const { return TupleValuesEnd(first_.expmap(delta, ordering)); } - VectorValues logmap(const TupleValuesEnd& cp, const Ordering& ordering) const { + VectorValues logmap(const TupleValuesEnd& cp, const Ordering& ordering) const { VectorValues delta(this->dims(ordering)); logmap(cp, ordering, delta); return delta; } - void logmap(const TupleValuesEnd& cp, const Ordering& ordering, VectorValues& delta) const { + void logmap(const TupleValuesEnd& cp, const Ordering& ordering, VectorValues& delta) const { first_.logmap(cp.first_, ordering, delta); } @@ -348,8 +348,8 @@ namespace gtsam { private: friend class boost::serialization::access; - template - void serialize(Archive & ar, const unsigned int version) { + template + void serialize(ARCHIVE & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP(first_); } };