Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / hana / doc / html / group__group-Group.html
1 <!--
2 Copyright Louis Dionne 2013-2017
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
5 -->
6 <!-- boost-no-inspect -->
7 <!-- HTML header for doxygen 1.8.9.1-->
8 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
9 <html xmlns="http://www.w3.org/1999/xhtml">
10 <head>
11 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
12 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
13 <meta name="generator" content="Doxygen 1.8.11"/>
14 <title>Boost.Hana: Group</title>
15 <link href="tabs.css" rel="stylesheet" type="text/css"/>
16 <script type="text/javascript" src="jquery.js"></script>
17 <script type="text/javascript" src="dynsections.js"></script>
18 <link href="navtree.css" rel="stylesheet" type="text/css"/>
19 <script type="text/javascript" src="resize.js"></script>
20 <script type="text/javascript" src="navtreedata.js"></script>
21 <script type="text/javascript" src="navtree.js"></script>
22 <script type="text/javascript">
23   $(document).ready(initResizable);
24   $(window).load(resizeHeight);
25 </script>
26 <link href="search/search.css" rel="stylesheet" type="text/css"/>
27 <script type="text/javascript" src="search/searchdata.js"></script>
28 <script type="text/javascript" src="search/search.js"></script>
29 <script type="text/javascript">
30   $(document).ready(function() { init_search(); });
31 </script>
32 <script type="text/x-mathjax-config">
33   MathJax.Hub.Config({
34     extensions: ["tex2jax.js"],
35     jax: ["input/TeX","output/HTML-CSS"],
36 });
37 // Copyright Louis Dionne 2013-2017
38 // Distributed under the Boost Software License, Version 1.0.
39 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
40 MathJax.Hub.Config({
41     "HTML-CSS": {
42         linebreaks: {
43             automatic: true,
44             width: "75% container"
45         }
46     }
47 });
48 </script><script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
49 <link href="doxygen.css" rel="stylesheet" type="text/css" />
50 <!-- Additional javascript for drawing charts. -->
51 <script type="text/javascript" src="highcharts.js"></script>
52 <script type="text/javascript" src="highcharts-data.js"></script>
53 <script type="text/javascript" src="highcharts-exporting.js"></script>
54 <script type="text/javascript" src="chart.js"></script>
55 <script type="text/javascript" src="hana.js"></script>
56 </head>
57 <body>
58 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
59 <div id="titlearea">
60 <table cellspacing="0" cellpadding="0">
61  <tbody>
62  <tr style="height: 56px;">
63   <td id="projectlogo"><img alt="Logo" src="Boost.png"/></td>
64   <td style="padding-left: 0.5em;">
65    <div id="projectname">Boost.Hana
66    &#160;<span id="projectnumber">1.1.0</span>
67    </div>
68    <div id="projectbrief">Your standard library for metaprogramming</div>
69   </td>
70    <td>        <div id="MSearchBox" class="MSearchBoxInactive">
71         <span class="left">
72           <img id="MSearchSelect" src="search/mag_sel.png"
73                onmouseover="return searchBox.OnSearchSelectShow()"
74                onmouseout="return searchBox.OnSearchSelectHide()"
75                alt=""/>
76           <input type="text" id="MSearchField" value="Search" accesskey="S"
77                onfocus="searchBox.OnSearchFieldFocus(true)" 
78                onblur="searchBox.OnSearchFieldFocus(false)" 
79                onkeyup="searchBox.OnSearchFieldChange(event)"/>
80           </span><span class="right">
81             <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
82           </span>
83         </div>
84 </td>
85  </tr>
86  </tbody>
87 </table>
88 </div>
89 <!-- end header part -->
90 <!-- Generated by Doxygen 1.8.11 -->
91 <script type="text/javascript">
92 var searchBox = new SearchBox("searchBox", "search",false,'Search');
93 </script>
94 </div><!-- top -->
95 <div id="side-nav" class="ui-resizable side-nav-resizable">
96   <div id="nav-tree">
97     <div id="nav-tree-contents">
98       <div id="nav-sync" class="sync"></div>
99     </div>
100   </div>
101   <div id="splitbar" style="-moz-user-select:none;" 
102        class="ui-resizable-handle">
103   </div>
104 </div>
105 <script type="text/javascript">
106 $(document).ready(function(){initNavTree('group__group-Group.html','');});
107 </script>
108 <div id="doc-content">
109 <!-- window showing the filter options -->
110 <div id="MSearchSelectWindow"
111      onmouseover="return searchBox.OnSearchSelectShow()"
112      onmouseout="return searchBox.OnSearchSelectHide()"
113      onkeydown="return searchBox.OnSearchSelectKey(event)">
114 </div>
115
116 <!-- iframe showing the search results (closed by default) -->
117 <div id="MSearchResultsWindow">
118 <iframe src="javascript:void(0)" frameborder="0" 
119         name="MSearchResults" id="MSearchResults">
120 </iframe>
121 </div>
122
123 <div class="header">
124   <div class="summary">
125 <a href="#var-members">Variables</a>  </div>
126   <div class="headertitle">
127 <div class="title">Group<div class="ingroups"><a class="el" href="group__group-concepts.html">Concepts</a></div></div>  </div>
128 </div><!--header-->
129 <div class="contents">
130 <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
131 <p>The <code>Group</code> concept represents <code>Monoid</code>s where all objects have an inverse w.r.t. the <code>Monoid</code>'s binary operation. </p>
132 <p>A <a href="http://en.wikipedia.org/wiki/Group_(mathematics)">Group</a> is an algebraic structure built on top of a <code>Monoid</code> which adds the ability to invert the action of the <code>Monoid</code>'s binary operation on any element of the set. Specifically, a <code>Group</code> is a <code>Monoid</code> <code>(S, +)</code> such that every element <code>s</code> in <code>S</code> has an inverse (say <code>s'</code>) which is such that </p><div class="fragment"><div class="line">s + s<span class="stringliteral">&#39; == s&#39;</span> + s == identity of the Monoid</div></div><!-- fragment --><p>There are many examples of <code>Group</code>s, one of which would be the additive <code>Monoid</code> on integers, where the inverse of any integer <code>n</code> is the integer <code>-n</code>. The method names used here refer to exactly this model.</p>
133 <h2>Minimal complete definitions </h2>
134 <ol type="1">
135 <li><code>minus</code><br />
136 When <code>minus</code> is specified, the <code>negate</code> method is defaulted by setting <div class="fragment"><div class="line"><a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>(x) = <a class="code" href="group__group-Group.html#ga2020c526324f361a2b990fe8d1b07c20">minus</a>(zero&lt;G&gt;(), x)</div></div><!-- fragment --></li>
137 <li><code>negate</code><br />
138 When <code>negate</code> is specified, the <code>minus</code> method is defaulted by setting <div class="fragment"><div class="line"><a class="code" href="group__group-Group.html#ga2020c526324f361a2b990fe8d1b07c20">minus</a>(x, y) = <a class="code" href="group__group-Monoid.html#gaeb5d4a1e967e319712f9e4791948896c">plus</a>(x, <a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>(y))</div></div><!-- fragment --></li>
139 </ol>
140 <h2>Laws </h2>
141 <p>For all objects <code>x</code> of a <code>Group</code> <code>G</code>, the following laws must be satisfied: </p><div class="fragment"><div class="line"><a class="code" href="group__group-Monoid.html#gaeb5d4a1e967e319712f9e4791948896c">plus</a>(x, <a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>(x)) == zero&lt;G&gt;() <span class="comment">// right inverse</span></div><div class="line"><a class="code" href="group__group-Monoid.html#gaeb5d4a1e967e319712f9e4791948896c">plus</a>(<a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>(x), x) == zero&lt;G&gt;() <span class="comment">// left inverse</span></div></div><!-- fragment --><h2>Refined concept </h2>
142 <p><code>Monoid</code></p>
143 <h2>Concrete models </h2>
144 <p><code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type. ">hana::integral_constant</a></code></p>
145 <h2>Free model for non-boolean arithmetic data types </h2>
146 <p>A data type <code>T</code> is arithmetic if <code>std::is_arithmetic&lt;T&gt;::value</code> is true. For a non-boolean arithmetic data type <code>T</code>, a model of <code>Group</code> is automatically defined by setting </p><div class="fragment"><div class="line"><a class="code" href="group__group-Group.html#ga2020c526324f361a2b990fe8d1b07c20">minus</a>(x, y) = (x - y)</div><div class="line"><a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>(x) = -x</div></div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>The rationale for not providing a Group model for <code>bool</code> is the same as for not providing a <code>Monoid</code> model.</dd></dl>
147 <h2>Structure-preserving functions </h2>
148 <p>Let <code>A</code> and <code>B</code> be two <code>Group</code>s. A function <code>f : A -&gt; B</code> is said to be a <a href="http://en.wikipedia.org/wiki/Group_homomorphism">Group morphism</a> if it preserves the group structure between <code>A</code> and <code>B</code>. Rigorously, for all objects <code>x, y</code> of data type <code>A</code>, </p><div class="fragment"><div class="line">f(<a class="code" href="group__group-Monoid.html#gaeb5d4a1e967e319712f9e4791948896c">plus</a>(x, y)) == <a class="code" href="group__group-Monoid.html#gaeb5d4a1e967e319712f9e4791948896c">plus</a>(f(x), f(y))</div></div><!-- fragment --><p> Because of the <code>Group</code> structure, it is easy to prove that the following will then also be satisfied: </p><div class="fragment"><div class="line">f(<a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>(x)) == <a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>(f(x))</div><div class="line">f(<a class="code" href="group__group-Monoid.html#gad459ac17b6bab8ead1cae7de0032f3c6">zero</a>&lt;A&gt;()) == <a class="code" href="group__group-Monoid.html#gad459ac17b6bab8ead1cae7de0032f3c6">zero</a>&lt;B&gt;()</div></div><!-- fragment --><p> Functions with these properties interact nicely with <code>Group</code>s, which is why they are given such a special treatment.</p>
149 <table class="memberdecls">
150 <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
151 Variables</h2></td></tr>
152 <tr class="memitem:ga2020c526324f361a2b990fe8d1b07c20"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Group.html#ga2020c526324f361a2b990fe8d1b07c20">boost::hana::minus</a></td></tr>
153 <tr class="memdesc:ga2020c526324f361a2b990fe8d1b07c20"><td class="mdescLeft">&#160;</td><td class="mdescRight">Subtract two elements of a group.Specifically, this performs the <code>Monoid</code> operation on the first argument and on the inverse of the second argument, thus being equivalent to:  <a href="group__group-Group.html#ga2020c526324f361a2b990fe8d1b07c20">More...</a><br /></td></tr>
154 <tr class="separator:ga2020c526324f361a2b990fe8d1b07c20"><td class="memSeparator" colspan="2">&#160;</td></tr>
155 <tr class="memitem:ga02e81002f40ba52eac4cf1974c7e0cdb"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">boost::hana::negate</a></td></tr>
156 <tr class="memdesc:ga02e81002f40ba52eac4cf1974c7e0cdb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the inverse of an element of a group.  <a href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">More...</a><br /></td></tr>
157 <tr class="separator:ga02e81002f40ba52eac4cf1974c7e0cdb"><td class="memSeparator" colspan="2">&#160;</td></tr>
158 </table>
159 <h2 class="groupheader">Variable Documentation</h2>
160 <a class="anchor" id="ga2020c526324f361a2b990fe8d1b07c20"></a>
161 <div class="memitem">
162 <div class="memproto">
163       <table class="memname">
164         <tr>
165           <td class="memname">constexpr auto boost::hana::minus</td>
166         </tr>
167       </table>
168 </div><div class="memdoc">
169
170 <p><code>#include &lt;<a class="el" href="fwd_2minus_8hpp.html">boost/hana/fwd/minus.hpp</a>&gt;</code></p>
171 <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x, <span class="keyword">auto</span>&amp;&amp; y) -&gt; decltype(<span class="keyword">auto</span>) {</div><div class="line">        <span class="keywordflow">return</span> tag-dispatched;</div><div class="line">    }</div></div><!-- fragment -->
172 <p>Subtract two elements of a group.Specifically, this performs the <code>Monoid</code> operation on the first argument and on the inverse of the second argument, thus being equivalent to: </p>
173 <div class="fragment"><div class="line"><a class="code" href="group__group-Group.html#ga2020c526324f361a2b990fe8d1b07c20">minus</a>(x, y) == <a class="code" href="group__group-Monoid.html#gaeb5d4a1e967e319712f9e4791948896c">plus</a>(x, <a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">negate</a>(y))</div></div><!-- fragment --><h2>Cross-type version of the method </h2>
174 <p>The <code>minus</code> method is "overloaded" to handle distinct data types with certain properties. Specifically, <code>minus</code> is defined for <em>distinct</em> data types <code>A</code> and <code>B</code> such that</p><ol type="1">
175 <li><code>A</code> and <code>B</code> share a common data type <code>C</code>, as determined by the <code>common</code> metafunction</li>
176 <li><code>A</code>, <code>B</code> and <code>C</code> are all <code>Group</code>s when taken individually</li>
177 <li><code>to&lt;C&gt; : A -&gt; B</code> and <code>to&lt;C&gt; : B -&gt; C</code> are <code>Group</code>-embeddings, as determined by the <code>is_embedding</code> metafunction.</li>
178 </ol>
179 <p>The definition of <code>minus</code> for data types satisfying the above properties is obtained by setting </p><div class="fragment"><div class="line"><a class="code" href="group__group-Group.html#ga2020c526324f361a2b990fe8d1b07c20">minus</a>(x, y) = <a class="code" href="group__group-Group.html#ga2020c526324f361a2b990fe8d1b07c20">minus</a>(to&lt;C&gt;(x), to&lt;C&gt;(y))</div></div><!-- fragment --><h2>Example </h2>
180 <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="minus_8hpp.html">boost/hana/minus.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line">    <a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Group.html#ga2020c526324f361a2b990fe8d1b07c20">hana::minus</a>(hana::int_c&lt;3&gt;, hana::int_c&lt;5&gt;) == hana::int_c&lt;-2&gt;);</div><div class="line">    static_assert(<a class="code" href="group__group-Group.html#ga2020c526324f361a2b990fe8d1b07c20">hana::minus</a>(1, 2) == -1, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">}</div></div><!-- fragment --> 
181 </div>
182 </div>
183 <a class="anchor" id="ga02e81002f40ba52eac4cf1974c7e0cdb"></a>
184 <div class="memitem">
185 <div class="memproto">
186       <table class="memname">
187         <tr>
188           <td class="memname">constexpr auto boost::hana::negate</td>
189         </tr>
190       </table>
191 </div><div class="memdoc">
192
193 <p><code>#include &lt;<a class="el" href="fwd_2negate_8hpp.html">boost/hana/fwd/negate.hpp</a>&gt;</code></p>
194 <b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x) -&gt; decltype(<span class="keyword">auto</span>) {</div><div class="line">        <span class="keywordflow">return</span> tag-dispatched;</div><div class="line">    }</div></div><!-- fragment -->
195 <p>Return the inverse of an element of a group. </p>
196 <h2>Example </h2>
197 <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="negate_8hpp.html">boost/hana/negate.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line">    <a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">hana::negate</a>(hana::int_c&lt;3&gt;) == hana::int_c&lt;-3&gt;);</div><div class="line">    static_assert(<a class="code" href="group__group-Group.html#ga02e81002f40ba52eac4cf1974c7e0cdb">hana::negate</a>(2) == -2, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">}</div></div><!-- fragment --> 
198 </div>
199 </div>
200 </div><!-- contents -->
201 </div><!-- doc-content -->
202 <!--
203 Copyright Louis Dionne 2013-2017
204 Distributed under the Boost Software License, Version 1.0.
205 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
206 -->
207 <!-- boost-no-inspect -->
208 <!-- HTML footer for doxygen 1.8.9.1-->
209 <!-- start footer part -->
210 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
211   <ul>
212   </ul>
213 </div>
214 </body>
215 </html>