9 #ifndef CBINARYRELATION_H_    10 #define CBINARYRELATION_H_    20 namespace mrpt  {       
namespace math  {
    54                 template<
typename FunctionType> 
inline void applyFunction(FunctionType fun,
size_t e1,
size_t e2,
const T &T1,
const T &T2) {
    55                         detail::applyFunction<T,U,UIsObject,FunctionType>(*
this,fun,e1,e2,T1,T2);
    74                         for (
size_t i=0;i<
elements.size();++i,++it)     {
    84                         for (
size_t i=0;i<
elements.size();++i,++it)     {
    88                                 for (
size_t j=i+1;j<
elements.size();++j,++jt)   {
   124                         if (it1==e||it2==e) 
return false;
   134                         if (it1==e||it2==e) 
throw std::domain_error(
"Element not found");
   144                         if (it1==e||it2==e) 
throw std::domain_error(
"Element not found");
   210                         if (it==e) 
throw std::domain_error(
"Element not found");
   220                         if (it==e) 
throw std::domain_error(
"Element not found");
   228                         std::copy(access.
begin(),access.
end(),vec.begin());
   233                         if (it==e) 
throw std::domain_error(
"Element not found");
   242                         if (it==e) 
throw std::domain_error(
"Element not found");
   252                         if (it==e) 
throw std::domain_error(
"Element not found");
   260                         std::copy(access.
begin(),access.
end(),vec.begin());
   265                         if (it==e) 
throw std::domain_error(
"Element not found");
   286                         if (it==e) 
return false;
   294                         std::set<size_t> positions;
   300                         return positions.size();
   303                         relation.removeRowsAndCols(poss,poss);
   304                         for (std::set<size_t>::const_reverse_iterator it=poss.rbegin();it!=poss.rend();++it)    {
   306                                 std::advance(it2,*it);
   318                                 std::multiset<size_t> newEls;
   320                                 relation.insertRowsAndCols(newEls,newEls);
   321                                 return std::make_pair(
true,dist);
   322                         }       
else return std::make_pair(
false,dist);
   327                 template<
typename FunctionType> std::pair<bool,size_t> 
insertElement(
const T &el,FunctionType fun)      {
   329                         size_t pos=ins.second;
   330                         for (
size_t i=0;i<
elements.size();++i)  {
   341                         if (els.empty()) 
return 0;
   345                         std::vector<size_t> added;
   347                         added.reserve(els.size());
   352                                         added.push_back(dist);
   357                         std::sort(added.begin(),added.end());
   358                         for (
size_t j=1;j<added.size();++j) added[j]-=j;
   359                         std::multiset<size_t> poss(added.begin(),added.end());
   360                         relation.insertRowsAndCols(poss,poss);
   366                 template<
typename FunctionType> 
size_t insertElements(
const std::set<T> &els,FunctionType fun)  {
   367                         if (els.empty()) 
return 0;
   369                         std::set<size_t> poss;
   375                         std::set<size_t> nPoss;
   378                         vector<const T *> proxy;
   379                         proxy.reserve(poss.size());
   382                                 proxy.push_back(&e1);
   399                         relation.setSize(newEls.size(),newEls.size());
   411                 template<
typename T,
typename U,
bool UIsObject,
typename FunctionType> 
inline void applyFunction(
CBinaryRelation<T,U,UIsObject> &o, FunctionType fun,
size_t e1,
size_t e2,
const T &T1,
const T &T2) {
   417                 template<
typename T,
typename U,
bool UIsObject> 
inline void applyFunction(
CBinaryRelation<T,U,UIsObject> &o,
typename CBinaryRelation<T,U,UIsObject>::FunctionByReferencePass fun,
size_t e1,
size_t e2,
const T &T1,
const T &T2)    {
 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...
 
CConstMatrixColumnAccessor< U > ConstAccessorForSecondElement
Const accessor type to every value related to any element B, i.e., f(x,B). 
 
CMatrixRowAccessor< U > AccessorForFirstElement
Accessor type to every value related to any element A, i.e., f(A,x). 
 
void removeElementsAt(const std::set< size_t > &poss)
 
std::pair< bool, size_t > insertElement(const T &el)
Inserts an element. 
 
size_t insertElements(const std::set< T > &els)
Inserts a set of elements into the relation. 
 
const_iterator end() const
 
#define ASSERT_BELOW_(__A, __B)
 
const_iterator begin() const
 
This class models a binary relation through the elements of any given set. 
 
const Scalar * const_iterator
 
const_iterator find(const KEY &key) const
 
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)
 
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...
 
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...
 
detail::MatrixWrapper< U, UIsObject >::MatrixType MatrixType
Matrix type used to store the actual relation. 
 
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. 
 
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)
 
U(* SimpleFunctionByReturnValue)(T, T)
Simple function type, used to initialize chunks of the matrix. 
 
CBinaryRelation(const std::set< T > &els, FunctionType fun)
Constructor which initializes the relation using a given function. 
 
std::set< T >::const_reverse_iterator const_reverse_iterator
Constant reverse iterator through the set elements. 
 
CConstMatrixRowAccessor< U > ConstAccessorForFirstElement
Const accessor type to every value related to any element A, i.e., f(A,x). 
 
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...
 
const_iterator begin() const
 
U(* FunctionByReturnValue)(const T &, const T &)
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't initialize the relation. 
 
const U & getRelationValue(size_t e1, size_t e2) const
Get a relation value, given the indices. 
 
void initializeSymmetricallyWith(FunctionType fun)
Initialize the whole relation with a given function, assuming that the relation is symmetrical...
 
CMatrixColumnAccessor< U > AccessorForSecondElement
Accessor type to every value related to any element B, i.e., f(x,B). 
 
void(* FunctionByReferencePass)(const T &, const T &, U &)
Function type which obtains the relation value by reference pass. 
 
size_t size() const
Returns the amount of elements present in the relation. 
 
ConstAccessorForFirstElement getRelationFrom(const T &t) const
Gets an iterable constant accessor for every value related to an element A, i.e., every f(A...
 
const_iterator end() const
 
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
 
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. 
 
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...
 
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)
 
std::set< T >::const_iterator const_iterator
Constant iterator through the set elements. 
 
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 BASE_IMPEXP distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.