<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>~/ntl-10.5.0test/doc/GF2.cpp.html</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="macvim">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #ffffff; }
body { font-family: monospace; color: #000000; background-color: #ffffff; }
* { font-size: 1em; }
.String { color: #4a708b; }
.PreProc { color: #1874cd; }
.Statement { color: #b03060; font-weight: bold; }
.Comment { color: #0000ee; font-style: italic; }
.Type { color: #008b00; font-weight: bold; }
-->
</style>
<script type='text/javascript'>
<!--
-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment">MODULE: GF2</span>
<span class="Comment">SUMMARY:</span>
<span class="Comment">The class GF2 represents the field GF(2).</span>
<span class="Comment">Computationally speaking, it is not a particularly useful class.</span>
<span class="Comment">Its main use is to make the interfaces to the various finite </span>
<span class="Comment">field classes as uniform as possible.</span>
<span class="Comment">The header file for GF2 also declares the class ref_GF2, which</span>
<span class="Comment">use used to represent non-const references to GF2's, such as</span>
<span class="Comment">those obtained from indexing a vec_GF2, which "packs" GF2's</span>
<span class="Comment">into words.</span>
<span class="Comment">There are implicit conversions from ref_GF2 to const GF2</span>
<span class="Comment">and from GF2& to ref_GF2. Therefore, if you want to declare</span>
<span class="Comment">a function that takes a non-const reference to a GF2, you</span>
<span class="Comment">should declare the parameter of type ref_GF2: this will</span>
<span class="Comment">allow you to pass variables of type GF2 as well as </span>
<span class="Comment">elements of vec_GF2's obtained through indexing.</span>
<span class="Comment">For all functions defined below which take a parameter of type</span>
<span class="Comment">GF2&, there is also a function that takes a parameter of type ref_GF2.</span>
<span class="Comment">Theoretically, we could have just defined the functions that take</span>
<span class="Comment">the ref_GF2 parameter type, because of the implicit conversion</span>
<span class="Comment">from GF2& to ref_GF2; however, for efficiency reasons, both</span>
<span class="Comment">flavors are actually provided. It is recommended that higher-level</span>
<span class="Comment">functions use the ref_GF2 type exclusively.</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
<span class="PreProc">#include </span><span class="String"><NTL/ZZ.h></span>
<span class="PreProc">#include </span><span class="String"><NTL/vector.h></span>
<span class="Type">class</span> GF2 {
<span class="Statement">public</span>:
GF2(); <span class="Comment">// initial value 0</span>
GF2(<span class="Type">const</span> GF2& a); <span class="Comment">// copy constructor</span>
<span class="Type">explicit</span> GF2(<span class="Type">long</span> a); <span class="Comment">// promotion constructor</span>
GF2& <span class="Statement">operator</span>=(<span class="Type">const</span> GF2& a); <span class="Comment">// assignment</span>
GF2& <span class="Statement">operator</span>=(<span class="Type">long</span> a); <span class="Comment">// assignment</span>
<span class="Comment">// typedefs to aid in generic programming</span>
<span class="Type">typedef</span> <span class="Type">long</span> rep_type;
<span class="Type">typedef</span> GF2Context context_type;
<span class="Type">typedef</span> GF2Bak bak_type;
<span class="Type">typedef</span> GF2Push push_type;
<span class="Type">typedef</span> GF2X poly_type;
};
<span class="Type">long</span> rep(GF2 a); <span class="Comment">// read-only access to representation of a</span>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Comparison</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
<span class="Type">long</span> <span class="Statement">operator</span>==(GF2 a, GF2 b);
<span class="Type">long</span> <span class="Statement">operator</span>!=(GF2 a, GF2 b);
<span class="Type">long</span> IsZero(GF2 a); <span class="Comment">// test for 0</span>
<span class="Type">long</span> IsOne(GF2 a); <span class="Comment">// test for 1</span>
<span class="Comment">// PROMOTIONS: operators ==, != promote long to GF2 on (a, b).</span>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Addition </span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
<span class="Comment">// operator notation:</span>
GF2 <span class="Statement">operator</span>+(GF2 a, GF2 b);
GF2 <span class="Statement">operator</span>-(GF2 a, GF2 b);
GF2 <span class="Statement">operator</span>-(GF2 a); <span class="Comment">// unary -</span>
GF2& <span class="Statement">operator</span>+=(GF2& x, GF2 a);
GF2& <span class="Statement">operator</span>+=(GF2& x, <span class="Type">long</span> a);
GF2& <span class="Statement">operator</span>-=(GF2& x, GF2 a);
GF2& <span class="Statement">operator</span>-=(GF2& x, <span class="Type">long</span> a);
GF2& <span class="Statement">operator</span>++(GF2& x); <span class="Comment">// prefix</span>
<span class="Type">void</span> <span class="Statement">operator</span>++(GF2& x, <span class="Type">int</span>); <span class="Comment">// postfix</span>
GF2& <span class="Statement">operator</span>--(GF2& x); <span class="Comment">// prefix</span>
<span class="Type">void</span> <span class="Statement">operator</span>--(GF2& x, <span class="Type">int</span>); <span class="Comment">// postfix</span>
<span class="Comment">// procedural versions:</span>
<span class="Type">void</span> add(GF2& x, GF2 a, GF2 b); <span class="Comment">// x = a + b</span>
<span class="Type">void</span> sub(GF2& x, GF2 a, GF2 b); <span class="Comment">// x = a - b </span>
<span class="Type">void</span> negate(GF2& x, GF2 a); <span class="Comment">// x = -a</span>
<span class="Comment">// PROMOTIONS: binary +, -, and procedures add, sub promote</span>
<span class="Comment">// from long to GF2 on (a, b).</span>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Multiplication </span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
<span class="Comment">// operator notation:</span>
GF2 <span class="Statement">operator</span>*(GF2 a, GF2 b);
GF2& <span class="Statement">operator</span>*=(GF2& x, GF2 a);
GF2& <span class="Statement">operator</span>*=(GF2& x, <span class="Type">long</span> a);
<span class="Comment">// procedural versions:</span>
<span class="Type">void</span> mul(GF2& x, GF2 a, GF2 b); <span class="Comment">// x = a * b</span>
<span class="Type">void</span> sqr(GF2& x, GF2 a); <span class="Comment">// x = a^2</span>
GF2 sqr(GF2 a);
<span class="Comment">// PROMOTIONS: operator * and procedure mul promote from long to GF2</span>
<span class="Comment">// on (a, b).</span>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Division</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
<span class="Statement">operator</span> notation:
GF2 <span class="Statement">operator</span>/(z_p a, GF2 b);
GF2& <span class="Statement">operator</span>/=(GF2& x, GF2 a);
GF2& <span class="Statement">operator</span>/=(GF2& x, <span class="Type">long</span> a);
procedural versions:
<span class="Type">void</span> div(GF2& x, GF2 a, GF2 b);
<span class="Comment">// x = a/b</span>
<span class="Type">void</span> inv(GF2& x, GF2 a);
GF2 inv(GF2 a);
<span class="Comment">// x = 1/a</span>
<span class="Comment">// PROMOTIONS: operator / and procedure div promote from long to GF2</span>
<span class="Comment">// on (a, b).</span>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Exponentiation</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
<span class="Type">void</span> power(GF2& x, GF2 a, <span class="Type">long</span> e); <span class="Comment">// x = a^e (e may be negative)</span>
GF2 power(GF2 a, <span class="Type">long</span> e);
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Random Elements</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
<span class="Type">void</span> random(GF2& x);
GF2 random_GF2();
<span class="Comment">// x = random element in GF2. Uses RandomBnd from ZZ.</span>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Input/Output</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
ostream& <span class="Statement">operator</span><<(ostream& s, GF2 a);
istream& <span class="Statement">operator</span>>>(istream& s, GF2& x);
<span class="Comment">// a ZZ is read and reduced mod 2</span>
<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>
<span class="Comment"> Miscellany</span>
<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>
<span class="Type">void</span> clear(GF2& x); <span class="Comment">// x = 0</span>
<span class="Type">void</span> set(GF2& x); <span class="Comment">// x = 1</span>
<span class="Type">void</span> GF2::swap(GF2& x);
<span class="Type">void</span> swap(GF2& x, GF2& y);
<span class="Comment">// swap </span>
<span class="Type">static</span> GF2 GF2::zero();
<span class="Comment">// GF2::zero() yields a read-only reference to zero</span>
<span class="Type">static</span> <span class="Type">long</span> GF2::modulus();
<span class="Comment">// GF2::modulus() returns the value 2</span>
<span class="Type">template</span><> <span class="Type">class</span> Vec<GF2>;
<span class="Comment">// Forward declaration of the explicit specialization</span>
<span class="Comment">// of Vec<GF2>. This specialization is defined in <NTL/vec_GF2.h>,</span>
<span class="Comment">// which must be included in source files that need to use Vec<GF2>.</span>
GF2::GF2(INIT_NO_ALLOC_TYPE);
<span class="Comment">// provided for consistency with other classes, initialize to zero</span>
GF2::GF2(INIT_ALLOC_TYPE);
<span class="Comment">// provided for consistency with other classes, initialize to zero</span>
GF2::allocate();
<span class="Comment">// provided for consistency with other classes, no action</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->