23 #include <gtsam/base/ConcurrentMap.h> 27 #include <boost/shared_ptr.hpp> 104 typedef std::map<Key,size_t> Dims;
118 template<
class CONTAINER>
119 explicit VectorValues(
const CONTAINER& c) : values_(c.begin(), c.end()) {}
125 template<
typename ITERATOR>
142 size_t size()
const {
return values_.size(); }
145 size_t dim(
Key j)
const {
return at(j).rows(); }
152 iterator item = find(j);
154 throw std::out_of_range(
155 "Requested variable '" + DefaultKeyFormatter(j) +
"' is not in this VectorValues.");
162 const_iterator item = find(j);
164 throw std::out_of_range(
165 "Requested variable '" + DefaultKeyFormatter(j) +
"' is not in this VectorValues.");
188 return insert(std::make_pair(j, value));
195 iterator insert(
const std::pair<Key, Vector>& key_value);
206 return values_.insert(std::make_pair(j, value)); }
210 if(values_.unsafe_erase(var) == 0)
211 throw std::invalid_argument(
"Requested variable '" + DefaultKeyFormatter(var) +
"', is not in this VectorValues.");
217 iterator
begin() {
return values_.begin(); }
218 const_iterator
begin()
const {
return values_.begin(); }
219 iterator
end() {
return values_.end(); }
220 const_iterator
end()
const {
return values_.end(); }
227 iterator
find(
Key j) {
return values_.find(j); }
230 const_iterator
find(
Key j)
const {
return values_.find(j); }
233 void print(
const std::string& str =
"VectorValues: ",
234 const KeyFormatter& formatter = DefaultKeyFormatter)
const;
244 Vector vector()
const;
250 Vector vector(
const Dims& dims)
const;
271 double squaredNorm()
const;
372 friend class boost::serialization::access;
373 template<
class ARCHIVE>
374 void serialize(ARCHIVE & ar,
const unsigned int ) {
375 ar & BOOST_SERIALIZATION_NVP(values_);
Values::iterator iterator
Iterator over vector values.
Definition: VectorValues.h:97
Values values_
Collection of Vectors making up this VectorValues.
Definition: VectorValues.h:94
Values::const_iterator const_iterator
Const iterator over vector values.
Definition: VectorValues.h:98
const_iterator find(Key j) const
Return the iterator corresponding to the requested key, or end() if no variable is present with this ...
Definition: VectorValues.h:230
const_iterator end() const
Iterator over variables.
Definition: VectorValues.h:220
VectorValues(const VectorValues &c)
Implicit copy constructor to specialize the explicit constructor from any container.
Definition: VectorValues.h:122
const Vector & operator[](Key j) const
Access the vector value with key j (const version), throws std::out_of_range if j does not exist...
Definition: VectorValues.h:176
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:140
ConcurrentMap< Key, Vector > Values
Typedef for the collection of Vectors making up a VectorValues.
Definition: VectorValues.h:93
Included from all GTSAM files.
boost::transform_iterator< boost::function1< ConstKeyValuePair, const ConstKeyValuePtrPair & >, KeyValueMap::const_iterator > const_iterator
Const forward iterator, with value type ConstKeyValuePair.
Definition: Values.h:123
BinarySumExpression< T > operator-(const Expression< T > &e1, const Expression< T > &e2)
Construct an expression that subtracts one expression from another.
Definition: Expression.h:279
Values::value_type value_type
Typedef to pair<Key, Vector>, a key-value pair.
Definition: VectorValues.h:102
size_t size() const
Number of variables stored.
Definition: VectorValues.h:142
size_t dim(Key j) const
Return the dimension of variable j.
Definition: VectorValues.h:145
typedef and functions to augment Eigen's VectorXd
bool exists(Key j) const
Check whether a variable with key j exists.
Definition: VectorValues.h:148
iterator find(Key j)
Return the iterator corresponding to the requested key, or end() if no variable is present with this ...
Definition: VectorValues.h:227
VectorValues(ITERATOR first, ITERATOR last)
Create from a pair of iterators over pair<Key,Vector>.
Definition: VectorValues.h:126
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
Template to create a binary predicate.
Definition: Testable.h:110
Vector & at(Key j)
Read/write access to the vector value with key j, throws std::out_of_range if j does not exist...
Definition: VectorValues.h:151
BinarySumExpression< T > operator+(const Expression< T > &e1, const Expression< T > &e2)
Construct an expression that sums two input expressions of the same type T The type T must be a vecto...
Definition: Expression.h:273
VectorValues(const CONTAINER &c)
Create from another container holding pair<Key,Vector>.
Definition: VectorValues.h:119
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:90
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
std::pair< iterator, bool > tryInsert(Key j, const Vector &value)
insert that mimics the STL map insert - if the value already exists, the map is not modified and an i...
Definition: VectorValues.h:205
const Vector & at(Key j) const
Access the vector value with key j (const version), throws std::out_of_range if j does not exist...
Definition: VectorValues.h:161
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: VectorValues.h:101
A key-value pair, which you get by dereferencing iterators.
Definition: Values.h:101
void erase(Key var)
Erase the vector with the given key, or throw std::out_of_range if it does not exist.
Definition: VectorValues.h:209
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition: Point2.h:170
value_type KeyValuePair
Typedef to pair<Key, Vector>, a key-value pair.
Definition: VectorValues.h:103
iterator begin()
Iterator over variables.
Definition: VectorValues.h:217
Scatter is an intermediate data structure used when building a HessianFactor incrementally, to get the keys in the right order.
Definition: Scatter.h:51
Maps global variable indices to slot indices.
VectorValues()
Default constructor creates an empty VectorValues.
Definition: VectorValues.h:112
double dot(const V1 &a, const V2 &b)
Dot product.
Definition: Vector.h:162
const_iterator begin() const
Iterator over variables.
Definition: VectorValues.h:218
A thin wrapper around std::vector that uses boost's pool_allocator.
iterator insert(Key j, const Vector &value)
Insert a vector value with key j.
Definition: VectorValues.h:187
boost::transform_iterator< boost::function1< KeyValuePair, const KeyValuePtrPair & >, KeyValueMap::iterator > iterator
Mutable forward iterator, with value type KeyValuePair.
Definition: Values.h:119
Vector & operator[](Key j)
Read/write access to the vector value with key j, throws std::out_of_range if j does not exist...
Definition: VectorValues.h:172
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
iterator end()
Iterator over variables.
Definition: VectorValues.h:219