~ubuntu-branches/ubuntu/trusty/bmagic/trusty-proposed

« back to all changes in this revision

Viewing changes to doc/html/a00009.html

  • Committer: Bazaar Package Importer
  • Author(s): Roberto C. Sanchez
  • Date: 2010-01-24 14:45:39 UTC
  • mfrom: (4.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100124144539-4ipk5rt64dpp38hl
Tags: 3.6.3-1
* New upstream release
* debian/patches/config.guess.patch: drop obsolete patch
* Add ${misc:Depends} as requested by lintian

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
</div>
23
23
<div class="contents">
24
24
<h1>sample9.cpp</h1><p>Example demonstrates binary distance metrics. </p>
25
 
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="a00120.html#gae451cb4b87e8c0859b0614d2ffb99737" title="Computes bitcount of AND operation of two bitsets.">bm::count_and</a> </dd>
26
 
<dd>
27
 
<a class="el" href="a00120.html#gafc64a082dcaee07f70f7faf3e24f844e" title="Computes bitcount of XOR operation of two bitsets.">bm::count_xor</a> </dd>
28
 
<dd>
29
 
<a class="el" href="a00120.html#ga902d8c1cd1f8a2538cd47d47f5d8d605" title="Computes bitcount of SUB operation of two bitsets.">bm::count_sub</a> </dd>
30
 
<dd>
31
 
<a class="el" href="a00120.html#ga803c564668703fc3bf80067570c2c905" title="Computes bitcount of OR operation of two bitsets.">bm::count_or</a> </dd>
32
 
<dd>
33
 
<a class="el" href="a00120.html#ga815fef76f02576ab9ab58de0a45d8a4b" title="Distance computing template function.">bm::distance_operation</a></dd></dl>
 
25
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="a00125.html#gae451cb4b87e8c0859b0614d2ffb99737" title="Computes bitcount of AND operation of two bitsets.">bm::count_and</a> </dd>
 
26
<dd>
 
27
<a class="el" href="a00125.html#gafc64a082dcaee07f70f7faf3e24f844e" title="Computes bitcount of XOR operation of two bitsets.">bm::count_xor</a> </dd>
 
28
<dd>
 
29
<a class="el" href="a00125.html#ga902d8c1cd1f8a2538cd47d47f5d8d605" title="Computes bitcount of SUB operation of two bitsets.">bm::count_sub</a> </dd>
 
30
<dd>
 
31
<a class="el" href="a00125.html#ga803c564668703fc3bf80067570c2c905" title="Computes bitcount of OR operation of two bitsets.">bm::count_or</a> </dd>
 
32
<dd>
 
33
<a class="el" href="a00125.html#ga815fef76f02576ab9ab58de0a45d8a4b" title="Distance computing template function.">bm::distance_operation</a></dd></dl>
34
34
<p>For more information please visit: <a href="http://bmagic.sourceforge.net">http://bmagic.sourceforge.net</a></p>
35
35
<div class="fragment"><pre class="fragment"><span class="comment">/*</span>
36
36
<span class="comment">Copyright(c) 2002-2005 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)</span>
71
71
 
72
72
<span class="preprocessor">#include &lt;iostream&gt;</span>
73
73
 
74
 
<span class="preprocessor">#include &quot;<a class="code" href="a00084.html">bm.h</a>&quot;</span>
75
 
<span class="preprocessor">#include &quot;<a class="code" href="a00085.html">bmalgo.h</a>&quot;</span>
 
74
<span class="preprocessor">#include &quot;<a class="code" href="a00087.html">bm.h</a>&quot;</span>
 
75
<span class="preprocessor">#include &quot;<a class="code" href="a00088.html">bmalgo.h</a>&quot;</span>
76
76
 
77
77
 
78
78
<span class="keyword">using namespace </span>std;
79
79
 
80
80
 
81
 
<span class="keywordtype">int</span> <a name="a0"></a><a class="code" href="a00101.html#a840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)
 
81
<span class="keywordtype">int</span> <a name="a0"></a><a class="code" href="a00105.html#a840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)
82
82
{
83
 
    <a name="_a1"></a><a class="code" href="a00043.html" title="bitvector with runtime compression of bits.">bm::bvector&lt;&gt;</a>   bv1;    
84
 
    <a class="code" href="a00043.html" title="bitvector with runtime compression of bits.">bm::bvector&lt;&gt;</a>   bv2;    
 
83
    <a name="_a1"></a><a class="code" href="a00044.html" title="bitvector with runtime compression of bits.">bm::bvector&lt;&gt;</a>   bv1;    
 
84
    <a class="code" href="a00044.html" title="bitvector with runtime compression of bits.">bm::bvector&lt;&gt;</a>   bv2;    
85
85
 
86
86
    bv1[10] = <span class="keyword">true</span>;
87
87
    bv1[100] = <span class="keyword">true</span>;
94
94
    
95
95
    <span class="comment">// Hamming distance: </span>
96
96
    
97
 
    <span class="keywordtype">unsigned</span> hamming = <a name="a2"></a><a class="code" href="a00120.html#gafc64a082dcaee07f70f7faf3e24f844e" title="Computes bitcount of XOR operation of two bitsets.">bm::count_xor</a>(bv1, bv2);
 
97
    <span class="keywordtype">unsigned</span> hamming = <a name="a2"></a><a class="code" href="a00125.html#gafc64a082dcaee07f70f7faf3e24f844e" title="Computes bitcount of XOR operation of two bitsets.">bm::count_xor</a>(bv1, bv2);
98
98
    
99
99
    cout &lt;&lt; <span class="stringliteral">&quot;Hamming distance = &quot;</span> &lt;&lt; hamming &lt;&lt; endl;
100
100
 
101
101
    <span class="comment">// Dice distance using basic distance functions</span>
102
102
    
103
103
    <span class="keywordtype">double</span> dice = 
104
 
        double(2 * <a name="a3"></a><a class="code" href="a00120.html#gae451cb4b87e8c0859b0614d2ffb99737" title="Computes bitcount of AND operation of two bitsets.">bm::count_and</a>(bv1, bv2))/double(bv1.<a name="a4"></a><a class="code" href="a00043.html#a71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>() + bv2.<a class="code" href="a00043.html#a71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>());
 
104
        double(2 * <a name="a3"></a><a class="code" href="a00125.html#gae451cb4b87e8c0859b0614d2ffb99737" title="Computes bitcount of AND operation of two bitsets.">bm::count_and</a>(bv1, bv2))/double(bv1.<a name="a4"></a><a class="code" href="a00044.html#a71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>() + bv2.<a class="code" href="a00044.html#a71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>());
105
105
    
106
106
    cout &lt;&lt; <span class="stringliteral">&quot;Dice distance = &quot;</span> &lt;&lt; dice &lt;&lt; endl;
107
107
    
108
108
    
109
109
    <span class="comment">// Dice distance, can be computed using &quot;metric pipeline&quot;</span>
110
110
    
111
 
    <a name="_a5"></a><a class="code" href="a00060.html" title="Distance metric descriptor, holds metric code and result.">bm::distance_metric_descriptor</a> dmd[3];
112
 
    dmd[0].<a name="a6"></a><a class="code" href="a00060.html#a3ece2ccdb7a6616f06a5a15679ccabb1">metric</a> = <a name="a7"></a><a class="code" href="a00120.html#ggac38d64c8b27b652413a664cddd4d40abacb39376469ba778e9a9099ddbae5e7ce" title="(A &amp;amp; B).count()">bm::COUNT_AND</a>;
113
 
    dmd[1].<a class="code" href="a00060.html#a3ece2ccdb7a6616f06a5a15679ccabb1">metric</a> = <a name="a8"></a><a class="code" href="a00120.html#ggac38d64c8b27b652413a664cddd4d40abaac7947d53eb3acf81251ee4130e6a4a2" title="A.count().">bm::COUNT_A</a>;
114
 
    dmd[2].<a class="code" href="a00060.html#a3ece2ccdb7a6616f06a5a15679ccabb1">metric</a> = <a name="a9"></a><a class="code" href="a00120.html#ggac38d64c8b27b652413a664cddd4d40abac6dbadf2ab9405daa47dc0f10d082516" title="B.count().">bm::COUNT_B</a>;
 
111
    <a name="_a5"></a><a class="code" href="a00061.html" title="Distance metric descriptor, holds metric code and result.">bm::distance_metric_descriptor</a> dmd[3];
 
112
    dmd[0].<a name="a6"></a><a class="code" href="a00061.html#a3ece2ccdb7a6616f06a5a15679ccabb1">metric</a> = <a name="a7"></a><a class="code" href="a00125.html#ggac38d64c8b27b652413a664cddd4d40abacb39376469ba778e9a9099ddbae5e7ce" title="(A &amp;amp; B).count()">bm::COUNT_AND</a>;
 
113
    dmd[1].<a class="code" href="a00061.html#a3ece2ccdb7a6616f06a5a15679ccabb1">metric</a> = <a name="a8"></a><a class="code" href="a00125.html#ggac38d64c8b27b652413a664cddd4d40abaac7947d53eb3acf81251ee4130e6a4a2" title="A.count().">bm::COUNT_A</a>;
 
114
    dmd[2].<a class="code" href="a00061.html#a3ece2ccdb7a6616f06a5a15679ccabb1">metric</a> = <a name="a9"></a><a class="code" href="a00125.html#ggac38d64c8b27b652413a664cddd4d40abac6dbadf2ab9405daa47dc0f10d082516" title="B.count().">bm::COUNT_B</a>;
115
115
            
116
 
    <a name="a10"></a><a class="code" href="a00120.html#ga815fef76f02576ab9ab58de0a45d8a4b" title="Distance computing template function.">bm::distance_operation</a>(bv1, bv2, dmd, dmd+3);
 
116
    <a name="a10"></a><a class="code" href="a00125.html#ga815fef76f02576ab9ab58de0a45d8a4b" title="Distance computing template function.">bm::distance_operation</a>(bv1, bv2, dmd, dmd+3);
117
117
    
118
118
    <span class="keywordtype">double</span> dice_p = 
119
119
        double(2 *  dmd[0].result) / double(dmd[1].result + dmd[2].result);  
124
124
}
125
125
 
126
126
</pre></div> </div>
127
 
<hr size="1"/><address style="text-align: right;"><small>Generated on Sun Nov 22 10:49:34 2009 for BitMagic by&nbsp;
 
127
<hr size="1"/><address style="text-align: right;"><small>Generated on Fri Jan 8 20:09:19 2010 for BitMagic by&nbsp;
128
128
<a href="http://www.doxygen.org/index.html">
129
129
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
130
130
</body>