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

« back to all changes in this revision

Viewing changes to doc/html/a00127.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:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
 
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3
 
<title>BitMagic: sample9.cpp Source File</title>
4
 
<link href="doxygen.css" rel="stylesheet" type="text/css">
5
 
<link href="tabs.css" rel="stylesheet" type="text/css">
6
 
</head><body>
7
 
<!-- Generated by Doxygen 1.5.5 -->
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
2
<html xmlns="http://www.w3.org/1999/xhtml">
 
3
<head>
 
4
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
 
5
<title>BitMagic: Memory Allocation</title>
 
6
<link href="tabs.css" rel="stylesheet" type="text/css"/>
 
7
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
 
8
</head>
 
9
<body>
 
10
<!-- Generated by Doxygen 1.6.1 -->
8
11
<div class="navigation" id="top">
9
12
  <div class="tabs">
10
13
    <ul>
11
14
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
12
15
      <li><a href="modules.html"><span>Modules</span></a></li>
13
16
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
14
 
      <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
15
 
      <li class="current"><a href="files.html"><span>Files</span></a></li>
 
17
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
 
18
      <li><a href="files.html"><span>Files</span></a></li>
16
19
      <li><a href="examples.html"><span>Examples</span></a></li>
17
20
    </ul>
18
21
  </div>
19
 
<h1>sample9.cpp</h1><a href="a00105.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
20
 
<a name="l00002"></a>00002 <span class="comment">Copyright(c) 2002-2005 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)</span>
21
 
<a name="l00003"></a>00003 <span class="comment"></span>
22
 
<a name="l00004"></a>00004 <span class="comment">Permission is hereby granted, free of charge, to any person </span>
23
 
<a name="l00005"></a>00005 <span class="comment">obtaining a copy of this software and associated documentation </span>
24
 
<a name="l00006"></a>00006 <span class="comment">files (the "Software"), to deal in the Software without restriction, </span>
25
 
<a name="l00007"></a>00007 <span class="comment">including without limitation the rights to use, copy, modify, merge, </span>
26
 
<a name="l00008"></a>00008 <span class="comment">publish, distribute, sublicense, and/or sell copies of the Software, </span>
27
 
<a name="l00009"></a>00009 <span class="comment">and to permit persons to whom the Software is furnished to do so, </span>
28
 
<a name="l00010"></a>00010 <span class="comment">subject to the following conditions:</span>
29
 
<a name="l00011"></a>00011 <span class="comment"></span>
30
 
<a name="l00012"></a>00012 <span class="comment">The above copyright notice and this permission notice shall be included </span>
31
 
<a name="l00013"></a>00013 <span class="comment">in all copies or substantial portions of the Software.</span>
32
 
<a name="l00014"></a>00014 <span class="comment"></span>
33
 
<a name="l00015"></a>00015 <span class="comment">THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, </span>
34
 
<a name="l00016"></a>00016 <span class="comment">EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES </span>
35
 
<a name="l00017"></a>00017 <span class="comment">OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. </span>
36
 
<a name="l00018"></a>00018 <span class="comment">IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, </span>
37
 
<a name="l00019"></a>00019 <span class="comment">DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, </span>
38
 
<a name="l00020"></a>00020 <span class="comment">ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR </span>
39
 
<a name="l00021"></a>00021 <span class="comment">OTHER DEALINGS IN THE SOFTWARE.</span>
40
 
<a name="l00022"></a>00022 <span class="comment">*/</span>
41
 
<a name="l00023"></a>00023 <span class="comment"></span>
42
 
<a name="l00024"></a>00024 <span class="comment">/** \example sample9.cpp</span>
43
 
<a name="l00025"></a>00025 <span class="comment"></span>
44
 
<a name="l00026"></a>00026 <span class="comment">    Example demonstrates binary distance metrics.</span>
45
 
<a name="l00027"></a>00027 <span class="comment"> </span>
46
 
<a name="l00028"></a>00028 <span class="comment">  \sa bm::count_and </span>
47
 
<a name="l00029"></a>00029 <span class="comment">  \sa bm::count_xor</span>
48
 
<a name="l00030"></a>00030 <span class="comment">  \sa bm::count_sub</span>
49
 
<a name="l00031"></a>00031 <span class="comment">  \sa bm::count_or</span>
50
 
<a name="l00032"></a>00032 <span class="comment">  \sa bm::distance_operation</span>
51
 
<a name="l00033"></a>00033 <span class="comment"></span>
52
 
<a name="l00034"></a>00034 <span class="comment">   For more information please visit:  http://bmagic.sourceforge.net</span>
53
 
<a name="l00035"></a>00035 <span class="comment"></span>
54
 
<a name="l00036"></a>00036 <span class="comment">*/</span>
55
 
<a name="l00037"></a>00037 
56
 
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;iostream&gt;</span>
57
 
<a name="l00039"></a>00039 
58
 
<a name="l00040"></a>00040 <span class="preprocessor">#include "<a class="code" href="a00082.html">bm.h</a>"</span>
59
 
<a name="l00041"></a>00041 <span class="preprocessor">#include "<a class="code" href="a00083.html">bmalgo.h</a>"</span>
60
 
<a name="l00042"></a>00042 
61
 
<a name="l00043"></a>00043 
62
 
<a name="l00044"></a>00044 <span class="keyword">using namespace </span>std;
63
 
<a name="l00045"></a>00045 
64
 
<a name="l00046"></a>00046 
65
 
<a name="l00047"></a><a class="code" href="a00105.html#840291bc02cba5474a4cb46a9b9566fe">00047</a> <span class="keywordtype">int</span> <a class="code" href="a00097.html#840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)
66
 
<a name="l00048"></a>00048 {
67
 
<a name="l00049"></a>00049     <a class="code" href="a00040.html" title="bitvector with runtime compression of bits.">bm::bvector&lt;&gt;</a>   bv1;    
68
 
<a name="l00050"></a>00050     <a class="code" href="a00040.html" title="bitvector with runtime compression of bits.">bm::bvector&lt;&gt;</a>   bv2;    
69
 
<a name="l00051"></a>00051 
70
 
<a name="l00052"></a>00052     bv1[10] = <span class="keyword">true</span>;
71
 
<a name="l00053"></a>00053     bv1[100] = <span class="keyword">true</span>;
72
 
<a name="l00054"></a>00054     bv1[10000] = <span class="keyword">true</span>;
73
 
<a name="l00055"></a>00055     
74
 
<a name="l00056"></a>00056     bv2[10] = <span class="keyword">true</span>;
75
 
<a name="l00057"></a>00057     bv2[100] = <span class="keyword">true</span>;
76
 
<a name="l00058"></a>00058     bv2[20000] = <span class="keyword">true</span>;
77
 
<a name="l00059"></a>00059     bv2[30000] = <span class="keyword">true</span>;
78
 
<a name="l00060"></a>00060     
79
 
<a name="l00061"></a>00061     <span class="comment">// Hamming distance: </span>
80
 
<a name="l00062"></a>00062     
81
 
<a name="l00063"></a>00063     <span class="keywordtype">unsigned</span> hamming = <a class="code" href="a00115.html#gfc64a082dcaee07f70f7faf3e24f844e" title="Computes bitcount of XOR operation of two bitsets.">bm::count_xor</a>(bv1, bv2);
82
 
<a name="l00064"></a>00064     
83
 
<a name="l00065"></a>00065     cout &lt;&lt; <span class="stringliteral">"Hamming distance = "</span> &lt;&lt; hamming &lt;&lt; endl;
84
 
<a name="l00066"></a>00066 
85
 
<a name="l00067"></a>00067     <span class="comment">// Dice distance using basic distance functions</span>
86
 
<a name="l00068"></a>00068     
87
 
<a name="l00069"></a>00069     <span class="keywordtype">double</span> dice = 
88
 
<a name="l00070"></a>00070         double(2 * <a class="code" href="a00115.html#ge451cb4b87e8c0859b0614d2ffb99737" title="Computes bitcount of AND operation of two bitsets.">bm::count_and</a>(bv1, bv2))/double(bv1.<a class="code" href="a00040.html#71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>() + bv2.<a class="code" href="a00040.html#71077c1315555301532e24d4d2b95ea2" title="Returns count of bits which are 1.">count</a>());
89
 
<a name="l00071"></a>00071     
90
 
<a name="l00072"></a>00072     cout &lt;&lt; <span class="stringliteral">"Dice distance = "</span> &lt;&lt; dice &lt;&lt; endl;
91
 
<a name="l00073"></a>00073     
92
 
<a name="l00074"></a>00074     
93
 
<a name="l00075"></a>00075     <span class="comment">// Dice distance, can be computed using "metric pipeline"</span>
94
 
<a name="l00076"></a>00076     
95
 
<a name="l00077"></a>00077     <a class="code" href="a00062.html" title="Distance metric descriptor, holds metric code and result.">bm::distance_metric_descriptor</a> dmd[3];
96
 
<a name="l00078"></a>00078     dmd[0].<a class="code" href="a00062.html#3ece2ccdb7a6616f06a5a15679ccabb1">metric</a> = <a class="code" href="a00115.html#ggc38d64c8b27b652413a664cddd4d40abcb39376469ba778e9a9099ddbae5e7ce" title="(A &amp;amp; B).count()">bm::COUNT_AND</a>;
97
 
<a name="l00079"></a>00079     dmd[1].<a class="code" href="a00062.html#3ece2ccdb7a6616f06a5a15679ccabb1">metric</a> = <a class="code" href="a00115.html#ggc38d64c8b27b652413a664cddd4d40abac7947d53eb3acf81251ee4130e6a4a2" title="A.count().">bm::COUNT_A</a>;
98
 
<a name="l00080"></a>00080     dmd[2].<a class="code" href="a00062.html#3ece2ccdb7a6616f06a5a15679ccabb1">metric</a> = <a class="code" href="a00115.html#ggc38d64c8b27b652413a664cddd4d40abc6dbadf2ab9405daa47dc0f10d082516" title="B.count().">bm::COUNT_B</a>;
99
 
<a name="l00081"></a>00081             
100
 
<a name="l00082"></a>00082     <a class="code" href="a00115.html#g815fef76f02576ab9ab58de0a45d8a4b" title="Distance computing template function.">bm::distance_operation</a>(bv1, bv2, dmd, dmd+3);
101
 
<a name="l00083"></a>00083     
102
 
<a name="l00084"></a>00084     <span class="keywordtype">double</span> dice_p = 
103
 
<a name="l00085"></a>00085         double(2 *  dmd[0].result) / double(dmd[1].result + dmd[2].result);  
104
 
<a name="l00086"></a>00086     
105
 
<a name="l00087"></a>00087     cout &lt;&lt; <span class="stringliteral">"Dice distance (pipeline) = "</span> &lt;&lt; dice_p &lt;&lt; endl;
106
 
<a name="l00088"></a>00088     
107
 
<a name="l00089"></a>00089     <span class="keywordflow">return</span> 0;
108
 
<a name="l00090"></a>00090 }
109
 
<a name="l00091"></a>00091 
110
 
</pre></div></div>
111
 
<hr size="1"><address style="text-align: right;"><small>Generated on Mon Oct 12 12:16:39 2009 for BitMagic by&nbsp;
 
22
</div>
 
23
<div class="contents">
 
24
<h1>Memory Allocation<br/>
 
25
<small>
 
26
[<a class="el" href="a00117.html">BitMagic C++ Library</a>]</small>
 
27
</h1>
 
28
<p><div class="dynheader">
 
29
Collaboration diagram for Memory Allocation:</div>
 
30
<div class="dynsection">
 
31
<center><table><tr><td><img src="a00127.png" border="0" alt="" usemap="#a00127_map"/>
 
32
<map name="a00127_map" id="a00127">
 
33
<area shape="rect" href="a00117.html" title="For more information please visit: http://bmagic.sourceforge.net." alt="" coords="5,5,149,35"/></map></td></tr></table></center>
 
34
</div>
 
35
</p>
 
36
<table border="0" cellpadding="0" cellspacing="0">
 
37
<tr><td colspan="2"><h2>Data Structures</h2></td></tr>
 
38
<tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00039.html">bm::block_allocator</a></td></tr>
 
39
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default malloc based bitblock allocator class.  <a href="a00039.html#_details">More...</a><br/></td></tr>
 
40
<tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00078.html">bm::ptr_allocator</a></td></tr>
 
41
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default malloc based bitblock allocator class.  <a href="a00078.html#_details">More...</a><br/></td></tr>
 
42
<tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html">bm::mem_alloc&lt; BA, PA &gt;</a></td></tr>
 
43
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">BM style allocator adapter.  <a href="a00074.html#_details">More...</a><br/></td></tr>
 
44
<tr><td colspan="2"><h2>Typedefs</h2></td></tr>
 
45
<tr><td class="memItemLeft" align="right" valign="top">typedef mem_alloc<br class="typebreak"/>
 
46
&lt; block_allocator, <br class="typebreak"/>
 
47
ptr_allocator &gt;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00127.html#gab9059bfb40a6588cdbacfd93901593c1">bm::standard_allocator</a></td></tr>
 
48
</table>
 
49
<hr/><a name="_details"></a><h2>Detailed Description</h2>
 
50
<p>Memory allocation related units </p>
 
51
<hr/><h2>Typedef Documentation</h2>
 
52
<a class="anchor" id="gab9059bfb40a6588cdbacfd93901593c1"></a><!-- doxytag: member="bm::standard_allocator" ref="gab9059bfb40a6588cdbacfd93901593c1" args="" -->
 
53
<div class="memitem">
 
54
<div class="memproto">
 
55
      <table class="memname">
 
56
        <tr>
 
57
          <td class="memname">typedef mem_alloc&lt;block_allocator, ptr_allocator&gt; <a class="el" href="a00074.html">bm::standard_allocator</a></td>
 
58
        </tr>
 
59
      </table>
 
60
</div>
 
61
<div class="memdoc">
 
62
 
 
63
<p>Definition at line <a class="el" href="a00090_source.html#l00234">234</a> of file <a class="el" href="a00090_source.html">bmalloc.h</a>.</p>
 
64
 
 
65
</div>
 
66
</div>
 
67
</div>
 
68
<hr size="1"/><address style="text-align: right;"><small>Generated on Fri Jan 8 20:09:20 2010 for BitMagic by&nbsp;
112
69
<a href="http://www.doxygen.org/index.html">
113
 
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
 
70
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
114
71
</body>
115
72
</html>