Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 4bc66056a634db26a1f4d0845dc41ca6 > files > 198

mrpt-doc-0.9.5-0.1.20110925svn2670.fc16.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>CBinaryRelation.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<div align="left"><a href="http://www.mrpt.org/">Main MRPT website</a> &gt; <b>C++ reference</b> </div>
<div align="right">
<a href="index.html"><img border="0" src="mrpt_logo.png" alt="MRPT logo"></a>
</div>
<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
          <div class="left">
            <form id="FSearchBox" action="search.php" method="get">
              <img id="MSearchSelect" src="search/mag.png" alt=""/>
              <input type="text" id="MSearchField" name="query" value="Search" size="20" accesskey="S" 
                     onfocus="searchBox.OnSearchFieldFocus(true)" 
                     onblur="searchBox.OnSearchFieldFocus(false)"/>
            </form>
          </div><div class="right"></div>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">CBinaryRelation.h</div>  </div>
</div>
<div class="contents">
<a href="_c_binary_relation_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* +---------------------------------------------------------------------------+</span>
<a name="l00002"></a>00002 <span class="comment">   |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |</span>
<a name="l00003"></a>00003 <span class="comment">   |                                                                           |</span>
<a name="l00004"></a>00004 <span class="comment">   |                       http://www.mrpt.org/                                |</span>
<a name="l00005"></a>00005 <span class="comment">   |                                                                           |</span>
<a name="l00006"></a>00006 <span class="comment">   |   Copyright (C) 2005-2011  University of Malaga                           |</span>
<a name="l00007"></a>00007 <span class="comment">   |                                                                           |</span>
<a name="l00008"></a>00008 <span class="comment">   |    This software was written by the Machine Perception and Intelligent    |</span>
<a name="l00009"></a>00009 <span class="comment">   |      Robotics Lab, University of Malaga (Spain).                          |</span>
<a name="l00010"></a>00010 <span class="comment">   |    Contact: Jose-Luis Blanco  &lt;jlblanco@ctima.uma.es&gt;                     |</span>
<a name="l00011"></a>00011 <span class="comment">   |                                                                           |</span>
<a name="l00012"></a>00012 <span class="comment">   |  This file is part of the MRPT project.                                   |</span>
<a name="l00013"></a>00013 <span class="comment">   |                                                                           |</span>
<a name="l00014"></a>00014 <span class="comment">   |     MRPT is free software: you can redistribute it and/or modify          |</span>
<a name="l00015"></a>00015 <span class="comment">   |     it under the terms of the GNU General Public License as published by  |</span>
<a name="l00016"></a>00016 <span class="comment">   |     the Free Software Foundation, either version 3 of the License, or     |</span>
<a name="l00017"></a>00017 <span class="comment">   |     (at your option) any later version.                                   |</span>
<a name="l00018"></a>00018 <span class="comment">   |                                                                           |</span>
<a name="l00019"></a>00019 <span class="comment">   |   MRPT is distributed in the hope that it will be useful,                 |</span>
<a name="l00020"></a>00020 <span class="comment">   |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |</span>
<a name="l00021"></a>00021 <span class="comment">   |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |</span>
<a name="l00022"></a>00022 <span class="comment">   |     GNU General Public License for more details.                          |</span>
<a name="l00023"></a>00023 <span class="comment">   |                                                                           |</span>
<a name="l00024"></a>00024 <span class="comment">   |     You should have received a copy of the GNU General Public License     |</span>
<a name="l00025"></a>00025 <span class="comment">   |     along with MRPT.  If not, see &lt;http://www.gnu.org/licenses/&gt;.         |</span>
<a name="l00026"></a>00026 <span class="comment">   |                                                                           |</span>
<a name="l00027"></a>00027 <span class="comment">   +---------------------------------------------------------------------------+ */</span>
<a name="l00028"></a>00028 <span class="preprocessor">#ifndef CBINARYRELATION_H_</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#define CBINARYRELATION_H_</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;<a class="code" href="_c_matrix_template_8h.html">mrpt/math/CMatrixTemplate.h</a>&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="matrix__adaptors_8h.html">mrpt/math/matrix_adaptors.h</a>&gt;</span>
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;set&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;iterator&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;algorithm&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;utility&gt;</span>
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 <span class="keyword">namespace </span>mrpt  {       <span class="keyword">namespace </span>math  {
<a name="l00040"></a>00040         <span class="keyword">using</span> std::vector;
<a name="l00041"></a>00041 <span class="comment"></span>
<a name="l00042"></a>00042 <span class="comment">        /**</span>
<a name="l00043"></a>00043 <span class="comment">          * This class models a binary relation through the elements of any given set. I.e. for each pair of elements (A,B) it assigns two values, f(A,B) and f(B,A).</span>
<a name="l00044"></a>00044 <span class="comment">          * This class is useful when calling the base function is costly, since it acts like a proxy. It&#39;s also useful if the relationship values do not correspond</span>
<a name="l00045"></a>00045 <span class="comment">          * with the return value of a function. Although it theoretically supports objects with non-trivial constructors or destructors (indicated by specifying</span>
<a name="l00046"></a>00046 <span class="comment">          * &quot;true&quot; as the thrid parameter of the template instantiation), certain operations will cause memory leaks and may even cause undefined behaviour, so it&#39;s</span>
<a name="l00047"></a>00047 <span class="comment">          * reccomended to use only basic types for the parameter U. The parameter T may be any complex object, however, like a smart pointer.</span>
<a name="l00048"></a>00048 <span class="comment">         * \ingroup mrpt_base_grp</span>
<a name="l00049"></a>00049 <span class="comment">          */</span>
<a name="l00050"></a>00050         <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U,<span class="keywordtype">bool</span> UIsObject=false&gt; <span class="keyword">class </span>CBinaryRelation      {
<a name="l00051"></a>00051         <span class="keyword">private</span>:
<a name="l00052"></a>00052                 <span class="comment">//TODO: VIRTUALIZE INSERTROWSANDCOLS!!! AND REIMPLEMENT IN CMATRIXTEMPLATEOBJECTS.</span>
<a name="l00053"></a>00053 
<a name="l00054"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a5ac3d3c70bd310b64719cdc9a143d3c8">00054</a>                 <span class="keyword">typedef</span> <span class="keyword">typename</span> detail::MatrixWrapper&lt;U,UIsObject&gt;::MatrixType <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a5ac3d3c70bd310b64719cdc9a143d3c8" title="Matrix type used to store the actual relation.">MatrixType</a>;     <span class="comment">//!&lt;Matrix type used to store the actual relation.</span>
<a name="l00055"></a>00055 <span class="comment"></span>        <span class="keyword">public</span>:
<a name="l00056"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ad14772199b4cb0fb5bbf09dd4499202b">00056</a>                 <span class="keyword">typedef</span> U (*<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ad14772199b4cb0fb5bbf09dd4499202b" title="Simple function type, used to initialize chunks of the matrix.">SimpleFunctionByReturnValue</a>)(T,T);  <span class="comment">//!&lt; Simple function type, used to initialize chunks of the matrix.</span>
<a name="l00057"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a31de6d5b6b21081ce58d3e72c8f0b8a6">00057</a> <span class="comment"></span>                <span class="keyword">typedef</span> U (*<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a31de6d5b6b21081ce58d3e72c8f0b8a6" title="Function type which obtains the relation value by a return value.">FunctionByReturnValue</a>)(<span class="keyword">const</span> T &amp;,<span class="keyword">const</span> T &amp;);        <span class="comment">//!&lt;Function type which obtains the relation value by a return value.</span>
<a name="l00058"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#adf4d1628db6cfb52d99f3286a4cd1730">00058</a> <span class="comment"></span>                <span class="keyword">typedef</span> void (*<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#adf4d1628db6cfb52d99f3286a4cd1730" title="Function type which obtains the relation value by reference pass.">FunctionByReferencePass</a>)(<span class="keyword">const</span> T &amp;,<span class="keyword">const</span> T &amp;,U &amp;);       <span class="comment">//!&lt;Function type which obtains the relation value by reference pass.</span>
<a name="l00059"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aedf7cde6549f80f341b74720f9380224">00059</a> <span class="comment"></span>                <span class="keyword">typedef</span> <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aedf7cde6549f80f341b74720f9380224" title="Constant iterator through the set elements.">const_iterator</a>;    <span class="comment">//!&lt;Constant iterator through the set elements.</span>
<a name="l00060"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a0125cd91914dbb6b75615a55911173cc">00060</a> <span class="comment"></span>                <span class="keyword">typedef</span> <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__reverse__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_reverse_iterator</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a0125cd91914dbb6b75615a55911173cc" title="Constant reverse iterator through the set elements.">const_reverse_iterator</a>;    <span class="comment">//!&lt;Constant reverse iterator through the set elements.</span>
<a name="l00061"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a86dde525795e47681ea65b7125dacabf">00061</a> <span class="comment"></span>                <span class="keyword">typedef</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_row_accessor.html" title="A vector-like wrapper for a Matrix for accessing the elements of a given row with a [] operator...">CMatrixRowAccessor&lt;U&gt;</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a86dde525795e47681ea65b7125dacabf" title="Accessor type to every value related to any element A, i.e., f(A,x).">AccessorForFirstElement</a>;  <span class="comment">//!&lt;Accessor type to every value related to any element A, i.e., f(A,x).</span>
<a name="l00062"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ab25cc02073cbdb37335cfd1cbce874d3">00062</a> <span class="comment"></span>                <span class="keyword">typedef</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_column_accessor.html" title="A vector-like wrapper for a Matrix for accessing the elements of a given column with a [] operator...">CMatrixColumnAccessor&lt;U&gt;</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ab25cc02073cbdb37335cfd1cbce874d3" title="Accessor type to every value related to any element B, i.e., f(x,B).">AccessorForSecondElement</a>;      <span class="comment">//!&lt;Accessor type to every value related to any element B, i.e., f(x,B).</span>
<a name="l00063"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#af8a4ff916f2838a038e1d59123d01cc4">00063</a> <span class="comment"></span>                <span class="keyword">typedef</span> <a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_row_accessor.html" title="A vector-like wrapper for a const Matrix for accessing the elements of a given row with a [] operator...">CConstMatrixRowAccessor&lt;U&gt;</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#af8a4ff916f2838a038e1d59123d01cc4" title="Const accessor type to every value related to any element A, i.e., f(A,x).">ConstAccessorForFirstElement</a>;        <span class="comment">//!&lt;Const accessor type to every value related to any element A, i.e., f(A,x).</span>
<a name="l00064"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#af3c404ad83f598aec39e9f2040b4a060">00064</a> <span class="comment"></span>                <span class="keyword">typedef</span> <a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_column_accessor.html" title="A vector-like wrapper for a const Matrix for accessing the elements of a given column with a [] opera...">CConstMatrixColumnAccessor&lt;U&gt;</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#af3c404ad83f598aec39e9f2040b4a060" title="Const accessor type to every value related to any element B, i.e., f(x,B).">ConstAccessorForSecondElement</a>;    <span class="comment">//!&lt;Const accessor type to every value related to any element B, i.e., f(x,B).</span>
<a name="l00065"></a>00065 <span class="comment"></span>        <span class="keyword">private</span>:
<a name="l00066"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48">00066</a>                 std<a class="code" href="classstd_1_1set.html">::set&lt;T&gt;</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>;   <span class="comment">//!&lt;Actual set of elements.</span>
<a name="l00067"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923">00067</a> <span class="comment"></span>                <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a5ac3d3c70bd310b64719cdc9a143d3c8" title="Matrix type used to store the actual relation.">MatrixType</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>;    <span class="comment">//!&lt;Matrix storing the relation.</span>
<a name="l00068"></a>00068 <span class="comment"></span><span class="comment"></span>
<a name="l00069"></a>00069 <span class="comment">                /**</span>
<a name="l00070"></a>00070 <span class="comment">                  * Template used to make the function interface independent from the function type.</span>
<a name="l00071"></a>00071 <span class="comment">                  *  (wrapper for the global method - needed to make this compile under GCC).</span>
<a name="l00072"></a>00072 <span class="comment">                  */</span>
<a name="l00073"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1116845765d3902942f5e1647d2a9c90">00073</a>                 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> FunctionType&gt; <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1116845765d3902942f5e1647d2a9c90" title="Template used to make the function interface independent from the function type.">applyFunction</a>(FunctionType fun,<span class="keywordtype">size_t</span> e1,<span class="keywordtype">size_t</span> e2,<span class="keyword">const</span> T &amp;T1,<span class="keyword">const</span> T &amp;T2) {
<a name="l00074"></a>00074                         detail::applyFunction&lt;T,U,UIsObject,FunctionType&gt;(*<span class="keyword">this</span>,fun,e1,e2,T1,T2);
<a name="l00075"></a>00075                 }
<a name="l00076"></a>00076 
<a name="l00077"></a>00077         <span class="keyword">public</span>:<span class="comment"></span>
<a name="l00078"></a>00078 <span class="comment">                /**</span>
<a name="l00079"></a>00079 <span class="comment">                  * Default constructor, doesn&#39;t initialize the relation.</span>
<a name="l00080"></a>00080 <span class="comment">                  */</span>
<a name="l00081"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a7326b799845e563a0d7615c86a933531">00081</a>                 <span class="keyword">explicit</span> <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a7326b799845e563a0d7615c86a933531" title="Default constructor, doesn&#39;t initialize the relation.">CBinaryRelation</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1set.html">std::set&lt;T&gt;</a> &amp;els):<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>(els),<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>(els.<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a3fb9d4e7e2d72fa030cbecd9a1f6bbab" title="Returns the amount of elements present in the relation.">size</a>(),els.<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a3fb9d4e7e2d72fa030cbecd9a1f6bbab" title="Returns the amount of elements present in the relation.">size</a>())   {}<span class="comment"></span>
<a name="l00082"></a>00082 <span class="comment">                /**</span>
<a name="l00083"></a>00083 <span class="comment">                  * Constructor which initializes the relation using a given function.</span>
<a name="l00084"></a>00084 <span class="comment">                  */</span>
<a name="l00085"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ae27214165957653570c28756f2b13043">00085</a>                 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> FunctionType&gt; <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ae27214165957653570c28756f2b13043" title="Constructor which initializes the relation using a given function.">CBinaryRelation</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1set.html">std::set&lt;T&gt;</a> &amp;els,FunctionType fun):<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>(els),<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>(els.<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a3fb9d4e7e2d72fa030cbecd9a1f6bbab" title="Returns the amount of elements present in the relation.">size</a>(),els.<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a3fb9d4e7e2d72fa030cbecd9a1f6bbab" title="Returns the amount of elements present in the relation.">size</a>())   {
<a name="l00086"></a>00086                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ab4c5cbeb4b4c1b66ccf496a678e8a4e3" title="Initialize the whole relation with a given function.">initializeWith</a>(fun);
<a name="l00087"></a>00087                 }<span class="comment"></span>
<a name="l00088"></a>00088 <span class="comment">                /**</span>
<a name="l00089"></a>00089 <span class="comment">                  * Initialize the whole relation with a given function.</span>
<a name="l00090"></a>00090 <span class="comment">                  */</span>
<a name="l00091"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ab4c5cbeb4b4c1b66ccf496a678e8a4e3">00091</a>                 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> FunctionType&gt; <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ab4c5cbeb4b4c1b66ccf496a678e8a4e3" title="Initialize the whole relation with a given function.">initializeWith</a>(FunctionType fun)   {
<a name="l00092"></a>00092                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin();
<a name="l00093"></a>00093                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i&lt;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size();++i,++it)     {
<a name="l00094"></a>00094                                 <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> jt=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin();
<a name="l00095"></a>00095                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0;j&lt;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size();++j,++jt) <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1116845765d3902942f5e1647d2a9c90" title="Template used to make the function interface independent from the function type.">applyFunction</a>(fun,i,j,*it,*jt);
<a name="l00096"></a>00096                         }
<a name="l00097"></a>00097                 }<span class="comment"></span>
<a name="l00098"></a>00098 <span class="comment">                /**</span>
<a name="l00099"></a>00099 <span class="comment">                  * Initialize the whole relation with a given function, assuming that the relation is symmetrical.</span>
<a name="l00100"></a>00100 <span class="comment">                  */</span>
<a name="l00101"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a525ba2c060ca8b0b632f6beaf45a1bfe">00101</a>                 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> FunctionType&gt; <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a525ba2c060ca8b0b632f6beaf45a1bfe" title="Initialize the whole relation with a given function, assuming that the relation is symmetrical...">initializeSymmetricallyWith</a>(FunctionType fun)      {
<a name="l00102"></a>00102                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin();
<a name="l00103"></a>00103                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i&lt;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size();++i,++it)     {
<a name="l00104"></a>00104                                 <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1116845765d3902942f5e1647d2a9c90" title="Template used to make the function interface independent from the function type.">applyFunction</a>(fun,i,i,*it,*it);
<a name="l00105"></a>00105                                 <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> jt=it;
<a name="l00106"></a>00106                                 jt++;
<a name="l00107"></a>00107                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=i+1;j&lt;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size();++j,++jt)   {
<a name="l00108"></a>00108                                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1116845765d3902942f5e1647d2a9c90" title="Template used to make the function interface independent from the function type.">applyFunction</a>(fun,i,j,*it,*jt);
<a name="l00109"></a>00109                                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>(j,i)=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>(i,j);
<a name="l00110"></a>00110                                 }
<a name="l00111"></a>00111                         }
<a name="l00112"></a>00112                 }<span class="comment"></span>
<a name="l00113"></a>00113 <span class="comment">                /**</span>
<a name="l00114"></a>00114 <span class="comment">                  * Manually set a relationship value, given the indices.</span>
<a name="l00115"></a>00115 <span class="comment">                  */</span>
<a name="l00116"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a4d2ea8625c09101701dd3d2ccbcb149b">00116</a>                 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a4d2ea8625c09101701dd3d2ccbcb149b" title="Manually set a relationship value, given the indices.">setRelationValue</a>(<span class="keywordtype">size_t</span> e1,<span class="keywordtype">size_t</span> e2,<span class="keyword">const</span> U &amp;newVal)       {
<a name="l00117"></a>00117                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>.get_unsafe(e1,e2)=newVal;
<a name="l00118"></a>00118                 }<span class="comment"></span>
<a name="l00119"></a>00119 <span class="comment">                /**</span>
<a name="l00120"></a>00120 <span class="comment">                  * Get a relation value, given the indices.</span>
<a name="l00121"></a>00121 <span class="comment">                  */</span>
<a name="l00122"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a7b21d9f0ebf4ce84b038c9152514ae43">00122</a>                 <span class="keyword">inline</span> <span class="keyword">const</span> U &amp;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a7b21d9f0ebf4ce84b038c9152514ae43" title="Get a relation value, given the indices.">getRelationValue</a>(<span class="keywordtype">size_t</span> e1,<span class="keywordtype">size_t</span> e2)<span class="keyword"> const     </span>{
<a name="l00123"></a>00123                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>.get_unsafe(e1,e2);
<a name="l00124"></a>00124                 }
<a name="l00125"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a9030aa25ba44a1fdd2a5a43e9de951ee">00125</a>                 <span class="keyword">inline</span> <span class="keyword">const</span> U &amp;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a9030aa25ba44a1fdd2a5a43e9de951ee">operator()</a>(<span class="keywordtype">size_t</span> e1,<span class="keywordtype">size_t</span> e2)<span class="keyword"> const   </span>{
<a name="l00126"></a>00126                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a7b21d9f0ebf4ce84b038c9152514ae43" title="Get a relation value, given the indices.">getRelationValue</a>(e1,e2);
<a name="l00127"></a>00127                 }<span class="comment"></span>
<a name="l00128"></a>00128 <span class="comment">                /**</span>
<a name="l00129"></a>00129 <span class="comment">                  * Get a reference to a relation value given its indices, which allows both querying and setting the value.</span>
<a name="l00130"></a>00130 <span class="comment">                  */</span>
<a name="l00131"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a24d48da89fbd795e41e4d5586ed0ffcd">00131</a>                 <span class="keyword">inline</span> U &amp;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a24d48da89fbd795e41e4d5586ed0ffcd" title="Get a reference to a relation value given its indices, which allows both querying and setting the val...">getRelationValue</a>(<span class="keywordtype">size_t</span> e1,<span class="keywordtype">size_t</span> e2) {
<a name="l00132"></a>00132                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>.get_unsafe(e1,e2);
<a name="l00133"></a>00133                 }
<a name="l00134"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a6741751070b9fed516bc43adf9f856c7">00134</a>                 <span class="keyword">inline</span> U &amp;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a6741751070b9fed516bc43adf9f856c7">operator()</a>(<span class="keywordtype">size_t</span> e1,<span class="keywordtype">size_t</span> e2)       {
<a name="l00135"></a>00135                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a7b21d9f0ebf4ce84b038c9152514ae43" title="Get a relation value, given the indices.">getRelationValue</a>(e1,e2);
<a name="l00136"></a>00136                 }<span class="comment"></span>
<a name="l00137"></a>00137 <span class="comment">                /**</span>
<a name="l00138"></a>00138 <span class="comment">                  * Manually set a relationship value, given the elements. Returns false if any of the elements is not present.</span>
<a name="l00139"></a>00139 <span class="comment">                  */</span>
<a name="l00140"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a941f8afd63945a3d61cf74c3a5840437">00140</a>                 <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a941f8afd63945a3d61cf74c3a5840437" title="Manually set a relationship value, given the elements.">setRelationValue</a>(<span class="keyword">const</span> T &amp;t1,<span class="keyword">const</span> T &amp;t2,<span class="keyword">const</span> U &amp;newVal)   {
<a name="l00141"></a>00141                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> b=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),e=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00142"></a>00142                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it1=std::find(b,e,t1),it2=std::find(b,e,t2);
<a name="l00143"></a>00143                         <span class="keywordflow">if</span> (it1==e||it2==e) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00144"></a>00144                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a4d2ea8625c09101701dd3d2ccbcb149b" title="Manually set a relationship value, given the indices.">setRelationValue</a>(static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it1)),static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it2)),newVal);
<a name="l00145"></a>00145                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00146"></a>00146                 }<span class="comment"></span>
<a name="l00147"></a>00147 <span class="comment">                /**</span>
<a name="l00148"></a>00148 <span class="comment">                  * Get a relation value, given the elements. Throws domain_error if any of the elements is not present.</span>
<a name="l00149"></a>00149 <span class="comment">                  */</span>
<a name="l00150"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a30dcc07d5cca61efc3a46328954c31c2">00150</a>                 <span class="keyword">inline</span> U <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a30dcc07d5cca61efc3a46328954c31c2" title="Get a relation value, given the elements.">getRelationValue</a>(<span class="keyword">const</span> T &amp;t1,<span class="keyword">const</span> T &amp;t2)<span class="keyword"> const        </span>{
<a name="l00151"></a>00151                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> b=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),e=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00152"></a>00152                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it1=std::find(b,e,t1),it2=std::find(b,e,t2);
<a name="l00153"></a>00153                         <span class="keywordflow">if</span> (it1==e||it2==e) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1domain__error.html" title="STL class.">std::domain_error</a>(<span class="stringliteral">&quot;Element not found&quot;</span>);
<a name="l00154"></a>00154                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a7b21d9f0ebf4ce84b038c9152514ae43" title="Get a relation value, given the indices.">getRelationValue</a>(static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it1)),static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it2)));
<a name="l00155"></a>00155                 }<span class="comment"></span>
<a name="l00156"></a>00156 <span class="comment">                /**</span>
<a name="l00157"></a>00157 <span class="comment">                  * Get a reference to a relation value given the elements, which allows both querying and setting. Throws domain_error if any of the elements is not</span>
<a name="l00158"></a>00158 <span class="comment">                  * present.</span>
<a name="l00159"></a>00159 <span class="comment">                  */</span>
<a name="l00160"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a48dc3add0a66d109e0056e19bb865c82">00160</a>                 <span class="keyword">inline</span> U &amp;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a48dc3add0a66d109e0056e19bb865c82" title="Get a reference to a relation value given the elements, which allows both querying and setting...">getRelationValue</a>(<span class="keyword">const</span> T &amp;t1,<span class="keyword">const</span> T &amp;t2)     {
<a name="l00161"></a>00161                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> b=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),e=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00162"></a>00162                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it1=std::find(b,e,t1),it2=std::find(b,e,t2);
<a name="l00163"></a>00163                         <span class="keywordflow">if</span> (it1==e||it2==e) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1domain__error.html" title="STL class.">std::domain_error</a>(<span class="stringliteral">&quot;Element not found&quot;</span>);
<a name="l00164"></a>00164                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a7b21d9f0ebf4ce84b038c9152514ae43" title="Get a relation value, given the indices.">getRelationValue</a>(static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it1)),static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">distance</a>(b,it2)));
<a name="l00165"></a>00165                 }<span class="comment"></span>
<a name="l00166"></a>00166 <span class="comment">                /**</span>
<a name="l00167"></a>00167 <span class="comment">                  * Gets an iterator to the starting point of the elements set.</span>
<a name="l00168"></a>00168 <span class="comment">                  */</span>
<a name="l00169"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a973728ff0c39e8c11cc13b6ac4c4fba5">00169</a>                 <span class="keyword">inline</span> <a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">const_iterator</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a973728ff0c39e8c11cc13b6ac4c4fba5" title="Gets an iterator to the starting point of the elements set.">begin</a>()<span class="keyword"> const     </span>{
<a name="l00170"></a>00170                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin();
<a name="l00171"></a>00171                 }<span class="comment"></span>
<a name="l00172"></a>00172 <span class="comment">                /**</span>
<a name="l00173"></a>00173 <span class="comment">                  * Gets an iterator to the ending point of the elements set.</span>
<a name="l00174"></a>00174 <span class="comment">                  */</span>
<a name="l00175"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#adb2913616f432880261e7c5f6b107ca1">00175</a>                 <span class="keyword">inline</span> <a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">const_iterator</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#adb2913616f432880261e7c5f6b107ca1" title="Gets an iterator to the ending point of the elements set.">end</a>()<span class="keyword"> const       </span>{
<a name="l00176"></a>00176                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00177"></a>00177                 }<span class="comment"></span>
<a name="l00178"></a>00178 <span class="comment">                /**</span>
<a name="l00179"></a>00179 <span class="comment">                  * Gets a reverse iterator to the ending point of the elements set.</span>
<a name="l00180"></a>00180 <span class="comment">                  */</span>
<a name="l00181"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ac6c7171bf934dbd57060a86f23ad9de6">00181</a>                 <span class="keyword">inline</span> <a class="code" href="classstd_1_1set_1_1const__reverse__iterator.html" title="STL iterator class.">const_reverse_iterator</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ac6c7171bf934dbd57060a86f23ad9de6" title="Gets a reverse iterator to the ending point of the elements set.">rbegin</a>()<span class="keyword"> const    </span>{
<a name="l00182"></a>00182                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.rbegin();
<a name="l00183"></a>00183                 }<span class="comment"></span>
<a name="l00184"></a>00184 <span class="comment">                /**</span>
<a name="l00185"></a>00185 <span class="comment">                  * Gets a reverse iterator to the starting point of the elements set.</span>
<a name="l00186"></a>00186 <span class="comment">                  */</span>
<a name="l00187"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#af5ac35a9b38ec6e0056d216e522bda94">00187</a>                 <span class="keyword">inline</span> <a class="code" href="classstd_1_1set_1_1const__reverse__iterator.html" title="STL iterator class.">const_reverse_iterator</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#af5ac35a9b38ec6e0056d216e522bda94" title="Gets a reverse iterator to the starting point of the elements set.">rend</a>()<span class="keyword"> const      </span>{
<a name="l00188"></a>00188                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.rend();
<a name="l00189"></a>00189                 }<span class="comment"></span>
<a name="l00190"></a>00190 <span class="comment">                /**</span>
<a name="l00191"></a>00191 <span class="comment">                  * Operator for direct access to a element given its index.</span>
<a name="l00192"></a>00192 <span class="comment">                  */</span>
<a name="l00193"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a439e2055644b08ec329ce9a8d253f24e">00193</a>                 T <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a439e2055644b08ec329ce9a8d253f24e" title="Operator for direct access to a element given its index.">operator[]</a>(<span class="keywordtype">size_t</span> i)<span class="keyword"> const    </span>{
<a name="l00194"></a>00194                         <a class="code" href="mrpt__macros_8h.html#a8b01938f6fbebe5c4163b7c83a137d1d">ASSERT_BELOW_</a>(i,<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size())
<a name="l00195"></a>00195                         <span class="keyword">typename</span> <a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">std::set&lt;T&gt;::const_iterator</a> it=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin();
<a name="l00196"></a>00196                         std::advance(it,i);
<a name="l00197"></a>00197                         <span class="keywordflow">return</span> *it;
<a name="l00198"></a>00198                 }<span class="comment"></span>
<a name="l00199"></a>00199 <span class="comment">                /**</span>
<a name="l00200"></a>00200 <span class="comment">                  * Gets an accessor for every value related to an element A given its index, i.e., every f(A,x). This accessor is iterable.</span>
<a name="l00201"></a>00201 <span class="comment">                  */</span>
<a name="l00202"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aebfa6985217ab10a4fdf915236de8307">00202</a>                 <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_row_accessor.html" title="A vector-like wrapper for a Matrix for accessing the elements of a given row with a [] operator...">AccessorForFirstElement</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aebfa6985217ab10a4fdf915236de8307" title="Gets an accessor for every value related to an element A given its index, i.e., every f(A...">getRelationFrom</a>(<span class="keywordtype">size_t</span> i)        {
<a name="l00203"></a>00203                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a86dde525795e47681ea65b7125dacabf" title="Accessor type to every value related to any element A, i.e., f(A,x).">AccessorForFirstElement</a>(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>,i);
<a name="l00204"></a>00204                 }<span class="comment"></span>
<a name="l00205"></a>00205 <span class="comment">                /**</span>
<a name="l00206"></a>00206 <span class="comment">                  * Gets a constant accessor for every value related to an element A given its index, i.e., every f(A,x). This accessor is iterable.</span>
<a name="l00207"></a>00207 <span class="comment">                  */</span>
<a name="l00208"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa1ac1113eb8faeb86f5829c02a56bed4">00208</a>                 <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_row_accessor.html" title="A vector-like wrapper for a const Matrix for accessing the elements of a given row with a [] operator...">ConstAccessorForFirstElement</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa1ac1113eb8faeb86f5829c02a56bed4" title="Gets a constant accessor for every value related to an element A given its index, i...">getRelationFrom</a>(<span class="keywordtype">size_t</span> i)<span class="keyword"> const     </span>{
<a name="l00209"></a>00209                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#af8a4ff916f2838a038e1d59123d01cc4" title="Const accessor type to every value related to any element A, i.e., f(A,x).">ConstAccessorForFirstElement</a>(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>,i);
<a name="l00210"></a>00210                 }<span class="comment"></span>
<a name="l00211"></a>00211 <span class="comment">                /**</span>
<a name="l00212"></a>00212 <span class="comment">                  * Gets an accessor for every value related to an element B given its index, i.e., every f(x,B). This accessor is iterable.</span>
<a name="l00213"></a>00213 <span class="comment">                  */</span>
<a name="l00214"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aab2f2b5fe10d2d9358d74469869eedce">00214</a>                 <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_column_accessor.html" title="A vector-like wrapper for a Matrix for accessing the elements of a given column with a [] operator...">AccessorForSecondElement</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aab2f2b5fe10d2d9358d74469869eedce" title="Gets an accessor for every value related to an element B given its index, i.e., every f(x...">getRelationTo</a>(<span class="keywordtype">size_t</span> i) {
<a name="l00215"></a>00215                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ab25cc02073cbdb37335cfd1cbce874d3" title="Accessor type to every value related to any element B, i.e., f(x,B).">AccessorForSecondElement</a>(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>,i);
<a name="l00216"></a>00216                 }<span class="comment"></span>
<a name="l00217"></a>00217 <span class="comment">                /**</span>
<a name="l00218"></a>00218 <span class="comment">                  * Gets a constant accessor for every value related to an element B given its index, i.e., every f(x,B). This accessor is fully iterable.</span>
<a name="l00219"></a>00219 <span class="comment">                  */</span>
<a name="l00220"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a889027227a75176a3c98f3ebea4a00f0">00220</a>                 <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_column_accessor.html" title="A vector-like wrapper for a const Matrix for accessing the elements of a given column with a [] opera...">ConstAccessorForSecondElement</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a889027227a75176a3c98f3ebea4a00f0" title="Gets a constant accessor for every value related to an element B given its index, i...">getRelationTo</a>(<span class="keywordtype">size_t</span> i)<span class="keyword"> const      </span>{
<a name="l00221"></a>00221                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#af3c404ad83f598aec39e9f2040b4a060" title="Const accessor type to every value related to any element B, i.e., f(x,B).">ConstAccessorForSecondElement</a>(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>,i);
<a name="l00222"></a>00222                 }<span class="comment"></span>
<a name="l00223"></a>00223 <span class="comment">                /**</span>
<a name="l00224"></a>00224 <span class="comment">                  * Gets an iterable accessor for every value related to an element A, i.e., every f(A,x). A domain_error will be thrown if the element is not present.</span>
<a name="l00225"></a>00225 <span class="comment">                  */</span>
<a name="l00226"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa64411e8aa57cae031e553937bcb5504">00226</a>                 <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_row_accessor.html" title="A vector-like wrapper for a Matrix for accessing the elements of a given row with a [] operator...">AccessorForFirstElement</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa64411e8aa57cae031e553937bcb5504" title="Gets an iterable accessor for every value related to an element A, i.e., every f(A,x).">getRelationFrom</a>(<span class="keyword">const</span> T &amp;<a class="code" href="eigen__plugins_8h.html#a7b88b312dc3827120dbfc60da344625d" title="Transpose.">t</a>)      {
<a name="l00227"></a>00227                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> b=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),e=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00228"></a>00228                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it=std::find(b,e,t);
<a name="l00229"></a>00229                         <span class="keywordflow">if</span> (it==e) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1domain__error.html" title="STL class.">std::domain_error</a>(<span class="stringliteral">&quot;Element not found&quot;</span>);
<a name="l00230"></a>00230                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aebfa6985217ab10a4fdf915236de8307" title="Gets an accessor for every value related to an element A given its index, i.e., every f(A...">getRelationFrom</a>(static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it)));
<a name="l00231"></a>00231                 }<span class="comment"></span>
<a name="l00232"></a>00232 <span class="comment">                /**</span>
<a name="l00233"></a>00233 <span class="comment">                  * Gets an iterable constant accessor for every value related to an element A, i.e., every f(A,x). A domain_error will be thrown if the element is not</span>
<a name="l00234"></a>00234 <span class="comment">                  * present.</span>
<a name="l00235"></a>00235 <span class="comment">                  */</span>
<a name="l00236"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a6ca2a2ef7ed4e8e2c823b4ac50f8c7d2">00236</a>                 <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_row_accessor.html" title="A vector-like wrapper for a const Matrix for accessing the elements of a given row with a [] operator...">ConstAccessorForFirstElement</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a6ca2a2ef7ed4e8e2c823b4ac50f8c7d2" title="Gets an iterable constant accessor for every value related to an element A, i.e., every f(A...">getRelationFrom</a>(<span class="keyword">const</span> T &amp;<a class="code" href="eigen__plugins_8h.html#a7b88b312dc3827120dbfc60da344625d" title="Transpose.">t</a>)<span class="keyword"> const   </span>{
<a name="l00237"></a>00237                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> b=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),e=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00238"></a>00238                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it=std::find(b,e,t);
<a name="l00239"></a>00239                         <span class="keywordflow">if</span> (it==e) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1domain__error.html" title="STL class.">std::domain_error</a>(<span class="stringliteral">&quot;Element not found&quot;</span>);
<a name="l00240"></a>00240                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aebfa6985217ab10a4fdf915236de8307" title="Gets an accessor for every value related to an element A given its index, i.e., every f(A...">getRelationFrom</a>(static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it)));
<a name="l00241"></a>00241                 }
<a name="l00242"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#af2fbaffb8fa2944e05a98cf2d3999fe1">00242</a>                 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#af2fbaffb8fa2944e05a98cf2d3999fe1">getRelationFrom</a>(<span class="keywordtype">size_t</span> i,<a class="code" href="classstd_1_1vector.html" title="STL class.">vector&lt;U&gt;</a> &amp;vec)    {
<a name="l00243"></a>00243                         <span class="keywordtype">size_t</span> N=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size();
<a name="l00244"></a>00244                         <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(i&lt;N);
<a name="l00245"></a>00245                         vec.resize(N);
<a name="l00246"></a>00246                         <a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_row_accessor.html" title="A vector-like wrapper for a const Matrix for accessing the elements of a given row with a [] operator...">ConstAccessorForFirstElement</a> access(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>,i);
<a name="l00247"></a>00247                         std::copy(access.<a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_row_accessor.html#aac54522371443aa6afde2576ce0feefc">begin</a>(),access.<a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_row_accessor.html#aae74722adb8260a8e90834bf4b402521">end</a>(),vec.begin());
<a name="l00248"></a>00248                 }
<a name="l00249"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a2436ff89d5b0cdfa06b2e68945111258">00249</a>                 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a2436ff89d5b0cdfa06b2e68945111258">getRelationFrom</a>(<span class="keyword">const</span> T &amp;<a class="code" href="eigen__plugins_8h.html#a7b88b312dc3827120dbfc60da344625d" title="Transpose.">t</a>,<a class="code" href="classstd_1_1vector.html" title="STL class.">vector&lt;U&gt;</a> &amp;vec)  {
<a name="l00250"></a>00250                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> b=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),e=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00251"></a>00251                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it=std::find(b,e,t);
<a name="l00252"></a>00252                         <span class="keywordflow">if</span> (it==e) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1domain__error.html" title="STL class.">std::domain_error</a>(<span class="stringliteral">&quot;Element not found&quot;</span>);
<a name="l00253"></a>00253                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aebfa6985217ab10a4fdf915236de8307" title="Gets an accessor for every value related to an element A given its index, i.e., every f(A...">getRelationFrom</a>(static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it)),vec);
<a name="l00254"></a>00254                 }<span class="comment"></span>
<a name="l00255"></a>00255 <span class="comment">                /**</span>
<a name="l00256"></a>00256 <span class="comment">                  * Gets an iterable accessor for every value related to an element B, i.e., every f(x,B). A domain_error will be thrown if the element is not present.</span>
<a name="l00257"></a>00257 <span class="comment">                  */</span>
<a name="l00258"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#acb9684bf8fb97f75c7f4033246be657f">00258</a>                 <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_column_accessor.html" title="A vector-like wrapper for a Matrix for accessing the elements of a given column with a [] operator...">AccessorForSecondElement</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#acb9684bf8fb97f75c7f4033246be657f" title="Gets an iterable accessor for every value related to an element B, i.e., every f(x,B).">getRelationTo</a>(<span class="keyword">const</span> T &amp;<a class="code" href="eigen__plugins_8h.html#a7b88b312dc3827120dbfc60da344625d" title="Transpose.">t</a>)       {
<a name="l00259"></a>00259                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> b=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),e=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00260"></a>00260                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it=std::find(b,e,t);
<a name="l00261"></a>00261                         <span class="keywordflow">if</span> (it==e) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1domain__error.html" title="STL class.">std::domain_error</a>(<span class="stringliteral">&quot;Element not found&quot;</span>);
<a name="l00262"></a>00262                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aab2f2b5fe10d2d9358d74469869eedce" title="Gets an accessor for every value related to an element B given its index, i.e., every f(x...">getRelationTo</a>(static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it)));
<a name="l00263"></a>00263                 }<span class="comment"></span>
<a name="l00264"></a>00264 <span class="comment">                /**</span>
<a name="l00265"></a>00265 <span class="comment">                  * Gets an iterable constant accessor for every value related to an alement B, i.e., every f(x,B). A domain_error will be thrown if the element is not</span>
<a name="l00266"></a>00266 <span class="comment">                  * present.</span>
<a name="l00267"></a>00267 <span class="comment">                  */</span>
<a name="l00268"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a52cce76d072f769327271b6cf7b274c8">00268</a>                 <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_column_accessor.html" title="A vector-like wrapper for a const Matrix for accessing the elements of a given column with a [] opera...">ConstAccessorForSecondElement</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a52cce76d072f769327271b6cf7b274c8" title="Gets an iterable constant accessor for every value related to an alement B, i.e., every f(x...">getRelationTo</a>(<span class="keyword">const</span> T &amp;<a class="code" href="eigen__plugins_8h.html#a7b88b312dc3827120dbfc60da344625d" title="Transpose.">t</a>)<span class="keyword"> const    </span>{
<a name="l00269"></a>00269                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> b=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),e=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00270"></a>00270                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it=std::find(b,e,t);
<a name="l00271"></a>00271                         <span class="keywordflow">if</span> (it==e) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1domain__error.html" title="STL class.">std::domain_error</a>(<span class="stringliteral">&quot;Element not found&quot;</span>);
<a name="l00272"></a>00272                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aab2f2b5fe10d2d9358d74469869eedce" title="Gets an accessor for every value related to an element B given its index, i.e., every f(x...">getRelationTo</a>(static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it)));
<a name="l00273"></a>00273                 }
<a name="l00274"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#afad71052b0f09715b5929028dc6a857f">00274</a>                 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#afad71052b0f09715b5929028dc6a857f">getRelationTo</a>(<span class="keywordtype">size_t</span> i,<a class="code" href="classstd_1_1vector.html" title="STL class.">vector&lt;U&gt;</a> &amp;vec)      {
<a name="l00275"></a>00275                         <span class="keywordtype">size_t</span> N=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size();
<a name="l00276"></a>00276                         <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(i&lt;N);
<a name="l00277"></a>00277                         vec.resize(N);
<a name="l00278"></a>00278                         <a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_column_accessor.html" title="A vector-like wrapper for a const Matrix for accessing the elements of a given column with a [] opera...">ConstAccessorForSecondElement</a> access(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>,i);
<a name="l00279"></a>00279                         std::copy(access.<a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_column_accessor.html#a7738d5f11f5df9e17e23840aca4dc8ba">begin</a>(),access.<a class="code" href="classmrpt_1_1math_1_1_c_const_matrix_column_accessor.html#a1bb8e2bb50e5424a3f7da282c1d0308c">end</a>(),vec.begin());
<a name="l00280"></a>00280                 }
<a name="l00281"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a78b5d3f578952c8c819a179bb5dac5a0">00281</a>                 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a78b5d3f578952c8c819a179bb5dac5a0">getRelationTo</a>(<span class="keyword">const</span> T &amp;<a class="code" href="eigen__plugins_8h.html#a7b88b312dc3827120dbfc60da344625d" title="Transpose.">t</a>,<a class="code" href="classstd_1_1vector.html" title="STL class.">vector&lt;U&gt;</a> &amp;vec)    {
<a name="l00282"></a>00282                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> b=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),e=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00283"></a>00283                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it=std::find(b,e,t);
<a name="l00284"></a>00284                         <span class="keywordflow">if</span> (it==e) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1domain__error.html" title="STL class.">std::domain_error</a>(<span class="stringliteral">&quot;Element not found&quot;</span>);
<a name="l00285"></a>00285                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aab2f2b5fe10d2d9358d74469869eedce" title="Gets an accessor for every value related to an element B given its index, i.e., every f(x...">getRelationTo</a>(static_cast&lt;size_t&gt;(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it)),vec);
<a name="l00286"></a>00286                 }<span class="comment"></span>
<a name="l00287"></a>00287 <span class="comment">                /**</span>
<a name="l00288"></a>00288 <span class="comment">                  * Removes an element at a concrete position.</span>
<a name="l00289"></a>00289 <span class="comment">                  */</span>
<a name="l00290"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a210c1c49d6b455a05387251ba90e3586">00290</a>                 <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a210c1c49d6b455a05387251ba90e3586" title="Removes an element at a concrete position.">removeElementAt</a>(<span class="keywordtype">size_t</span> i)  {
<a name="l00291"></a>00291                         <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(i&lt;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size());
<a name="l00292"></a>00292                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin();
<a name="l00293"></a>00293                         std::advance(it,i);
<a name="l00294"></a>00294                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.erase(i);
<a name="l00295"></a>00295                         <a class="code" href="classstd_1_1set.html" title="STL class.">set&lt;size_t&gt;</a> ii;
<a name="l00296"></a>00296                         ii.insert(i);
<a name="l00297"></a>00297                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>.removeRowsAndCols(ii,ii);
<a name="l00298"></a>00298                 }<span class="comment"></span>
<a name="l00299"></a>00299 <span class="comment">                /**</span>
<a name="l00300"></a>00300 <span class="comment">                  * Removes an element. Returns false if the element was not present and thus could&#39;nt be eliminated.</span>
<a name="l00301"></a>00301 <span class="comment">                  */</span>
<a name="l00302"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a0f590ddfb9925941400adbe84efbd72f">00302</a>                 <span class="keywordtype">bool</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a0f590ddfb9925941400adbe84efbd72f" title="Removes an element.">removeElement</a>(<span class="keyword">const</span> T &amp;el) {
<a name="l00303"></a>00303                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> b=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),e=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00304"></a>00304                         <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it=std::find(e,b,el);
<a name="l00305"></a>00305                         <span class="keywordflow">if</span> (it==e) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00306"></a>00306                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a210c1c49d6b455a05387251ba90e3586" title="Removes an element at a concrete position.">removeElementAt</a>(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(b,it));
<a name="l00307"></a>00307                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00308"></a>00308                 }<span class="comment"></span>
<a name="l00309"></a>00309 <span class="comment">                /**</span>
<a name="l00310"></a>00310 <span class="comment">                  * Removes a set of elements. Returns the number of elements which were actually erased.</span>
<a name="l00311"></a>00311 <span class="comment">                  */</span>
<a name="l00312"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ae4f59b47c8455dc176423afba05054ba">00312</a>                 <span class="keywordtype">size_t</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ae4f59b47c8455dc176423afba05054ba" title="Removes a set of elements.">removeElements</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1set.html">set&lt;T&gt;</a> &amp;vals)       {
<a name="l00313"></a>00313                         <a class="code" href="classstd_1_1set.html" title="STL class.">set&lt;size_t&gt;</a> positions;
<a name="l00314"></a>00314                         <span class="keywordflow">for</span> (<span class="keyword">typename</span> <a class="code" href="classstd_1_1set.html" title="STL class.">set&lt;T&gt;::const_iterator</a> it=vals.begin();it!=vals.end();++it)       {
<a name="l00315"></a>00315                                 <span class="keyword">typename</span> <a class="code" href="classstd_1_1set.html" title="STL class.">set&lt;T&gt;::iterator</a> elsIt=std::find(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end(),*it);
<a name="l00316"></a>00316                                 <span class="keywordflow">if</span> (elsIt!=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end()) positions.insert(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),elsIt));
<a name="l00317"></a>00317                         }
<a name="l00318"></a>00318 <span class="comment">/*                      for (set&lt;size_t&gt;::const_reverse_iterator it=positions.rbegin();it!=positions.rend();++it)       {</span>
<a name="l00319"></a>00319 <span class="comment">                                typename std::set&lt;T&gt;::const_iterator it2=elements.begin();</span>
<a name="l00320"></a>00320 <span class="comment">                                std::advance(it2,*it);</span>
<a name="l00321"></a>00321 <span class="comment">                                elements.erase(it2);</span>
<a name="l00322"></a>00322 <span class="comment">                        }</span>
<a name="l00323"></a>00323 <span class="comment">                        relation.removeRowsAndCols(positions,positions);*/</span>
<a name="l00324"></a>00324                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#afcdbc56f86d9a4aaf05459a401b9a143">removeElementsAt</a>(positions);
<a name="l00325"></a>00325                         <span class="keywordflow">return</span> positions.size();
<a name="l00326"></a>00326                 }
<a name="l00327"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#afcdbc56f86d9a4aaf05459a401b9a143">00327</a>                 <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#afcdbc56f86d9a4aaf05459a401b9a143">removeElementsAt</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1set.html" title="STL class.">set&lt;size_t&gt;</a> &amp;poss)  {
<a name="l00328"></a>00328                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>.removeRowsAndCols(poss,poss);
<a name="l00329"></a>00329                         <span class="keywordflow">for</span> (<a class="code" href="classstd_1_1set_1_1const__reverse__iterator.html" title="STL iterator class.">set&lt;size_t&gt;::const_reverse_iterator</a> it=poss.rbegin();it!=poss.rend();++it) {
<a name="l00330"></a>00330                                 <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> it2=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin();
<a name="l00331"></a>00331                                 std::advance(it2,*it);
<a name="l00332"></a>00332                                 <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.erase(it2);
<a name="l00333"></a>00333                         }
<a name="l00334"></a>00334                 }<span class="comment"></span>
<a name="l00335"></a>00335 <span class="comment">                /**</span>
<a name="l00336"></a>00336 <span class="comment">                  * Inserts an element. If the element was present, returns false and its current position. If it wasn&#39;t, returns true and the position in which it was</span>
<a name="l00337"></a>00337 <span class="comment">                  * inserted.</span>
<a name="l00338"></a>00338 <span class="comment">                  */</span>
<a name="l00339"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1d0ab22a46d50973e416e81353bb4c74">00339</a>                 std::pair&lt;bool,size_t&gt; <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1d0ab22a46d50973e416e81353bb4c74" title="Inserts an element.">insertElement</a>(<span class="keyword">const</span> T &amp;el)       {
<a name="l00340"></a>00340                         std<a class="code" href="eigen__plugins_8h.html#a39c5d6430ea9395ae7ae729dd0c3f18c">::pair&lt;typename std::set&lt;T&gt;::iterator</a>,<span class="keywordtype">bool</span>&gt; ins=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.insert(el);
<a name="l00341"></a>00341                         <span class="keywordtype">size_t</span> dist=<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),ins.first);
<a name="l00342"></a>00342                         <span class="keywordflow">if</span> (ins.second) {
<a name="l00343"></a>00343                                 std<a class="code" href="classstd_1_1multiset.html" title="STL class.">::multiset&lt;size_t&gt;</a> newEls;
<a name="l00344"></a>00344                                 newEls.insert(dist);
<a name="l00345"></a>00345                                 <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>.insertRowsAndCols(newEls,newEls);
<a name="l00346"></a>00346                                 <span class="keywordflow">return</span> std::make_pair(<span class="keyword">true</span>,dist);
<a name="l00347"></a>00347                         }       <span class="keywordflow">else</span> <span class="keywordflow">return</span> std::make_pair(<span class="keyword">false</span>,dist);
<a name="l00348"></a>00348                 }<span class="comment"></span>
<a name="l00349"></a>00349 <span class="comment">                /**</span>
<a name="l00350"></a>00350 <span class="comment">                  * Inserts an element and initializes its relationship values, even if it was already present.</span>
<a name="l00351"></a>00351 <span class="comment">                  */</span>
<a name="l00352"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ac46075f4f49633b71793c88d9e5b504a">00352</a>                 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> FunctionType&gt; std::pair&lt;bool,size_t&gt; <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ac46075f4f49633b71793c88d9e5b504a" title="Inserts an element and initializes its relationship values, even if it was already present...">insertElement</a>(<span class="keyword">const</span> T &amp;el,FunctionType fun)      {
<a name="l00353"></a>00353                         std::pair&lt;bool,size_t&gt; ins=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1d0ab22a46d50973e416e81353bb4c74" title="Inserts an element.">insertElement</a>(el);
<a name="l00354"></a>00354                         <span class="keywordtype">size_t</span> pos=ins.second;
<a name="l00355"></a>00355                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i&lt;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size();++i)  {
<a name="l00356"></a>00356                                 <span class="keyword">const</span> T &amp;newEl=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a439e2055644b08ec329ce9a8d253f24e" title="Operator for direct access to a element given its index.">operator[]</a>(i);
<a name="l00357"></a>00357                                 <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1116845765d3902942f5e1647d2a9c90" title="Template used to make the function interface independent from the function type.">applyFunction</a>(fun,pos,i,el,newEl);
<a name="l00358"></a>00358                                 <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1116845765d3902942f5e1647d2a9c90" title="Template used to make the function interface independent from the function type.">applyFunction</a>(fun,i,pos,newEl,el);
<a name="l00359"></a>00359                         }
<a name="l00360"></a>00360                         <span class="keywordflow">return</span> ins;
<a name="l00361"></a>00361                 }<span class="comment"></span>
<a name="l00362"></a>00362 <span class="comment">                /**</span>
<a name="l00363"></a>00363 <span class="comment">                  * Inserts a set of elements into the relation. Does not initialize the actual relation.</span>
<a name="l00364"></a>00364 <span class="comment">                  */</span>
<a name="l00365"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a3ec3583e24d1946b7483dbf088718ab6">00365</a>                 <span class="keywordtype">size_t</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a3ec3583e24d1946b7483dbf088718ab6" title="Inserts a set of elements into the relation.">insertElements</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1set.html">std::set&lt;T&gt;</a> &amp;els)   {
<a name="l00366"></a>00366                         <span class="keywordflow">if</span> (els.empty()) <span class="keywordflow">return</span> 0;
<a name="l00367"></a>00367                         <span class="comment">//This code is much more complex than it should! Trying, for efficiency, to avoid multiple calls to insertElement makes things a lot harder.</span>
<a name="l00368"></a>00368                         <span class="comment">//It raises the complexity level to N², but alleviates it greatly by making a single memory allocation. Multiple calls to insertElement will be</span>
<a name="l00369"></a>00369                         <span class="comment">//faster only if the number of elements in the set is really large.</span>
<a name="l00370"></a>00370                         std<a class="code" href="classstd_1_1vector.html">::vector&lt;size_t&gt;</a> added;
<a name="l00371"></a>00371                         <span class="comment">//std::vector&lt;size_t&gt; exist;</span>
<a name="l00372"></a>00372                         added.reserve(els.size());
<a name="l00373"></a>00373                         <span class="keywordflow">for</span> (<span class="keyword">typename</span> <a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">std::set&lt;T&gt;::const_iterator</a> it=els.begin();it!=els.end();++it)    {
<a name="l00374"></a>00374                                 std<a class="code" href="eigen__plugins_8h.html#a39c5d6430ea9395ae7ae729dd0c3f18c">::pair&lt;typename std::set&lt;T&gt;::iterator</a>,<span class="keywordtype">bool</span>&gt; ins=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.insert(*it);
<a name="l00375"></a>00375                                 <span class="keywordtype">size_t</span> dist=<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),ins.first);
<a name="l00376"></a>00376                                 <span class="keywordflow">if</span> (ins.second) {
<a name="l00377"></a>00377                                         added.push_back(dist);
<a name="l00378"></a>00378                                         <span class="keywordflow">for</span> (<a class="code" href="classstd_1_1vector_1_1iterator.html" title="STL iterator class.">std::vector&lt;size_t&gt;::iterator</a> it2=added.begin();it2!=added.end();++it2) <span class="keywordflow">if</span> (*it2&gt;=dist) ++(*it2);
<a name="l00379"></a>00379                                         <span class="comment">//for (std::vector&lt;size_t&gt;::iterator it2=exist.begin();it2!=exist.end();++it2) if (*it2&gt;=dist) ++(*it2);</span>
<a name="l00380"></a>00380                                 }<span class="comment">//     else exist.push_back(dist);</span>
<a name="l00381"></a>00381                         }
<a name="l00382"></a>00382                         std::sort(added.begin(),added.end());
<a name="l00383"></a>00383                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=1;j&lt;added.size();++j) added[j]-=j;
<a name="l00384"></a>00384                         std<a class="code" href="classstd_1_1multiset.html" title="STL class.">::multiset&lt;size_t&gt;</a> poss(added.begin(),added.end());
<a name="l00385"></a>00385                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>.insertRowsAndCols(poss,poss);
<a name="l00386"></a>00386                         <span class="keywordflow">return</span> added.size();
<a name="l00387"></a>00387                 }<span class="comment"></span>
<a name="l00388"></a>00388 <span class="comment">                /**</span>
<a name="l00389"></a>00389 <span class="comment">                  * Inserts a set of elements into the relation, initializing the actual relation with a given function.</span>
<a name="l00390"></a>00390 <span class="comment">                  */</span>
<a name="l00391"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a9eb0bac1f1938bdb4498bd72670dbe92">00391</a>                 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> FunctionType&gt; <span class="keywordtype">size_t</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a9eb0bac1f1938bdb4498bd72670dbe92" title="Inserts a set of elements into the relation, initializing the actual relation with a given function...">insertElements</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1set.html">std::set&lt;T&gt;</a> &amp;els,FunctionType fun)  {
<a name="l00392"></a>00392                         <span class="keywordflow">if</span> (els.empty()) <span class="keywordflow">return</span> 0;
<a name="l00393"></a>00393                         <span class="keywordtype">size_t</span> howMany=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a3ec3583e24d1946b7483dbf088718ab6" title="Inserts a set of elements into the relation.">insertElements</a>(els);
<a name="l00394"></a>00394                         std<a class="code" href="classstd_1_1set.html" title="STL class.">::set&lt;size_t&gt;</a> poss;
<a name="l00395"></a>00395                         {
<a name="l00396"></a>00396                                 <span class="comment">//Little scope for &quot;begin&quot; and &quot;end&quot;...</span>
<a name="l00397"></a>00397                                 <span class="keyword">typename</span> std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;T&gt;::const_iterator</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a973728ff0c39e8c11cc13b6ac4c4fba5" title="Gets an iterator to the starting point of the elements set.">begin</a>=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin(),<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#adb2913616f432880261e7c5f6b107ca1" title="Gets an iterator to the ending point of the elements set.">end</a>=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();
<a name="l00398"></a>00398                                 <span class="keywordflow">for</span> (<span class="keyword">typename</span> <a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">std::set&lt;T&gt;::const_iterator</a> it=els.begin();it!=els.end();++it) poss.insert(<a class="code" href="group__geometry__grp.html#ga8c0a76e906f12560cfa49fcd269c8398" title="Gets the distance between two points in a 2D space.">std::distance</a>(begin,find(begin,<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#adb2913616f432880261e7c5f6b107ca1" title="Gets an iterator to the ending point of the elements set.">end</a>,*it)));
<a name="l00399"></a>00399                         }
<a name="l00400"></a>00400                         std<a class="code" href="classstd_1_1set.html" title="STL class.">::set&lt;size_t&gt;</a> nPoss;
<a name="l00401"></a>00401                         std<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">::set&lt;size_t&gt;::const_iterator</a> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a973728ff0c39e8c11cc13b6ac4c4fba5" title="Gets an iterator to the starting point of the elements set.">begin</a>=poss.begin(),<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#adb2913616f432880261e7c5f6b107ca1" title="Gets an iterator to the ending point of the elements set.">end</a>=poss.end();
<a name="l00402"></a>00402                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i&lt;<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size();++i) <span class="keywordflow">if</span> (std::find(begin,<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#adb2913616f432880261e7c5f6b107ca1" title="Gets an iterator to the ending point of the elements set.">end</a>,i)==<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#adb2913616f432880261e7c5f6b107ca1" title="Gets an iterator to the ending point of the elements set.">end</a>) nPoss.insert(i);
<a name="l00403"></a>00403                         <a class="code" href="classstd_1_1vector.html" title="STL class.">vector&lt;const T *&gt;</a> proxy;
<a name="l00404"></a>00404                         proxy.reserve(poss.size());
<a name="l00405"></a>00405                         <span class="keywordflow">for</span> (<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">std::set&lt;size_t&gt;::const_iterator</a> it=begin;it!=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#adb2913616f432880261e7c5f6b107ca1" title="Gets an iterator to the ending point of the elements set.">end</a>;++it)    {
<a name="l00406"></a>00406                                 <span class="keyword">const</span> T &amp;e1=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a439e2055644b08ec329ce9a8d253f24e" title="Operator for direct access to a element given its index.">operator[]</a>(*it);
<a name="l00407"></a>00407                                 proxy.push_back(&amp;e1);
<a name="l00408"></a>00408                                 <span class="keywordtype">size_t</span> i=0;
<a name="l00409"></a>00409                                 <span class="keywordflow">for</span> (<span class="keyword">typename</span> <a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">std::set&lt;T&gt;::const_iterator</a> it2=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.begin();it2!=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.end();++it2,++i) <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1116845765d3902942f5e1647d2a9c90" title="Template used to make the function interface independent from the function type.">applyFunction</a>(fun,*it,i,e1,*it2);
<a name="l00410"></a>00410                         }
<a name="l00411"></a>00411                         <span class="keywordflow">for</span> (<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">std::set&lt;size_t&gt;::const_iterator</a> it=nPoss.begin();it!=nPoss.end();++it)    {
<a name="l00412"></a>00412                                 <span class="keyword">const</span> T &amp;e1=<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a439e2055644b08ec329ce9a8d253f24e" title="Operator for direct access to a element given its index.">operator[]</a>(*it);
<a name="l00413"></a>00413                                 <span class="keyword">typename</span> std<a class="code" href="classstd_1_1vector_1_1const__iterator.html" title="STL iterator class.">::vector&lt;const T *&gt;::const_iterator</a> itV=proxy.begin();
<a name="l00414"></a>00414                                 <span class="keywordflow">for</span> (<a class="code" href="classstd_1_1set_1_1const__iterator.html" title="STL iterator class.">std::set&lt;size_t&gt;::const_iterator</a> it2=poss.begin();it2!=poss.end();++it2,++itV) <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a1116845765d3902942f5e1647d2a9c90" title="Template used to make the function interface independent from the function type.">applyFunction</a>(fun,*it,*it2,e1,**itV);
<a name="l00415"></a>00415                         }
<a name="l00416"></a>00416                         <span class="keywordflow">return</span> howMany;
<a name="l00417"></a>00417                 }<span class="comment"></span>
<a name="l00418"></a>00418 <span class="comment">                /**</span>
<a name="l00419"></a>00419 <span class="comment">                  * Completely resets the relation, using a new set of elements. Does not initialize the relation.</span>
<a name="l00420"></a>00420 <span class="comment">                  */</span>
<a name="l00421"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ae704d4e75b665bbe320c10d922043489">00421</a>                 <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#ae704d4e75b665bbe320c10d922043489" title="Completely resets the relation, using a new set of elements.">setElements</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1set.html">std::set&lt;T&gt;</a> &amp;newEls)     {
<a name="l00422"></a>00422                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>.setSize(0,0);
<a name="l00423"></a>00423                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>=newEls;
<a name="l00424"></a>00424                         <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#aa80f763010af1fe6fb017671cbb58923" title="Matrix storing the relation.">relation</a>.setSize(newEls.size(),newEls.size());
<a name="l00425"></a>00425                 }<span class="comment"></span>
<a name="l00426"></a>00426 <span class="comment">                /**</span>
<a name="l00427"></a>00427 <span class="comment">                  * Returns the amount of elements present in the relation.</span>
<a name="l00428"></a>00428 <span class="comment">                  */</span>
<a name="l00429"></a><a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a3fb9d4e7e2d72fa030cbecd9a1f6bbab">00429</a>                 <span class="keyword">inline</span> <span class="keywordtype">size_t</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#a3fb9d4e7e2d72fa030cbecd9a1f6bbab" title="Returns the amount of elements present in the relation.">size</a>()<span class="keyword"> const      </span>{
<a name="l00430"></a>00430                         <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html#abe0e7bcd6cf991f27631ac3ae2a4db48" title="Actual set of elements.">elements</a>.size();
<a name="l00431"></a>00431                 }
<a name="l00432"></a>00432         };
<a name="l00433"></a>00433 
<a name="l00434"></a><a class="code" href="namespacemrpt_1_1math_1_1detail.html">00434</a>         <span class="keyword">namespace </span>detail {
<a name="l00435"></a>00435                 <span class="comment">// generic version (specialization is after definition of CBinaryRelation):</span>
<a name="l00436"></a><a class="code" href="namespacemrpt_1_1math_1_1detail.html#ac3ef448f76fc9232d29d4d02e3fd2f64">00436</a>                 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U,<span class="keywordtype">bool</span> UIsObject,<span class="keyword">typename</span> FunctionType&gt; <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="namespacemrpt_1_1math_1_1detail.html#ac3ef448f76fc9232d29d4d02e3fd2f64">applyFunction</a>(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html" title="This class models a binary relation through the elements of any given set.">CBinaryRelation&lt;T,U,UIsObject&gt;</a> &amp;o, FunctionType fun,<span class="keywordtype">size_t</span> e1,<span class="keywordtype">size_t</span> e2,<span class="keyword">const</span> T &amp;T1,<span class="keyword">const</span> T &amp;T2) {
<a name="l00437"></a>00437                         o.getRelationValue(e1,e2)=fun(T1,T2);
<a name="l00438"></a>00438                 }
<a name="l00439"></a>00439 <span class="comment"></span>
<a name="l00440"></a>00440 <span class="comment">                /** Template specialization by reference type.</span>
<a name="l00441"></a>00441 <span class="comment">                  */</span>
<a name="l00442"></a><a class="code" href="namespacemrpt_1_1math_1_1detail.html#ae848e6be59fb0b9effb834dc8a28ac5a">00442</a>                 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U,<span class="keywordtype">bool</span> UIsObject&gt; <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="namespacemrpt_1_1math_1_1detail.html#ac3ef448f76fc9232d29d4d02e3fd2f64">applyFunction</a>(<a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html" title="This class models a binary relation through the elements of any given set.">CBinaryRelation&lt;T,U,UIsObject&gt;</a> &amp;o,<span class="keyword">typename</span> <a class="code" href="classmrpt_1_1math_1_1_c_binary_relation.html" title="This class models a binary relation through the elements of any given set.">CBinaryRelation&lt;T,U,UIsObject&gt;::FunctionByReferencePass</a> fun,<span class="keywordtype">size_t</span> e1,<span class="keywordtype">size_t</span> e2,<span class="keyword">const</span> T &amp;T1,<span class="keyword">const</span> T &amp;T2)    {
<a name="l00443"></a>00443                         fun(T1,T2,o.getRelationValue(e1,e2));
<a name="l00444"></a>00444                 }
<a name="l00445"></a>00445         }
<a name="l00446"></a>00446 
<a name="l00447"></a>00447 
<a name="l00448"></a>00448 }}      <span class="comment">//End of namespaces</span>
<a name="l00449"></a>00449 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<br><hr><br> <table border="0" width="100%"> <tr> <td> Page generated by <a href="http://www.doxygen.org" target="_blank">Doxygen 1.7.5</a> for MRPT 0.9.5 SVN: at Sun Sep 25 17:20:18 UTC 2011</td><td></td> <td width="100"> </td> <td width="150">  </td></tr> </table>  </body></html>