1069 |
11 Feb 08 |
markus |
// $Id$ |
1094 |
15 Feb 08 |
peter |
2 |
// |
2119 |
12 Dec 09 |
peter |
// Copyright (C) 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér |
3550 |
03 Jan 17 |
peter |
// Copyright (C) 2009, 2010, 2011, 2014, 2017 Peter Johansson |
1094 |
15 Feb 08 |
peter |
5 |
// |
1437 |
25 Aug 08 |
peter |
// This file is part of the yat library, http://dev.thep.lu.se/yat |
1094 |
15 Feb 08 |
peter |
7 |
// |
1113 |
21 Feb 08 |
peter |
// The yat library is free software; you can redistribute it and/or |
1094 |
15 Feb 08 |
peter |
// modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
// published by the Free Software Foundation; either version 3 of the |
1094 |
15 Feb 08 |
peter |
// License, or (at your option) any later version. |
1094 |
15 Feb 08 |
peter |
12 |
// |
1094 |
15 Feb 08 |
peter |
// The yat library is distributed in the hope that it will be useful, |
1094 |
15 Feb 08 |
peter |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1094 |
15 Feb 08 |
peter |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1094 |
15 Feb 08 |
peter |
// General Public License for more details. |
1094 |
15 Feb 08 |
peter |
17 |
// |
1094 |
15 Feb 08 |
peter |
// You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
// along with yat. If not, see <http://www.gnu.org/licenses/>. |
1069 |
11 Feb 08 |
markus |
20 |
|
1094 |
15 Feb 08 |
peter |
21 |
|
1069 |
11 Feb 08 |
markus |
22 |
/** |
1112 |
21 Feb 08 |
markus |
\page Concepts Concepts |
1074 |
12 Feb 08 |
markus |
24 |
|
1112 |
21 Feb 08 |
markus |
This page lists all the C++ concepts in the yat project. |
1074 |
12 Feb 08 |
markus |
26 |
|
1545 |
01 Oct 08 |
peter |
- \subpage concept_container_2d |
2141 |
12 Jan 10 |
peter |
- \subpage concept_data_iterator |
1547 |
03 Oct 08 |
peter |
- \subpage concept_distance |
1545 |
01 Oct 08 |
peter |
- \subpage concept_mutable_container_2d |
1112 |
21 Feb 08 |
markus |
- \subpage concept_neighbor_weighting |
1590 |
17 Oct 08 |
peter |
- \subpage concept_weighted_iterator |
1074 |
12 Feb 08 |
markus |
33 |
*/ |
1074 |
12 Feb 08 |
markus |
34 |
|
1074 |
12 Feb 08 |
markus |
35 |
|
1074 |
12 Feb 08 |
markus |
36 |
/** |
1545 |
01 Oct 08 |
peter |
\page concept_container_2d Container2D |
1545 |
01 Oct 08 |
peter |
38 |
|
3295 |
25 Jul 14 |
peter |
\section concept_container_2d_description Description |
1545 |
01 Oct 08 |
peter |
40 |
|
1547 |
03 Oct 08 |
peter |
\ref concept_container_2d is a <a |
1547 |
03 Oct 08 |
peter |
href="http://www.sgi.com/tech/stl/Container.html">Container</a> that |
1547 |
03 Oct 08 |
peter |
stores elements in a two-dimensional array (columns and rows). It |
2002 |
13 Jun 09 |
peter |
provides element access of a specific row and column, as well |
1699 |
06 Jan 09 |
peter |
as iterators that can be used to iterate over a specific column or |
1699 |
06 Jan 09 |
peter |
row. |
1545 |
01 Oct 08 |
peter |
47 |
|
3295 |
25 Jul 14 |
peter |
\section concept_container_2d_requirments Requirements |
1545 |
01 Oct 08 |
peter |
49 |
|
1547 |
03 Oct 08 |
peter |
A \ref concept_container_2d provides the following: |
1545 |
01 Oct 08 |
peter |
51 |
|
3295 |
25 Jul 14 |
peter |
\subsection concept_container_2d_types Types |
1547 |
03 Oct 08 |
peter |
53 |
|
2299 |
12 Jul 10 |
peter |
<table cellspacing=0 border=1> |
1550 |
06 Oct 08 |
peter |
<tr><td>Value type</td><td><tt>X::value_type</tt></td> |
1550 |
06 Oct 08 |
peter |
<td>Type of element stored in Container.</td> |
1550 |
06 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr><td>Const reference type</td><td><tt>X::const_reference</tt></td> |
1547 |
03 Oct 08 |
peter |
<td>A type that behaves as const reference to the \ref |
1547 |
03 Oct 08 |
peter |
concept_container_2d 's value type.</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Const iterator type</td> |
3295 |
25 Jul 14 |
peter |
<td><tt>X::const_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> |
1547 |
03 Oct 08 |
peter |
A read-only iterator that can be used to iterate over the entire \ref |
1547 |
03 Oct 08 |
peter |
concept_container_2d. Typically the iterator iterates along a |
1547 |
03 Oct 08 |
peter |
row, and when the end of one row is reached it jumps to the |
1547 |
03 Oct 08 |
peter |
beginning of the next row. |
1547 |
03 Oct 08 |
peter |
</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Const column iterator type</td> |
3295 |
25 Jul 14 |
peter |
<td><tt>X::const_column_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> |
1547 |
03 Oct 08 |
peter |
A read-only iterator that can be used to examine the elements in one |
1547 |
03 Oct 08 |
peter |
column of the \ref concept_container_2d. |
1547 |
03 Oct 08 |
peter |
</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Const row iterator type</td> |
3295 |
25 Jul 14 |
peter |
<td><tt>X::const_row_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> |
1547 |
03 Oct 08 |
peter |
A read-only iterator that can be used to examine the elements in one |
1547 |
03 Oct 08 |
peter |
row of the \ref concept_container_2d. |
1547 |
03 Oct 08 |
peter |
</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
</table> |
1547 |
03 Oct 08 |
peter |
89 |
|
3295 |
25 Jul 14 |
peter |
\subsection concept_container_2d_public_functions Public Functions |
1547 |
03 Oct 08 |
peter |
91 |
|
2299 |
12 Jul 10 |
peter |
<table cellspacing=0 border=1> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<th>Name</th><th>Expression</th><th>Precondition</th><th>Return type</th> |
1547 |
03 Oct 08 |
peter |
<th>Postcondition</th> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Beginning of range</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.begin()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
<td><tt>const_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Beginning of column</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.begin_column(size_t column)</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>0 <= column < a.columns()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>const_column_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Beginning of row</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.begin_row(size_t row)</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>0 <= row < a.rows()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>const_row_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>End of range</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.end()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
<td><tt>const_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>End of column</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.end_column(size_t column)</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>0 <= column < a.columns()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>const_column_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>End of row</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.end_row(size_t row)</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>0 <= row < a.rows()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>const_row_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Columns</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.columns()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
<td><tt>size_t</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Rows</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.rows()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
<td><tt>size_t</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Element Access</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a(size_t row, size_t column)</tt></td> |
3295 |
25 Jul 14 |
peter |
<td><tt>0 <= row < a.rows()</tt> and |
1698 |
06 Jan 09 |
peter |
<tt>0 <= column < a.columns()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>const_reference</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
</table> |
1547 |
03 Oct 08 |
peter |
162 |
|
3295 |
25 Jul 14 |
peter |
\section concept_container_2d_implementations Implementations |
1545 |
01 Oct 08 |
peter |
164 |
|
1547 |
03 Oct 08 |
peter |
Examples of concept \ref concept_container_2d include: |
1547 |
03 Oct 08 |
peter |
- theplu::yat::classifier::MatrixLookup, |
1547 |
03 Oct 08 |
peter |
- theplu::yat::classifier::MatrixLookupWeighted |
1547 |
03 Oct 08 |
peter |
- theplu::yat::classifier::KernelLookup. |
1545 |
01 Oct 08 |
peter |
169 |
|
1545 |
01 Oct 08 |
peter |
170 |
*/ |
1545 |
01 Oct 08 |
peter |
171 |
|
1545 |
01 Oct 08 |
peter |
172 |
/** |
1547 |
03 Oct 08 |
peter |
\page concept_mutable_container_2d Mutable Container2D |
1545 |
01 Oct 08 |
peter |
174 |
|
3295 |
25 Jul 14 |
peter |
\section concept_mutable_container_2d_description Description |
1545 |
01 Oct 08 |
peter |
176 |
|
1547 |
03 Oct 08 |
peter |
\ref concept_mutable_container_2d is a \ref concept_container_2d that |
1547 |
03 Oct 08 |
peter |
also provides non-const access to its elements. |
1545 |
01 Oct 08 |
peter |
179 |
|
3295 |
25 Jul 14 |
peter |
\section concept_mutable_container_2d_requirments Requirements |
1545 |
01 Oct 08 |
peter |
181 |
|
1547 |
03 Oct 08 |
peter |
In addition to the requirements defined in \ref concept_container_2d, |
1547 |
03 Oct 08 |
peter |
a \ref concept_mutable_container_2d also provides the following: |
1547 |
03 Oct 08 |
peter |
184 |
|
3295 |
25 Jul 14 |
peter |
\subsection concept_mutable_container_2d_types Types |
1547 |
03 Oct 08 |
peter |
186 |
|
2299 |
12 Jul 10 |
peter |
<table cellspacing=0 border=1> |
1547 |
03 Oct 08 |
peter |
<tr><td>Reference type</td><td><tt>X::reference</tt></td> |
1547 |
03 Oct 08 |
peter |
<td>A type that behaves as reference to the \ref |
1547 |
03 Oct 08 |
peter |
concept_mutable_container_2d 's value type.</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Iterator type</td> |
3295 |
25 Jul 14 |
peter |
<td><tt>X::iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> |
1547 |
03 Oct 08 |
peter |
196 |
|
1547 |
03 Oct 08 |
peter |
A mutable iterator similar to Const iterator type, which can be used to |
1547 |
03 Oct 08 |
peter |
iterate over the \ref concept_mutable_container_2d (and modify the |
1547 |
03 Oct 08 |
peter |
elements). Typically the iterator iterates along a row, and when the |
1547 |
03 Oct 08 |
peter |
end of one row is reached it jumps to the beginning of the next row. |
1547 |
03 Oct 08 |
peter |
201 |
|
1547 |
03 Oct 08 |
peter |
</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Column iterator type</td> |
3295 |
25 Jul 14 |
peter |
<td><tt>X::column_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> |
1547 |
03 Oct 08 |
peter |
A mutable iterator that can be used to modify the elements in one |
1547 |
03 Oct 08 |
peter |
column of the \ref concept_mutable_container_2d. |
1547 |
03 Oct 08 |
peter |
</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Row iterator type</td> |
3295 |
25 Jul 14 |
peter |
<td><tt>X::row_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> |
1547 |
03 Oct 08 |
peter |
A mutable iterator that can be used to modify the elements in one |
1547 |
03 Oct 08 |
peter |
row of the \ref concept_mutable_container_2d. |
1547 |
03 Oct 08 |
peter |
</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
</table> |
1547 |
03 Oct 08 |
peter |
221 |
|
3295 |
25 Jul 14 |
peter |
\subsection concept_mutable_container_2d_public_functions Public Functions |
1547 |
03 Oct 08 |
peter |
223 |
|
2299 |
12 Jul 10 |
peter |
<table cellspacing=0 border=1> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<th>Name</th><th>Expression</th><th>Precondition</th><th>Return type</th> |
1547 |
03 Oct 08 |
peter |
<th>Postcondition</th> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Beginning of range</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.begin()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
<td><tt>iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>iterator</tt> is derefenceable, unless <tt>a</tt> is empty</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Beginning of column</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.begin_column(size_t column)</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>0 <= column < a.columns()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>column_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>column_iterator</tt> is derefenceable, unless <tt>a</tt> is empty</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Beginning of row</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.begin_row(size_t row)</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>0 <= row < a.rows()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>row_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>row_iterator</tt> is derefenceable, unless <tt>a</tt> is empty</td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>End of range</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.end()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
<td><tt>iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>End of column</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.end_column(size_t column)</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>column<a.columns()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>column_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>End of row</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a.end_row(size_t row)</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>row<a.rows()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>row_iterator</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
<tr> |
1547 |
03 Oct 08 |
peter |
<td>Element Access</td> |
1547 |
03 Oct 08 |
peter |
<td><tt>a(size_t row, size_t column)</tt></td> |
3295 |
25 Jul 14 |
peter |
<td><tt>0 <= row < a.rows()</tt> and |
1547 |
03 Oct 08 |
peter |
<tt>0 <= column < a.columns()</tt></td> |
1547 |
03 Oct 08 |
peter |
<td><tt>reference</tt></td> |
1547 |
03 Oct 08 |
peter |
<td> </td> |
1547 |
03 Oct 08 |
peter |
</tr> |
1547 |
03 Oct 08 |
peter |
</table> |
1547 |
03 Oct 08 |
peter |
280 |
|
3295 |
25 Jul 14 |
peter |
\section concept_mutable_container_2d_implementations Implementations |
1545 |
01 Oct 08 |
peter |
282 |
|
1547 |
03 Oct 08 |
peter |
Examples of concept \ref concept_mutable_container_2d include: |
1547 |
03 Oct 08 |
peter |
- theplu::yat::utility::Matrix, |
1547 |
03 Oct 08 |
peter |
- theplu::yat::utility::MatrixWeighted |
1545 |
01 Oct 08 |
peter |
286 |
|
1545 |
01 Oct 08 |
peter |
287 |
*/ |
1545 |
01 Oct 08 |
peter |
288 |
|
1545 |
01 Oct 08 |
peter |
289 |
/** |
1112 |
21 Feb 08 |
markus |
\page concept_distance Distance |
1112 |
21 Feb 08 |
markus |
291 |
|
3295 |
25 Jul 14 |
peter |
\section concept_distance_description Description |
1112 |
21 Feb 08 |
markus |
293 |
|
1115 |
21 Feb 08 |
markus |
\ref concept_distance is a concept for classes implementing different |
3548 |
01 Jan 17 |
peter |
alternatives to calculate the distance between two ranges. For details |
3548 |
01 Jan 17 |
peter |
on requirements needed for a class modelling the concept \ref |
3548 |
01 Jan 17 |
peter |
concept_distance refer to section below, but a convenient way to |
3548 |
01 Jan 17 |
peter |
implement a class is to use class theplu::yat::statistics::Distance as |
3548 |
01 Jan 17 |
peter |
base class. |
1112 |
21 Feb 08 |
markus |
300 |
|
3295 |
25 Jul 14 |
peter |
\section concept_distance_requirments Requirements |
1112 |
21 Feb 08 |
markus |
302 |
|
2338 |
16 Oct 10 |
peter |
Classes modelling the concept \ref concept_distance should have a copy |
3295 |
25 Jul 14 |
peter |
constructor |
1112 |
21 Feb 08 |
markus |
305 |
|
1115 |
21 Feb 08 |
markus |
\verbatim |
2338 |
16 Oct 10 |
peter |
Distance(const Distance& d); |
2338 |
16 Oct 10 |
peter |
\endverbatim |
2338 |
16 Oct 10 |
peter |
309 |
|
2338 |
16 Oct 10 |
peter |
and also implement the following public function: |
2338 |
16 Oct 10 |
peter |
311 |
|
2338 |
16 Oct 10 |
peter |
\verbatim |
3548 |
01 Jan 17 |
peter |
template<typename Iterator1, typename Iterator2> |
3548 |
01 Jan 17 |
peter |
double operator() (Iterator1 beg1, Iterator1 end1, Iterator2 beg2) const |
1115 |
21 Feb 08 |
markus |
\endverbatim |
1115 |
21 Feb 08 |
markus |
316 |
|
1115 |
21 Feb 08 |
markus |
This function should calculate and return the distance between |
1115 |
21 Feb 08 |
markus |
elements of two ranges. The first range is given by [\a beg1, \a end1) |
1115 |
21 Feb 08 |
markus |
and the second range starts with \a beg2 and has the same length as |
3548 |
01 Jan 17 |
peter |
the first range. The function should support iterators that model \ref |
3548 |
01 Jan 17 |
peter |
concept_data_iterator and \forward_traversal_iterator, in other words, |
3548 |
01 Jan 17 |
peter |
the function should not assume any functionality not guaranteed by |
3548 |
01 Jan 17 |
peter |
concepts \forward_traversal_iterator and \readable_iterator. |
3548 |
01 Jan 17 |
peter |
324 |
|
3549 |
01 Jan 17 |
peter |
As \ref concept_data_iterator should be supported, class |
3548 |
01 Jan 17 |
peter |
should support \ref concept_weighted_iterator. Typically a \ref |
3548 |
01 Jan 17 |
peter |
concept_distance class has a fast calculation for the case when |
3548 |
01 Jan 17 |
peter |
neither of the two input ranges is weighted, and a separate function |
3548 |
01 Jan 17 |
peter |
taking care of weights. A convenient way to select between unweighted and |
3548 |
01 Jan 17 |
peter |
weighted implementations is to utilize tag structs |
3295 |
25 Jul 14 |
peter |
theplu::yat::utility::unweighted_iterator_tag and |
3548 |
01 Jan 17 |
peter |
theplu::yat::utility::weighted_iterator_tag as returned from meta-function |
3548 |
01 Jan 17 |
peter |
theplu::yat::utility::weighted_if_any2. |
1115 |
21 Feb 08 |
markus |
334 |
|
3548 |
01 Jan 17 |
peter |
The class theplu::yat::utility::DistanceConcept an be used to test |
3548 |
01 Jan 17 |
peter |
that a class fulfills these requirements. |
3548 |
01 Jan 17 |
peter |
337 |
|
3295 |
25 Jul 14 |
peter |
\section concept_distance_implementations Implementations |
1115 |
21 Feb 08 |
markus |
339 |
|
1112 |
21 Feb 08 |
markus |
Examples of classes modelling the concept \ref concept_distance |
1112 |
21 Feb 08 |
markus |
include theplu::yat::statistics::PearsonDistance and |
1112 |
21 Feb 08 |
markus |
theplu::yat::statistics::EuclideanDistance. |
1112 |
21 Feb 08 |
markus |
343 |
|
1181 |
27 Feb 08 |
peter |
\see \ref weighted_distance |
1181 |
27 Feb 08 |
peter |
345 |
|
1073 |
12 Feb 08 |
markus |
346 |
*/ |
1112 |
21 Feb 08 |
markus |
347 |
|
1112 |
21 Feb 08 |
markus |
348 |
/** |
1112 |
21 Feb 08 |
markus |
\page concept_neighbor_weighting Neighbor Weighting Method |
1112 |
21 Feb 08 |
markus |
350 |
|
3295 |
25 Jul 14 |
peter |
\section concept_neighbor_weighting_description Description |
1112 |
21 Feb 08 |
markus |
352 |
|
1112 |
21 Feb 08 |
markus |
\ref concept_neighbor_weighting is a concept used in connection with |
1112 |
21 Feb 08 |
markus |
theplu::yat::classifier::KNN - classes used as the template argument |
1112 |
21 Feb 08 |
markus |
NeighborWeighting should implement this concept. |
1112 |
21 Feb 08 |
markus |
356 |
|
3295 |
25 Jul 14 |
peter |
\section concept_neighbor_weighting_requirements Requirements |
1112 |
21 Feb 08 |
markus |
358 |
|
1112 |
21 Feb 08 |
markus |
Classes modelling the concept \ref concept_neighbor_weighting should |
3295 |
25 Jul 14 |
peter |
be DefaultConstructible and Assignable as well as |
1115 |
21 Feb 08 |
markus |
implement the following public function: |
3295 |
25 Jul 14 |
peter |
362 |
|
3295 |
25 Jul 14 |
peter |
\verbatim |
3295 |
25 Jul 14 |
peter |
void operator()(const utility::VectorBase& distance, |
1522 |
23 Sep 08 |
peter |
const std::vector<size_t>& k_sorted, |
3295 |
25 Jul 14 |
peter |
const Target& target, |
1522 |
23 Sep 08 |
peter |
utility::VectorMutable& prediction) const |
1112 |
21 Feb 08 |
markus |
\endverbatim |
1112 |
21 Feb 08 |
markus |
369 |
|
1112 |
21 Feb 08 |
markus |
For a test sample, this function should calculate a total vote |
1112 |
21 Feb 08 |
markus |
(i.e. based on all k nearest neighbors) for each class. The vector \a |
1112 |
21 Feb 08 |
markus |
distance contains the distances from a test sample to all training |
1112 |
21 Feb 08 |
markus |
samples. The vector \a k_sorted contains the indices (for both \a |
1112 |
21 Feb 08 |
markus |
distance and \a target) to the k training samples with the smallest |
1112 |
21 Feb 08 |
markus |
distances to the test sample. The class for each training sample is |
1112 |
21 Feb 08 |
markus |
given by \a target, which is sorted in the same sample order as \a |
1112 |
21 Feb 08 |
markus |
distance. For each class the function calculates a total vote based on |
1112 |
21 Feb 08 |
markus |
the the nearest neighbors of the test sample that belong to the |
1156 |
26 Feb 08 |
markus |
class. The total vote for each class is stored in the vector \a |
1156 |
26 Feb 08 |
markus |
prediction. The function should be implemented such that nearest |
1156 |
26 Feb 08 |
markus |
neighbors with distance infinity do not vote. |
1112 |
21 Feb 08 |
markus |
382 |
|
3295 |
25 Jul 14 |
peter |
\section concept_neighbor_weighting_implementations Implementations |
1115 |
21 Feb 08 |
markus |
384 |
|
1112 |
21 Feb 08 |
markus |
Examples of classes modelling the concept \ref |
1112 |
21 Feb 08 |
markus |
concept_neighbor_weighting include |
1112 |
21 Feb 08 |
markus |
theplu::yat::classifier::KNN_Uniform, |
1112 |
21 Feb 08 |
markus |
theplu::yat::classifier::KNN_ReciprocalDistance and |
1112 |
21 Feb 08 |
markus |
theplu::yat::classifier::KNN_ReciprocalRank. |
1112 |
21 Feb 08 |
markus |
390 |
|
1112 |
21 Feb 08 |
markus |
391 |
*/ |
1590 |
17 Oct 08 |
peter |
392 |
|
1590 |
17 Oct 08 |
peter |
393 |
/** |
1590 |
17 Oct 08 |
peter |
\page concept_weighted_iterator Weighted Iterator |
1590 |
17 Oct 08 |
peter |
395 |
|
3295 |
25 Jul 14 |
peter |
\section concept_weighted_iterator_description Description |
1590 |
17 Oct 08 |
peter |
397 |
|
1590 |
17 Oct 08 |
peter |
Most functionality in yat come in two versions: one optimized for |
1590 |
17 Oct 08 |
peter |
speed and one weighted version allowing for missing value (see \ref |
1590 |
17 Oct 08 |
peter |
weighted_statistics). For example, weighted containers such as |
1590 |
17 Oct 08 |
peter |
theplu::yat::utility::MatrixWeighted and |
1590 |
17 Oct 08 |
peter |
theplu::yat::classifier::MatrixLookupWeighted allow an easy way to |
1590 |
17 Oct 08 |
peter |
handle missing values. Iterators that iterate over such weighted |
1590 |
17 Oct 08 |
peter |
containers are by definition \ref concept_weighted_iterator. This |
1590 |
17 Oct 08 |
peter |
concept is orthogonal against other iterator concepts such as Random |
1590 |
17 Oct 08 |
peter |
Access Iterator. |
1590 |
17 Oct 08 |
peter |
407 |
|
3295 |
25 Jul 14 |
peter |
\section concept_weighted_iterator_requirements Requirements |
1590 |
17 Oct 08 |
peter |
409 |
|
1590 |
17 Oct 08 |
peter |
When implementing a new iterator that may be a \ref |
1590 |
17 Oct 08 |
peter |
concept_weighted_iterator, there are a few things to concider. |
1590 |
17 Oct 08 |
peter |
412 |
|
1590 |
17 Oct 08 |
peter |
\subsection weighted_iterator_traits |
1590 |
17 Oct 08 |
peter |
414 |
|
1590 |
17 Oct 08 |
peter |
To decide whether an iterator is weighted, there exists a |
1590 |
17 Oct 08 |
peter |
meta-function |
1590 |
17 Oct 08 |
peter |
theplu::yat::utility::weighted_iterator_traits<Iterator>::type that |
1590 |
17 Oct 08 |
peter |
will return either theplu::yat::utility::weighted_iterator_tag or |
1590 |
17 Oct 08 |
peter |
theplu::yat::utility::unweighted_iterator_tag. The default |
1590 |
17 Oct 08 |
peter |
implementation of this meta-function works in most cases, including on |
1590 |
17 Oct 08 |
peter |
all std::iterators, but if you implement a new iterator make sure it |
1590 |
17 Oct 08 |
peter |
behaves as you desire, or you need to create a specialization. |
1590 |
17 Oct 08 |
peter |
423 |
|
1590 |
17 Oct 08 |
peter |
\subsection iterator_traits |
1590 |
17 Oct 08 |
peter |
425 |
|
1590 |
17 Oct 08 |
peter |
Sometimes it is useful to have unweighted iterators behaving as though |
1590 |
17 Oct 08 |
peter |
they were weighted. For instance, |
1590 |
17 Oct 08 |
peter |
theplu::yat::statistics::EuclideanDistance calculates the distance |
2249 |
13 May 10 |
peter |
between two ranges. If both ranges are unweighted the unweighted |
1590 |
17 Oct 08 |
peter |
version is used, and when any of the two ranges is weighted the |
1590 |
17 Oct 08 |
peter |
weighted version kicks in. In order to make this work also when |
1590 |
17 Oct 08 |
peter |
comparing weighted and unweighted ranges, there must a mechanism to |
1590 |
17 Oct 08 |
peter |
let the unweighted iterator behave as though it were weighted. |
1590 |
17 Oct 08 |
peter |
434 |
|
1590 |
17 Oct 08 |
peter |
This can be accomplished through |
1590 |
17 Oct 08 |
peter |
theplu::yat::utility::iterator_traits, which enables access to data |
1590 |
17 Oct 08 |
peter |
value as well as to weight value. For unweighted iterators the weight |
1590 |
17 Oct 08 |
peter |
value is always equal to 1.0 and is not mutable. The default |
1590 |
17 Oct 08 |
peter |
implementation works for most iterators including all unweighted, but |
1590 |
17 Oct 08 |
peter |
if you implement a new weighted iterator you need to check that the |
1590 |
17 Oct 08 |
peter |
default implementation will work for you (see class |
1590 |
17 Oct 08 |
peter |
documentation). Otherwise, you will need to implement a |
2280 |
26 Jun 10 |
peter |
specialization. Note that the default implementation requires that, if |
2312 |
17 Aug 10 |
peter |
\c iterator is a weighted iterator, its \c reference must have |
2280 |
26 Jun 10 |
peter |
member functions data() and weight(). This should not be a problem as |
2312 |
17 Aug 10 |
peter |
long as \c reference is theplu::yat::utility::DataWeight or |
2281 |
26 Jun 10 |
peter |
theplu::yat::utility::DataWeightProxy, but could potentially be a |
2312 |
17 Aug 10 |
peter |
problem when creating weighted iterators with other \c reference. |
1590 |
17 Oct 08 |
peter |
449 |
|
2141 |
12 Jan 10 |
peter |
450 |
*/ |
2141 |
12 Jan 10 |
peter |
451 |
|
2141 |
12 Jan 10 |
peter |
452 |
/** |
2141 |
12 Jan 10 |
peter |
\page concept_data_iterator Data Iterator |
2141 |
12 Jan 10 |
peter |
454 |
|
3295 |
25 Jul 14 |
peter |
\section concept_data_iterator_description Description |
2141 |
12 Jan 10 |
peter |
456 |
|
3295 |
25 Jul 14 |
peter |
\ref concept_data_iterator is an iterator that is either: |
2141 |
12 Jan 10 |
peter |
458 |
|
2504 |
29 Jun 11 |
peter |
- a \ref concept_weighted_iterator with value type convertible to |
2504 |
29 Jun 11 |
peter |
theplu::yat::utility::DataWeight. |
2504 |
29 Jun 11 |
peter |
- an unweighted iterator with value type convertible to \c double. |
2141 |
12 Jan 10 |
peter |
462 |
|
3322 |
06 Oct 14 |
peter |
in addition |
3322 |
06 Oct 14 |
peter |
464 |
|
3322 |
06 Oct 14 |
peter |
- \c theplu::yat::utility::weighted_iterator_traits<I> must work |
3579 |
16 Jan 17 |
peter |
well, which implies that iterator, \c I is a \readable_iterator |
3579 |
16 Jan 17 |
peter |
and \single_pass_iterator. |
3322 |
06 Oct 14 |
peter |
468 |
|
3295 |
25 Jul 14 |
peter |
\section concept_data_iterator_implementations Implementations |
2141 |
12 Jan 10 |
peter |
470 |
|
2141 |
12 Jan 10 |
peter |
Examples of concept \ref concept_data_iterator include: |
2141 |
12 Jan 10 |
peter |
- theplu::yat::utility::Matrix::iterator, |
2263 |
26 May 10 |
peter |
- theplu::yat::utility::MatrixWeighted::iterator, |
2141 |
12 Jan 10 |
peter |
- theplu::yat::classifier::MatrixLookup::const_iterator, |
2141 |
12 Jan 10 |
peter |
- theplu::yat::classifier::MatrixLookupWeighted::const_iterator |
2141 |
12 Jan 10 |
peter |
476 |
*/ |