/usr/share/doc/libntl-dev/NTL/GF2.cpp.html is in libntl-dev 6.2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | <!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>/Volumes/Unix/unix-files.noindex/ntl-new/ntl-6.1.0/doc/GF2.cpp.html</title>
<meta name="Generator" content="Vim/7.3">
<meta name="plugin-version" content="vim7.3_v6">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css">
<style type="text/css">
<!--
pre { font-family: monospace; color: #000000; background-color: #ffffff; }
body { font-family: monospace; color: #000000; background-color: #ffffff; }
.Statement { color: #b03060; font-weight: bold; }
.Type { color: #008b00; font-weight: bold; }
.String { color: #4a708b; }
.PreProc { color: #1874cd; }
.Comment { color: #0000ee; font-style: italic; }
-->
</style>
</head>
<body>
<pre>
<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> swap(GF2& x, GF2& y);
<span class="Comment">// swap x and y </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>
|