1
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3
<title>BitMagic: Distance metrics</title>
3
<title>BitMagic: bm::decoder_range_adapter< DEC > Class Template Reference</title>
4
4
<link href="doxygen.css" rel="stylesheet" type="text/css">
6
6
<!-- Generated by Doxygen 1.4.1 -->
7
7
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="examples.html">Examples</a></div>
8
<h1>Distance metrics<br>
10
[<a class="el" href="a00100.html">Set algorithms</a>]</small>
13
Collaboration diagram for Distance metrics:<center><table><tr><td><img src="a00101.png" border="0" alt="" usemap="#a00162_map">
14
<map name="a00162_map">
15
<area href="a00100.html" shape="rect" coords="17,5,111,26" alt="">
16
</map></td></tr></table></center>
17
<table border="0" cellpadding="0" cellspacing="0">
9
<a class="el" href="a00129.html">bm</a>::<a class="el" href="a00101.html">decoder_range_adapter</a></div>
10
<h1>bm::decoder_range_adapter< DEC > Class Template Reference</h1>Adapter to get words from a range stream (see range serialized bit-block).
11
<a href="#_details">More...</a>
13
<code>#include <<a class="el" href="a00141.html">bmfunc.h</a>></code>
15
Collaboration diagram for bm::decoder_range_adapter< DEC >:<p><center><img src="a00221.png" border="0" usemap="#a00222" alt="Collaboration graph"></center>
16
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center><table border="0" cellpadding="0" cellspacing="0">
19
<tr><td colspan="2"><br><h2>Enumerations</h2></td></tr>
20
<tr><td class="memItemLeft" nowrap align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><a class="el" href="a00101.html#ga5">bm::distance_metric</a> { <br>
21
<a class="el" href="a00101.html#gga5a36">bm::COUNT_AND</a>,
22
<a class="el" href="a00101.html#gga5a37">bm::COUNT_XOR</a>,
23
<a class="el" href="a00101.html#gga5a38">bm::COUNT_OR</a>,
24
<a class="el" href="a00101.html#gga5a39">bm::COUNT_SUB_AB</a>,
26
<a class="el" href="a00101.html#gga5a40">bm::COUNT_SUB_BA</a>,
27
<a class="el" href="a00101.html#gga5a41">bm::COUNT_A</a>,
28
<a class="el" href="a00101.html#gga5a42">bm::COUNT_B</a>
32
<tr><td class="mdescLeft"> </td><td class="mdescRight">Distance metrics codes defined for vectors A and B. <a href="a00101.html#ga5">More...</a><br></td></tr>
33
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
34
<tr><td class="memTemplParams" nowrap colspan="2">template<class BV> </td></tr>
35
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top">void </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00101.html#ga0">bm::distance_operation</a> (const BV &bv1, const BV &bv2, distance_metric_descriptor *dmit, distance_metric_descriptor *dmit_end)</td></tr>
37
<tr><td class="mdescLeft"> </td><td class="mdescRight">Distance computing template function. <a href="#ga0"></a><br></td></tr>
38
<tr><td class="memTemplParams" nowrap colspan="2">template<class BV> </td></tr>
39
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top"><a class="el" href="a00092.html#a9">bm::id_t</a> </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00101.html#ga1">bm::count_and</a> (const BV &bv1, const BV &bv2)</td></tr>
41
<tr><td class="mdescLeft"> </td><td class="mdescRight">Computes bitcount of AND operation of two bitsets. <a href="#ga1"></a><br></td></tr>
42
<tr><td class="memTemplParams" nowrap colspan="2">template<class BV> </td></tr>
43
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top"><a class="el" href="a00092.html#a9">bm::id_t</a> </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00101.html#ga2">bm::count_xor</a> (const BV &bv1, const BV &bv2)</td></tr>
45
<tr><td class="mdescLeft"> </td><td class="mdescRight">Computes bitcount of XOR operation of two bitsets. <a href="#ga2"></a><br></td></tr>
46
<tr><td class="memTemplParams" nowrap colspan="2">template<class BV> </td></tr>
47
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top"><a class="el" href="a00092.html#a9">bm::id_t</a> </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00101.html#ga3">bm::count_sub</a> (const BV &bv1, const BV &bv2)</td></tr>
49
<tr><td class="mdescLeft"> </td><td class="mdescRight">Computes bitcount of SUB operation of two bitsets. <a href="#ga3"></a><br></td></tr>
50
<tr><td class="memTemplParams" nowrap colspan="2">template<class BV> </td></tr>
51
<tr><td class="memTemplItemLeft" nowrap align="right" valign="top"><a class="el" href="a00092.html#a9">bm::id_t</a> </td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00101.html#ga4">bm::count_or</a> (const BV &bv1, const BV &bv2)</td></tr>
53
<tr><td class="mdescLeft"> </td><td class="mdescRight">Computes bitcount of OR operation of two bitsets. <a href="#ga4"></a><br></td></tr>
18
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
19
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00101.html#a0">decoder_range_adapter</a> (DEC &dec, unsigned from_idx, unsigned to_idx)</td></tr>
21
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="a00129.html#a27">bm::word_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00101.html#a1">get_32</a> ()</td></tr>
55
24
<hr><a name="_details"></a><h2>Detailed Description</h2>
56
Algorithms to compute binary distance metrics <hr><h2>Enumeration Type Documentation</h2>
57
<a class="anchor" name="ga5" doxytag="bm::distance_metric"></a><p>
58
<table class="mdTable" cellpadding="2" cellspacing="0">
61
<table cellpadding="0" cellspacing="0" border="0">
63
<td class="md" nowrap valign="top">enum <a class="el" href="a00101.html#ga5">bm::distance_metric</a> </td>
69
<table cellspacing="5" cellpadding="0" border="0">
77
Distance metrics codes defined for vectors A and B.
79
<dl compact><dt><b>Enumeration values: </b></dt><dd>
80
<table border="0" cellspacing="2" cellpadding="0">
81
<tr><td valign="top"><em><a class="anchor" name="gga5a36" doxytag="COUNT_AND"></a>COUNT_AND</em> </td><td>
82
(A & B).count() </td></tr>
83
<tr><td valign="top"><em><a class="anchor" name="gga5a37" doxytag="COUNT_XOR"></a>COUNT_XOR</em> </td><td>
84
(A ^ B).count() </td></tr>
85
<tr><td valign="top"><em><a class="anchor" name="gga5a38" doxytag="COUNT_OR"></a>COUNT_OR</em> </td><td>
86
(A | B).count() </td></tr>
87
<tr><td valign="top"><em><a class="anchor" name="gga5a39" doxytag="COUNT_SUB_AB"></a>COUNT_SUB_AB</em> </td><td>
88
(A - B).count() </td></tr>
89
<tr><td valign="top"><em><a class="anchor" name="gga5a40" doxytag="COUNT_SUB_BA"></a>COUNT_SUB_BA</em> </td><td>
90
(B - A).count() </td></tr>
91
<tr><td valign="top"><em><a class="anchor" name="gga5a41" doxytag="COUNT_A"></a>COUNT_A</em> </td><td>
93
<tr><td valign="top"><em><a class="anchor" name="gga5a42" doxytag="COUNT_B"></a>COUNT_B</em> </td><td>
99
Definition at line <a class="el" href="a00103.html#l00052">52</a> of file <a class="el" href="a00103.html">bmalgo.h</a>. </td>
102
<hr><h2>Function Documentation</h2>
103
<a class="anchor" name="ga1" doxytag="bm::count_and"></a><p>
104
<table class="mdTable" cellpadding="2" cellspacing="0">
107
<table cellpadding="0" cellspacing="0" border="0">
109
<td class="mdPrefix" colspan="4">
110
template<class BV> </td>
113
<td class="md" nowrap valign="top"><a class="el" href="a00092.html#a9">bm::id_t</a> count_and </td>
114
<td class="md" valign="top">( </td>
115
<td class="md" nowrap valign="top">const BV & </td>
116
<td class="mdname" nowrap> <em>bv1</em>, </td>
119
<td class="md" nowrap align="right"></td>
121
<td class="md" nowrap>const BV & </td>
122
<td class="mdname" nowrap> <em>bv2</em></td>
126
<td class="md">) </td>
127
<td class="md" colspan="2"></td>
133
<table cellspacing="5" cellpadding="0" border="0">
141
Computes bitcount of AND operation of two bitsets.
143
<dl compact><dt><b>Parameters:</b></dt><dd>
144
<table border="0" cellspacing="2" cellpadding="0">
145
<tr><td valign="top"></td><td valign="top"><em>bv1</em> </td><td>- Argument bit-vector. </td></tr>
146
<tr><td valign="top"></td><td valign="top"><em>bv2</em> </td><td>- Argument bit-vector. </td></tr>
149
<dl compact><dt><b>Returns:</b></dt><dd>bitcount of the result </dd></dl>
152
Definition at line <a class="el" href="a00103.html#l00455">455</a> of file <a class="el" href="a00103.html">bmalgo.h</a>.
154
References <a class="el" href="a00103.html#l00352">bm::distance_operation()</a>, and <a class="el" href="a00103.html#l00071">bm::distance_metric_descriptor::result</a>. </td>
157
<a class="anchor" name="ga4" doxytag="bm::count_or"></a><p>
158
<table class="mdTable" cellpadding="2" cellspacing="0">
161
<table cellpadding="0" cellspacing="0" border="0">
163
<td class="mdPrefix" colspan="4">
164
template<class BV> </td>
167
<td class="md" nowrap valign="top"><a class="el" href="a00092.html#a9">bm::id_t</a> count_or </td>
168
<td class="md" valign="top">( </td>
169
<td class="md" nowrap valign="top">const BV & </td>
170
<td class="mdname" nowrap> <em>bv1</em>, </td>
173
<td class="md" nowrap align="right"></td>
175
<td class="md" nowrap>const BV & </td>
176
<td class="mdname" nowrap> <em>bv2</em></td>
180
<td class="md">) </td>
181
<td class="md" colspan="2"></td>
187
<table cellspacing="5" cellpadding="0" border="0">
195
Computes bitcount of OR operation of two bitsets.
197
<dl compact><dt><b>Parameters:</b></dt><dd>
198
<table border="0" cellspacing="2" cellpadding="0">
199
<tr><td valign="top"></td><td valign="top"><em>bv1</em> </td><td>- Argument bit-vector. </td></tr>
200
<tr><td valign="top"></td><td valign="top"><em>bv2</em> </td><td>- Argument bit-vector. </td></tr>
203
<dl compact><dt><b>Returns:</b></dt><dd>bitcount of the result </dd></dl>
206
Definition at line <a class="el" href="a00103.html#l00506">506</a> of file <a class="el" href="a00103.html">bmalgo.h</a>.
208
References <a class="el" href="a00103.html#l00352">bm::distance_operation()</a>, and <a class="el" href="a00103.html#l00071">bm::distance_metric_descriptor::result</a>. </td>
211
<a class="anchor" name="ga3" doxytag="bm::count_sub"></a><p>
212
<table class="mdTable" cellpadding="2" cellspacing="0">
215
<table cellpadding="0" cellspacing="0" border="0">
217
<td class="mdPrefix" colspan="4">
218
template<class BV> </td>
221
<td class="md" nowrap valign="top"><a class="el" href="a00092.html#a9">bm::id_t</a> count_sub </td>
222
<td class="md" valign="top">( </td>
223
<td class="md" nowrap valign="top">const BV & </td>
224
<td class="mdname" nowrap> <em>bv1</em>, </td>
227
<td class="md" nowrap align="right"></td>
229
<td class="md" nowrap>const BV & </td>
230
<td class="mdname" nowrap> <em>bv2</em></td>
234
<td class="md">) </td>
235
<td class="md" colspan="2"></td>
241
<table cellspacing="5" cellpadding="0" border="0">
249
Computes bitcount of SUB operation of two bitsets.
251
<dl compact><dt><b>Parameters:</b></dt><dd>
252
<table border="0" cellspacing="2" cellpadding="0">
253
<tr><td valign="top"></td><td valign="top"><em>bv1</em> </td><td>- Argument bit-vector. </td></tr>
254
<tr><td valign="top"></td><td valign="top"><em>bv2</em> </td><td>- Argument bit-vector. </td></tr>
257
<dl compact><dt><b>Returns:</b></dt><dd>bitcount of the result </dd></dl>
260
Definition at line <a class="el" href="a00103.html#l00489">489</a> of file <a class="el" href="a00103.html">bmalgo.h</a>.
262
References <a class="el" href="a00103.html#l00352">bm::distance_operation()</a>, and <a class="el" href="a00103.html#l00071">bm::distance_metric_descriptor::result</a>. </td>
265
<a class="anchor" name="ga2" doxytag="bm::count_xor"></a><p>
266
<table class="mdTable" cellpadding="2" cellspacing="0">
269
<table cellpadding="0" cellspacing="0" border="0">
271
<td class="mdPrefix" colspan="4">
272
template<class BV> </td>
275
<td class="md" nowrap valign="top"><a class="el" href="a00092.html#a9">bm::id_t</a> count_xor </td>
276
<td class="md" valign="top">( </td>
277
<td class="md" nowrap valign="top">const BV & </td>
278
<td class="mdname" nowrap> <em>bv1</em>, </td>
281
<td class="md" nowrap align="right"></td>
283
<td class="md" nowrap>const BV & </td>
284
<td class="mdname" nowrap> <em>bv2</em></td>
288
<td class="md">) </td>
289
<td class="md" colspan="2"></td>
295
<table cellspacing="5" cellpadding="0" border="0">
303
Computes bitcount of XOR operation of two bitsets.
305
<dl compact><dt><b>Parameters:</b></dt><dd>
306
<table border="0" cellspacing="2" cellpadding="0">
307
<tr><td valign="top"></td><td valign="top"><em>bv1</em> </td><td>- Argument bit-vector. </td></tr>
308
<tr><td valign="top"></td><td valign="top"><em>bv2</em> </td><td>- Argument bit-vector. </td></tr>
311
<dl compact><dt><b>Returns:</b></dt><dd>bitcount of the result </dd></dl>
312
<dl compact><dt><b>Examples: </b></dt><dd>
313
<a class="el" href="a00042.html#a61">sample9.cpp</a>.</dl>
315
Definition at line <a class="el" href="a00103.html#l00472">472</a> of file <a class="el" href="a00103.html">bmalgo.h</a>.
317
References <a class="el" href="a00103.html#l00352">bm::distance_operation()</a>, and <a class="el" href="a00103.html#l00071">bm::distance_metric_descriptor::result</a>.
319
Referenced by <a class="el" href="a00119.html#l00047">main()</a>. </td>
322
<a class="anchor" name="ga0" doxytag="bm::distance_operation"></a><p>
323
<table class="mdTable" cellpadding="2" cellspacing="0">
326
<table cellpadding="0" cellspacing="0" border="0">
328
<td class="mdPrefix" colspan="4">
329
template<class BV> </td>
332
<td class="md" nowrap valign="top">void distance_operation </td>
333
<td class="md" valign="top">( </td>
334
<td class="md" nowrap valign="top">const BV & </td>
335
<td class="mdname" nowrap> <em>bv1</em>, </td>
338
<td class="md" nowrap align="right"></td>
340
<td class="md" nowrap>const BV & </td>
341
<td class="mdname" nowrap> <em>bv2</em>, </td>
344
<td class="md" nowrap align="right"></td>
346
<td class="md" nowrap>distance_metric_descriptor * </td>
347
<td class="mdname" nowrap> <em>dmit</em>, </td>
350
<td class="md" nowrap align="right"></td>
352
<td class="md" nowrap>distance_metric_descriptor * </td>
353
<td class="mdname" nowrap> <em>dmit_end</em></td>
357
<td class="md">) </td>
358
<td class="md" colspan="2"></td>
364
<table cellspacing="5" cellpadding="0" border="0">
372
Distance computing template function.
374
Function receives two bitvectors and an array of distance metrics (metrics pipeline). Function computes all metrics saves result into corresponding pipeline results (<a class="el" href="a00065.html#o1">distance_metric_descriptor::result</a>) An important detail is that function reuses metric descriptors, incrementing received values. It allows you to accumulate results from different calls in the pipeline.<p>
375
<dl compact><dt><b>Parameters:</b></dt><dd>
376
<table border="0" cellspacing="2" cellpadding="0">
377
<tr><td valign="top"></td><td valign="top"><em>bv1</em> </td><td>- argument bitvector 1 (A) </td></tr>
378
<tr><td valign="top"></td><td valign="top"><em>bv2</em> </td><td>- argument bitvector 2 (B) </td></tr>
379
<tr><td valign="top"></td><td valign="top"><em>dmit</em> </td><td>- pointer to first element of metric descriptors array Input-Output parameter, receives metric code as input, computation is added to "result" field </td></tr>
380
<tr><td valign="top"></td><td valign="top"><em>dmit_end</em> </td><td>- pointer to (last+1) element of metric descriptors array </td></tr>
383
<dl compact><dt><b>Examples: </b></dt><dd>
384
<a class="el" href="a00042.html#a65">sample9.cpp</a>.</dl>
386
Definition at line <a class="el" href="a00103.html#l00352">352</a> of file <a class="el" href="a00103.html">bmalgo.h</a>.
388
References <a class="el" href="a00105.html#l00059">BM_IS_GAP</a>, <a class="el" href="a00105.html#l00093">BM_SET_MMX_GUARD</a>, and <a class="el" href="a00103.html#l00099">bm::combine_count_operation_with_block()</a>.
390
Referenced by <a class="el" href="a00103.html#l00455">bm::count_and()</a>, <a class="el" href="a00103.html#l00506">bm::count_or()</a>, <a class="el" href="a00103.html#l00489">bm::count_sub()</a>, <a class="el" href="a00103.html#l00472">bm::count_xor()</a>, and <a class="el" href="a00119.html#l00047">main()</a>. </td>
393
<hr size="1"><address style="align: right;"><small>Generated on Thu Apr 20 13:29:10 2006 for BitMagic by
25
<h3>template<class DEC><br>
26
class bm::decoder_range_adapter< DEC ></h3>
28
Adapter to get words from a range stream (see range serialized bit-block).
32
Definition at line <a class="el" href="a00141.html#l04125">4125</a> of file <a class="el" href="a00141.html">bmfunc.h</a>.<hr><h2>Constructor & Destructor Documentation</h2>
33
<a class="anchor" name="a0" doxytag="bm::decoder_range_adapter::decoder_range_adapter"></a><p>
34
<table class="mdTable" cellpadding="2" cellspacing="0">
37
<table cellpadding="0" cellspacing="0" border="0">
39
<td class="mdPrefix" colspan="4">
40
template<class DEC> </td>
43
<td class="md" nowrap valign="top"><a class="el" href="a00101.html">bm::decoder_range_adapter</a>< DEC >::<a class="el" href="a00101.html">decoder_range_adapter</a> </td>
44
<td class="md" valign="top">( </td>
45
<td class="md" nowrap valign="top">DEC & </td>
46
<td class="mdname" nowrap> <em>dec</em>, </td>
49
<td class="md" nowrap align="right"></td>
51
<td class="md" nowrap>unsigned </td>
52
<td class="mdname" nowrap> <em>from_idx</em>, </td>
55
<td class="md" nowrap align="right"></td>
57
<td class="md" nowrap>unsigned </td>
58
<td class="mdname" nowrap> <em>to_idx</em></td>
62
<td class="md">) </td>
63
<td class="md" colspan="2"><code> [inline]</code></td>
69
<table cellspacing="5" cellpadding="0" border="0">
79
Definition at line <a class="el" href="a00141.html#l04128">4128</a> of file <a class="el" href="a00141.html">bmfunc.h</a>. </td>
82
<hr><h2>Member Function Documentation</h2>
83
<a class="anchor" name="a1" doxytag="bm::decoder_range_adapter::get_32"></a><p>
84
<table class="mdTable" cellpadding="2" cellspacing="0">
87
<table cellpadding="0" cellspacing="0" border="0">
89
<td class="mdPrefix" colspan="4">
90
template<class DEC> </td>
93
<td class="md" nowrap valign="top"><a class="el" href="a00129.html#a27">bm::word_t</a> <a class="el" href="a00101.html">bm::decoder_range_adapter</a>< DEC >::get_32 </td>
94
<td class="md" valign="top">( </td>
95
<td class="mdname1" valign="top" nowrap> </td>
96
<td class="md" valign="top"> ) </td>
97
<td class="md" nowrap><code> [inline]</code></td>
103
<table cellspacing="5" cellpadding="0" border="0">
113
Definition at line <a class="el" href="a00141.html#l04135">4135</a> of file <a class="el" href="a00141.html">bmfunc.h</a>. </td>
116
<hr>The documentation for this class was generated from the following file:<ul>
117
<li><a class="el" href="a00141.html">bmfunc.h</a></ul>
118
<hr size="1"><address style="align: right;"><small>Generated on Sun Aug 5 14:12:40 2007 for BitMagic by
394
119
<a href="http://www.doxygen.org/index.html">
395
120
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.1 </small></address>