MRPT  2.0.4
CBinaryRelation.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
13 
14 #include <algorithm>
15 #include <iterator>
16 #include <set>
17 #include <utility>
18 
19 namespace mrpt
20 {
21 namespace math
22 {
23 using std::vector;
24 
25 /**
26  * This class models a binary relation through the elements of any given set.
27  * I.e. for each pair of elements (A,B) it assigns two values, f(A,B) and
28  * f(B,A).
29  * This class is useful when calling the base function is costly, since it acts
30  * like a proxy. It's also useful if the relationship values do not correspond
31  * with the return value of a function. Although it theoretically supports
32  * objects with non-trivial constructors or destructors (indicated by specifying
33  * "true" as the thrid parameter of the template instantiation), certain
34  * operations will cause memory leaks and may even cause undefined behaviour, so
35  * it's
36  * reccomended to use only basic types for the parameter U. The parameter T may
37  * be any complex object, however, like a smart pointer.
38  * \ingroup mrpt_math_grp
39  */
40 template <typename T, typename U, bool UIsObject = false>
42 {
43  private:
44  // TODO: VIRTUALIZE INSERTROWSANDCOLS!!! AND REIMPLEMENT IN
45  // CMATRIXTEMPLATEOBJECTS.
46 
47  /**Matrix type used to store the actual relation. */
49 
50  public:
51  /** Simple function type, used to initialize chunks of the matrix. */
52  using SimpleFunctionByReturnValue = U (*)(T, T);
53  /**Function type which obtains the relation value by a return value. */
54  using FunctionByReturnValue = U (*)(const T&, const T&);
55  /**Function type which obtains the relation value by reference pass. */
56  using FunctionByReferencePass = void (*)(const T&, const T&, U&);
57  /**Constant iterator through the set elements. */
58  using const_iterator = typename std::set<T>::const_iterator;
59  /**Constant reverse iterator through the set elements. */
60  using const_reverse_iterator = typename std::set<T>::const_reverse_iterator;
61  /**Accessor type to every value related to any element A, i.e., f(A,x). */
63  /**Accessor type to every value related to any element B, i.e., f(x,B). */
65  /**Const accessor type to every value related to any element A, i.e.,
66  * f(A,x). */
68  /**Const accessor type to every value related to any element B, i.e.,
69  * f(x,B). */
71 
72  private:
73  /**Actual set of elements. */
74  std::set<T> elements;
75  /**Matrix storing the relation. */
77 
78  /**
79  * Template used to make the function interface independent from the
80  * function type.
81  * (wrapper for the global method - needed to make this compile under
82  * GCC).
83  */
84  template <typename FunctionType>
85  inline void applyFunction(
86  FunctionType fun, size_t e1, size_t e2, const T& T1, const T& T2)
87  {
88  detail::applyFunction<T, U, UIsObject, FunctionType>(
89  *this, fun, e1, e2, T1, T2);
90  }
91 
92  public:
93  /**
94  * Default constructor, doesn't initialize the relation.
95  */
96  explicit inline CBinaryRelation(const std::set<T>& els)
97  : elements(els), relation(els.size(), els.size())
98  {
99  }
100  /**
101  * Constructor which initializes the relation using a given function.
102  */
103  template <typename FunctionType>
104  inline CBinaryRelation(const std::set<T>& els, FunctionType fun)
105  : elements(els), relation(els.size(), els.size())
106  {
107  initializeWith(fun);
108  }
109  /**
110  * Initialize the whole relation with a given function.
111  */
112  template <typename FunctionType>
113  void initializeWith(FunctionType fun)
114  {
115  typename std::set<T>::const_iterator it = elements.begin();
116  for (size_t i = 0; i < elements.size(); ++i, ++it)
117  {
118  typename std::set<T>::const_iterator jt = elements.begin();
119  for (size_t j = 0; j < elements.size(); ++j, ++jt)
120  applyFunction(fun, i, j, *it, *jt);
121  }
122  }
123  /**
124  * Initialize the whole relation with a given function, assuming that the
125  * relation is symmetrical.
126  */
127  template <typename FunctionType>
128  void initializeSymmetricallyWith(FunctionType fun)
129  {
130  typename std::set<T>::const_iterator it = elements.begin();
131  for (size_t i = 0; i < elements.size(); ++i, ++it)
132  {
133  applyFunction(fun, i, i, *it, *it);
134  typename std::set<T>::const_iterator jt = it;
135  jt++;
136  for (size_t j = i + 1; j < elements.size(); ++j, ++jt)
137  {
138  applyFunction(fun, i, j, *it, *jt);
139  relation(j, i) = relation(i, j);
140  }
141  }
142  }
143  /**
144  * Manually set a relationship value, given the indices.
145  */
146  inline void setRelationValue(size_t e1, size_t e2, const U& newVal)
147  {
148  relation(e1, e2) = newVal;
149  }
150  /**
151  * Get a relation value, given the indices.
152  */
153  inline const U& getRelationValue(size_t e1, size_t e2) const
154  {
155  return relation(e1, e2);
156  }
157  inline const U& operator()(size_t e1, size_t e2) const
158  {
159  return getRelationValue(e1, e2);
160  }
161  /**
162  * Get a reference to a relation value given its indices, which allows both
163  * querying and setting the value.
164  */
165  inline U& getRelationValue(size_t e1, size_t e2)
166  {
167  return relation(e1, e2);
168  }
169  inline U& operator()(size_t e1, size_t e2)
170  {
171  return getRelationValue(e1, e2);
172  }
173  /**
174  * Manually set a relationship value, given the elements. Returns false if
175  * any of the elements is not present.
176  */
177  inline bool setRelationValue(const T& t1, const T& t2, const U& newVal)
178  {
179  typename std::set<T>::const_iterator b = elements.begin(),
180  e = elements.end();
181  typename std::set<T>::const_iterator it1 = std::find(b, e, t1),
182  it2 = std::find(b, e, t2);
183  if (it1 == e || it2 == e) return false;
185  static_cast<size_t>(std::distance(b, it1)),
186  static_cast<size_t>(std::distance(b, it2)), newVal);
187  return true;
188  }
189  /**
190  * Get a relation value, given the elements. Throws domain_error if any of
191  * the elements is not present.
192  */
193  inline U getRelationValue(const T& t1, const T& t2) const
194  {
195  typename std::set<T>::const_iterator b = elements.begin(),
196  e = elements.end();
197  typename std::set<T>::const_iterator it1 = std::find(b, e, t1),
198  it2 = std::find(b, e, t2);
199  if (it1 == e || it2 == e) throw std::domain_error("Element not found");
200  return getRelationValue(
201  static_cast<size_t>(std::distance(b, it1)),
202  static_cast<size_t>(std::distance(b, it2)));
203  }
204  /**
205  * Get a reference to a relation value given the elements, which allows
206  * both querying and setting. Throws domain_error if any of the elements is
207  * not
208  * present.
209  */
210  inline U& getRelationValue(const T& t1, const T& t2)
211  {
212  typename std::set<T>::const_iterator b = elements.begin(),
213  e = elements.end();
214  typename std::set<T>::const_iterator it1 = std::find(b, e, t1),
215  it2 = std::find(b, e, t2);
216  if (it1 == e || it2 == e) throw std::domain_error("Element not found");
217  return getRelationValue(
218  static_cast<size_t>(std::distance(b, it1)),
219  static_cast<size_t>(distance(b, it2)));
220  }
221  /**
222  * Gets an iterator to the starting point of the elements set.
223  */
224  inline const_iterator begin() const { return elements.begin(); }
225  /**
226  * Gets an iterator to the ending point of the elements set.
227  */
228  inline const_iterator end() const { return elements.end(); }
229  /**
230  * Gets a reverse iterator to the ending point of the elements set.
231  */
232  inline const_reverse_iterator rbegin() const { return elements.rbegin(); }
233  /**
234  * Gets a reverse iterator to the starting point of the elements set.
235  */
236  inline const_reverse_iterator rend() const { return elements.rend(); }
237  /**
238  * Operator for direct access to a element given its index.
239  */
240  T operator[](size_t i) const
241  {
242  ASSERT_BELOW_(i, elements.size();
243  typename std::set<T>::const_iterator it = elements.begin();
244  std::advance(it, i);
245  return *it;
246  }
247  /**
248  * Gets an accessor for every value related to an element A given its
249  * index, i.e., every f(A,x). This accessor is iterable.
250  */
252  {
254  }
255  /**
256  * Gets a constant accessor for every value related to an element A given
257  * its index, i.e., every f(A,x). This accessor is iterable.
258  */
260  {
262  }
263  /**
264  * Gets an accessor for every value related to an element B given its
265  * index, i.e., every f(x,B). This accessor is iterable.
266  */
268  {
270  }
271  /**
272  * Gets a constant accessor for every value related to an element B given
273  * its index, i.e., every f(x,B). This accessor is fully iterable.
274  */
276  {
278  }
279  /**
280  * Gets an iterable accessor for every value related to an element A, i.e.,
281  * every f(A,x). A domain_error will be thrown if the element is not
282  * present.
283  */
285  {
286  typename std::set<T>::const_iterator b = elements.begin(),
287  e = elements.end();
288  typename std::set<T>::const_iterator it = std::find(b, e, t);
289  if (it == e) throw std::domain_error("Element not found");
290  return getRelationFrom(static_cast<size_t>(std::distance(b, it)));
291  }
292  /**
293  * Gets an iterable constant accessor for every value related to an element
294  * A, i.e., every f(A,x). A domain_error will be thrown if the element is
295  * not
296  * present.
297  */
299  {
300  typename std::set<T>::const_iterator b = elements.begin(),
301  e = elements.end();
302  typename std::set<T>::const_iterator it = std::find(b, e, t);
303  if (it == e) throw std::domain_error("Element not found");
304  return getRelationFrom(static_cast<size_t>(std::distance(b, it)));
305  }
306  inline void getRelationFrom(size_t i, vector<U>& vec)
307  {
308  size_t N = elements.size();
309  ASSERT_(i < N);
310  vec.resize(N);
312  std::copy(access.begin(), access.end(), vec.begin());
313  }
314  inline void getRelationFrom(const T& t, vector<U>& vec)
315  {
316  typename std::set<T>::const_iterator b = elements.begin(),
317  e = elements.end();
318  typename std::set<T>::const_iterator it = std::find(b, e, t);
319  if (it == e) throw std::domain_error("Element not found");
320  getRelationFrom(static_cast<size_t>(std::distance(b, it)), vec);
321  }
322  /**
323  * Gets an iterable accessor for every value related to an element B, i.e.,
324  * every f(x,B). A domain_error will be thrown if the element is not
325  * present.
326  */
328  {
329  typename std::set<T>::const_iterator b = elements.begin(),
330  e = elements.end();
331  typename std::set<T>::const_iterator it = std::find(b, e, t);
332  if (it == e) throw std::domain_error("Element not found");
333  return getRelationTo(static_cast<size_t>(std::distance(b, it)));
334  }
335  /**
336  * Gets an iterable constant accessor for every value related to an alement
337  * B, i.e., every f(x,B). A domain_error will be thrown if the element is
338  * not
339  * present.
340  */
342  {
343  typename std::set<T>::const_iterator b = elements.begin(),
344  e = elements.end();
345  typename std::set<T>::const_iterator it = std::find(b, e, t);
346  if (it == e) throw std::domain_error("Element not found");
347  return getRelationTo(static_cast<size_t>(std::distance(b, it)));
348  }
349  inline void getRelationTo(size_t i, vector<U>& vec)
350  {
351  size_t N = elements.size();
352  ASSERT_(i < N);
353  vec.resize(N);
355  std::copy(access.begin(), access.end(), vec.begin());
356  }
357  inline void getRelationTo(const T& t, vector<U>& vec)
358  {
359  typename std::set<T>::const_iterator b = elements.begin(),
360  e = elements.end();
361  typename std::set<T>::const_iterator it = std::find(b, e, t);
362  if (it == e) throw std::domain_error("Element not found");
363  getRelationTo(static_cast<size_t>(std::distance(b, it)), vec);
364  }
365  /**
366  * Removes an element at a concrete position.
367  */
368  void removeElementAt(size_t i)
369  {
370  ASSERT_(i < elements.size());
371  typename std::set<T>::const_iterator it = elements.begin();
372  std::advance(it, i);
373  elements.erase(i);
374  std::set<size_t> ii;
375  ii.insert(i);
376  relation.removeRowsAndCols(ii, ii);
377  }
378  /**
379  * Removes an element. Returns false if the element was not present and
380  * thus could'nt be eliminated.
381  */
382  bool removeElement(const T& el)
383  {
384  typename std::set<T>::const_iterator b = elements.begin(),
385  e = elements.end();
386  typename std::set<T>::const_iterator it = std::find(e, b, el);
387  if (it == e) return false;
389  return true;
390  }
391  /**
392  * Removes a set of elements. Returns the number of elements which were
393  * actually erased.
394  */
395  size_t removeElements(const std::set<T>& vals)
396  {
397  std::set<size_t> positions;
398  for (typename std::set<T>::const_iterator it = vals.begin();
399  it != vals.end(); ++it)
400  {
401  typename std::set<T>::iterator elsIt =
402  std::find(elements.begin(), elements.end(), *it);
403  if (elsIt != elements.end())
404  positions.insert(std::distance(elements.begin(), elsIt));
405  }
406  removeElementsAt(positions);
407  return positions.size();
408  }
409  void removeElementsAt(const std::set<size_t>& poss)
410  {
411  relation.removeRowsAndCols(poss, poss);
412  for (std::set<size_t>::const_reverse_iterator it = poss.rbegin();
413  it != poss.rend(); ++it)
414  {
415  typename std::set<T>::const_iterator it2 = elements.begin();
416  std::advance(it2, *it);
417  elements.erase(it2);
418  }
419  }
420  /**
421  * Inserts an element. If the element was present, returns false and its
422  * current position. If it wasn't, returns true and the position in which it
423  * was
424  * inserted.
425  */
426  std::pair<bool, size_t> insertElement(const T& el)
427  {
428  std::pair<typename std::set<T>::iterator, bool> ins =
429  elements.insert(el);
430  size_t dist = std::distance(elements.begin(), ins.first);
431  if (ins.second)
432  {
433  std::multiset<size_t> newEls;
434  newEls.insert(dist);
435  relation.insertRowsAndCols(newEls, newEls);
436  return std::make_pair(true, dist);
437  }
438  else
439  return std::make_pair(false, dist);
440  }
441  /**
442  * Inserts an element and initializes its relationship values, even if it
443  * was already present.
444  */
445  template <typename FunctionType>
446  std::pair<bool, size_t> insertElement(const T& el, FunctionType fun)
447  {
448  std::pair<bool, size_t> ins = insertElement(el);
449  size_t pos = ins.second;
450  for (size_t i = 0; i < elements.size(); ++i)
451  {
452  const T& newEl = operator[](i);
453  applyFunction(fun, pos, i, el, newEl);
454  applyFunction(fun, i, pos, newEl, el);
455  }
456  return ins;
457  }
458  /**
459  * Inserts a set of elements into the relation. Does not initialize the
460  * actual relation.
461  */
462  size_t insertElements(const std::set<T>& els)
463  {
464  if (els.empty()) return 0;
465  // This code is much more complex than it should! Trying, for
466  // efficiency, to avoid multiple calls to insertElement makes things a
467  // lot harder.
468  // It raises the complexity level to N^2, but alleviates it greatly by
469  // making a single memory allocation. Multiple calls to insertElement
470  // will be
471  // faster only if the number of elements in the set is really large.
472  std::vector<size_t> added;
473  // std::vector<size_t> exist;
474  added.reserve(els.size());
475  for (typename std::set<T>::const_iterator it = els.begin();
476  it != els.end(); ++it)
477  {
478  std::pair<typename std::set<T>::iterator, bool> ins =
479  elements.insert(*it);
480  size_t dist = std::distance(elements.begin(), ins.first);
481  if (ins.second)
482  {
483  added.push_back(dist);
484  for (std::vector<size_t>::iterator it2 = added.begin();
485  it2 != added.end(); ++it2)
486  if (*it2 >= dist) ++(*it2);
487  // for (std::vector<size_t>::iterator
488  // it2=exist.begin();it2!=exist.end();++it2) if (*it2>=dist)
489  // ++(*it2);
490  } // else exist.push_back(dist);
491  }
492  std::sort(added.begin(), added.end());
493  for (size_t j = 1; j < added.size(); ++j) added[j] -= j;
494  std::multiset<size_t> poss(added.begin(), added.end());
495  relation.insertRowsAndCols(poss, poss);
496  return added.size();
497  }
498  /**
499  * Inserts a set of elements into the relation, initializing the actual
500  * relation with a given function.
501  */
502  template <typename FunctionType>
503  size_t insertElements(const std::set<T>& els, FunctionType fun)
504  {
505  if (els.empty()) return 0;
506  size_t howMany = insertElements(els);
507  std::set<size_t> poss;
508  {
509  // Little scope for "begin" and "end"...
510  typename std::set<T>::const_iterator begin = elements.begin(),
511  end = elements.end();
512  for (typename std::set<T>::const_iterator it = els.begin();
513  it != els.end(); ++it)
514  poss.insert(std::distance(begin, find(begin, end, *it)));
515  }
516  std::set<size_t> nPoss;
517  std::set<size_t>::const_iterator begin = poss.begin(), end = poss.end();
518  for (size_t i = 0; i < elements.size(); ++i)
519  if (std::find(begin, end, i) == end) nPoss.insert(i);
520  vector<const T*> proxy;
521  proxy.reserve(poss.size());
522  for (std::set<size_t>::const_iterator it = begin; it != end; ++it)
523  {
524  const T& e1 = operator[](*it);
525  proxy.push_back(&e1);
526  size_t i = 0;
527  for (typename std::set<T>::const_iterator it2 = elements.begin();
528  it2 != elements.end(); ++it2, ++i)
529  applyFunction(fun, *it, i, e1, *it2);
530  }
531  for (std::set<size_t>::const_iterator it = nPoss.begin();
532  it != nPoss.end(); ++it)
533  {
534  const T& e1 = operator[](*it);
535  typename std::vector<const T*>::const_iterator itV = proxy.begin();
536  for (std::set<size_t>::const_iterator it2 = poss.begin();
537  it2 != poss.end(); ++it2, ++itV)
538  applyFunction(fun, *it, *it2, e1, **itV);
539  }
540  return howMany;
541  }
542  /**
543  * Completely resets the relation, using a new set of elements. Does not
544  * initialize the relation.
545  */
546  void setElements(const std::set<T>& newEls)
547  {
548  relation.setSize(0, 0);
549  elements = newEls;
550  relation.setSize(newEls.size(), newEls.size());
551  }
552  /**
553  * Returns the amount of elements present in the relation.
554  */
555  inline size_t size() const { return elements.size(); }
556 };
557 
558 namespace detail
559 {
560 // generic version (specialization is after definition of CBinaryRelation):
561 template <typename T, typename U, bool UIsObject, typename FunctionType>
562 inline void applyFunction(
563  CBinaryRelation<T, U, UIsObject>& o, FunctionType fun, size_t e1, size_t e2,
564  const T& T1, const T& T2)
565 {
566  o.getRelationValue(e1, e2) = fun(T1, T2);
567 }
568 
569 /** Template specialization by reference type.
570  */
571 template <typename T, typename U, bool UIsObject>
572 inline void applyFunction(
575  size_t e1, size_t e2, const T& T1, const T& T2)
576 {
577  fun(T1, T2, o.getRelationValue(e1, e2));
578 }
579 } // namespace detail
580 } // namespace math
581 } // namespace mrpt
CMatrixRowAccessor< U > AccessorForFirstElement
Accessor type to every value related to any element A, i.e., f(A,x).
A vector-like wrapper for a const Matrix for accessing the elements of a given column with a [] opera...
void applyFunction(CBinaryRelation< T, U, UIsObject > &o, FunctionType fun, size_t e1, size_t e2, const T &T1, const T &T2)
U & getRelationValue(size_t e1, size_t e2)
Get a reference to a relation value given its indices, which allows both querying and setting the val...
const_iterator end() const
Gets an iterator to the ending point of the elements set.
This template is a trick to switch the type of a variable using a boolean variable in the template...
void setRelationValue(size_t e1, size_t e2, const U &newVal)
Manually set a relationship value, given the indices.
ConstAccessorForFirstElement getRelationFrom(size_t i) const
Gets a constant accessor for every value related to an element A given its index, i...
const_iterator find(const KEY &key) const
Definition: ts_hash_map.h:224
#define ASSERT_BELOW_(__A, __B)
Definition: exceptions.h:149
void removeElementsAt(const std::set< size_t > &poss)
std::pair< bool, size_t > insertElement(const T &el, FunctionType fun)
Inserts an element and initializes its relationship values, even if it was already present...
typename std::set< T >::const_reverse_iterator const_reverse_iterator
Constant reverse iterator through the set elements.
void(*)(const T &, const T &, U &) FunctionByReferencePass
Function type which obtains the relation value by reference pass.
size_t insertElements(const std::set< T > &els)
Inserts a set of elements into the relation.
This class models a binary relation through the elements of any given set.
std::pair< bool, size_t > insertElement(const T &el)
Inserts an element.
AccessorForFirstElement getRelationFrom(size_t i)
Gets an accessor for every value related to an element A given its index, i.e., every f(A...
void applyFunction(FunctionType fun, size_t e1, size_t e2, const T &T1, const T &T2)
Template used to make the function interface independent from the function type.
const_iterator begin() const
Gets an iterator to the starting point of the elements set.
void getRelationTo(size_t i, vector< U > &vec)
void getRelationFrom(size_t i, vector< U > &vec)
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
size_t removeElements(const std::set< T > &vals)
Removes a set of elements.
A vector-like wrapper for a const Matrix for accessing the elements of a given row with a [] operator...
size_t insertElements(const std::set< T > &els, FunctionType fun)
Inserts a set of elements into the relation, initializing the actual relation with a given function...
std::set< T > elements
Actual set of elements.
ConstAccessorForSecondElement getRelationTo(size_t i) const
Gets a constant accessor for every value related to an element B given its index, i...
CConstMatrixColumnAccessor< U > ConstAccessorForSecondElement
Const accessor type to every value related to any element B, i.e., f(x,B).
U & getRelationValue(const T &t1, const T &t2)
Get a reference to a relation value given the elements, which allows both querying and setting...
MatrixType relation
Matrix storing the relation.
ConstAccessorForSecondElement getRelationTo(const T &t) const
Gets an iterable constant accessor for every value related to an alement B, i.e., every f(x...
void initializeWith(FunctionType fun)
Initialize the whole relation with a given function.
const_reverse_iterator rend() const
Gets a reverse iterator to the starting point of the elements set.
U(*)(T, T) SimpleFunctionByReturnValue
Simple function type, used to initialize chunks of the matrix.
A vector-like wrapper for a Matrix for accessing the elements of a given row with a [] operator...
void setElements(const std::set< T > &newEls)
Completely resets the relation, using a new set of elements.
void getRelationFrom(const T &t, vector< U > &vec)
void getRelationTo(const T &t, vector< U > &vec)
CBinaryRelation(const std::set< T > &els, FunctionType fun)
Constructor which initializes the relation using a given function.
void removeElementAt(size_t i)
Removes an element at a concrete position.
bool removeElement(const T &el)
Removes an element.
AccessorForSecondElement getRelationTo(size_t i)
Gets an accessor for every value related to an element B given its index, i.e., every f(x...
U(*)(const T &, const T &) FunctionByReturnValue
Function type which obtains the relation value by a return value.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
CBinaryRelation(const std::set< T > &els)
Default constructor, doesn&#39;t initialize the relation.
const U & getRelationValue(size_t e1, size_t e2) const
Get a relation value, given the indices.
typename std::set< T >::const_iterator const_iterator
Constant iterator through the set elements.
void initializeSymmetricallyWith(FunctionType fun)
Initialize the whole relation with a given function, assuming that the relation is symmetrical...
size_t size() const
Returns the amount of elements present in the relation.
CMatrixColumnAccessor< U > AccessorForSecondElement
Accessor type to every value related to any element B, i.e., f(x,B).
ConstAccessorForFirstElement getRelationFrom(const T &t) const
Gets an iterable constant accessor for every value related to an element A, i.e., every f(A...
typename detail::MatrixWrapper< U, UIsObject >::MatrixType MatrixType
Matrix type used to store the actual relation.
bool setRelationValue(const T &t1, const T &t2, const U &newVal)
Manually set a relationship value, given the elements.
AccessorForSecondElement getRelationTo(const T &t)
Gets an iterable accessor for every value related to an element B, i.e., every f(x,B).
T operator[](size_t i) const
Operator for direct access to a element given its index.
A vector-like wrapper for a Matrix for accessing the elements of a given column with a [] operator...
U & operator()(size_t e1, size_t e2)
const U & operator()(size_t e1, size_t e2) const
const_reverse_iterator rbegin() const
Gets a reverse iterator to the ending point of the elements set.
AccessorForFirstElement getRelationFrom(const T &t)
Gets an iterable accessor for every value related to an element A, i.e., every f(A,x).
U getRelationValue(const T &t1, const T &t2) const
Get a relation value, given the elements.
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
Definition: geometry.cpp:1807
CConstMatrixRowAccessor< U > ConstAccessorForFirstElement
Const accessor type to every value related to any element A, i.e., f(A,x).



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020