/usr/share/doc/libntl-dev/NTL/GF2.cpp.html is in libntl-dev 9.9.1-3.
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 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>/Volumes/unix-files/u/ntl-new/ntl-9.9.0dev/doc/GF2.cpp.html</title>
<meta name="Generator" content="Vim/7.1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000"><font face="monospace">
<br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i>MODULE: GF2</i></font><br>
<br>
<font color="#0000ed"><i>SUMMARY:</i></font><br>
<br>
<font color="#0000ed"><i>The class GF2 represents the field GF(2).</i></font><br>
<font color="#0000ed"><i>Computationally speaking, it is not a particularly useful class.</i></font><br>
<font color="#0000ed"><i>Its main use is to make the interfaces to the various finite </i></font><br>
<font color="#0000ed"><i>field classes as uniform as possible.</i></font><br>
<br>
<font color="#0000ed"><i>The header file for GF2 also declares the class ref_GF2, which</i></font><br>
<font color="#0000ed"><i>use used to represent non-const references to GF2's, such as</i></font><br>
<font color="#0000ed"><i>those obtained from indexing a vec_GF2, which "packs" GF2's</i></font><br>
<font color="#0000ed"><i>into words.</i></font><br>
<br>
<font color="#0000ed"><i>There are implicit conversions from ref_GF2 to const GF2</i></font><br>
<font color="#0000ed"><i>and from GF2& to ref_GF2. Therefore, if you want to declare</i></font><br>
<font color="#0000ed"><i>a function that takes a non-const reference to a GF2, you</i></font><br>
<font color="#0000ed"><i>should declare the parameter of type ref_GF2: this will</i></font><br>
<font color="#0000ed"><i>allow you to pass variables of type GF2 as well as </i></font><br>
<font color="#0000ed"><i>elements of vec_GF2's obtained through indexing.</i></font><br>
<br>
<font color="#0000ed"><i>For all functions defined below which take a parameter of type</i></font><br>
<font color="#0000ed"><i>GF2&, there is also a function that takes a parameter of type ref_GF2.</i></font><br>
<font color="#0000ed"><i>Theoretically, we could have just defined the functions that take</i></font><br>
<font color="#0000ed"><i>the ref_GF2 parameter type, because of the implicit conversion</i></font><br>
<font color="#0000ed"><i>from GF2& to ref_GF2; however, for efficiency reasons, both</i></font><br>
<font color="#0000ed"><i>flavors are actually provided. It is recommended that higher-level</i></font><br>
<font color="#0000ed"><i>functions use the ref_GF2 type exclusively.</i></font><br>
<br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<font color="#1773cc">#include </font><font color="#4a6f8b"><NTL/ZZ.h></font><br>
<font color="#1773cc">#include </font><font color="#4a6f8b"><NTL/vector.h></font><br>
<br>
<br>
<font color="#008b00"><b>class</b></font> GF2 {<br>
<font color="#b02f60"><b>public</b></font>:<br>
<br>
GF2(); <font color="#0000ed"><i>// initial value 0</i></font><br>
<br>
GF2(<font color="#008b00"><b>const</b></font> GF2& a); <font color="#0000ed"><i>// copy constructor</i></font><br>
<font color="#008b00"><b>explicit</b></font> GF2(<font color="#008b00"><b>long</b></font> a); <font color="#0000ed"><i>// promotion constructor</i></font><br>
<br>
GF2& <font color="#b02f60"><b>operator</b></font>=(<font color="#008b00"><b>const</b></font> GF2& a); <font color="#0000ed"><i>// assignment</i></font><br>
GF2& <font color="#b02f60"><b>operator</b></font>=(<font color="#008b00"><b>long</b></font> a); <font color="#0000ed"><i>// assignment</i></font><br>
<br>
<font color="#0000ed"><i>// typedefs to aid in generic programming</i></font><br>
<font color="#008b00"><b>typedef</b></font> <font color="#008b00"><b>long</b></font> rep_type;<br>
<font color="#008b00"><b>typedef</b></font> GF2Context context_type;<br>
<font color="#008b00"><b>typedef</b></font> GF2Bak bak_type;<br>
<font color="#008b00"><b>typedef</b></font> GF2Push push_type;<br>
<font color="#008b00"><b>typedef</b></font> GF2X poly_type;<br>
<br>
};<br>
<br>
<br>
<font color="#008b00"><b>long</b></font> rep(GF2 a); <font color="#0000ed"><i>// read-only access to representation of a</i></font><br>
<br>
<br>
<br>
<br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i> Comparison</i></font><br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<br>
<font color="#008b00"><b>long</b></font> <font color="#b02f60"><b>operator</b></font>==(GF2 a, GF2 b);<br>
<font color="#008b00"><b>long</b></font> <font color="#b02f60"><b>operator</b></font>!=(GF2 a, GF2 b);<br>
<br>
<font color="#008b00"><b>long</b></font> IsZero(GF2 a); <font color="#0000ed"><i>// test for 0</i></font><br>
<font color="#008b00"><b>long</b></font> IsOne(GF2 a); <font color="#0000ed"><i>// test for 1</i></font><br>
<br>
<font color="#0000ed"><i>// PROMOTIONS: operators ==, != promote long to GF2 on (a, b).</i></font><br>
<br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i> Addition </i></font><br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<font color="#0000ed"><i>// operator notation:</i></font><br>
<br>
GF2 <font color="#b02f60"><b>operator</b></font>+(GF2 a, GF2 b);<br>
GF2 <font color="#b02f60"><b>operator</b></font>-(GF2 a, GF2 b);<br>
<br>
GF2 <font color="#b02f60"><b>operator</b></font>-(GF2 a); <font color="#0000ed"><i>// unary -</i></font><br>
<br>
GF2& <font color="#b02f60"><b>operator</b></font>+=(GF2& x, GF2 a);<br>
GF2& <font color="#b02f60"><b>operator</b></font>+=(GF2& x, <font color="#008b00"><b>long</b></font> a);<br>
<br>
GF2& <font color="#b02f60"><b>operator</b></font>-=(GF2& x, GF2 a);<br>
GF2& <font color="#b02f60"><b>operator</b></font>-=(GF2& x, <font color="#008b00"><b>long</b></font> a);<br>
<br>
GF2& <font color="#b02f60"><b>operator</b></font>++(GF2& x); <font color="#0000ed"><i>// prefix</i></font><br>
<font color="#008b00"><b>void</b></font> <font color="#b02f60"><b>operator</b></font>++(GF2& x, <font color="#008b00"><b>int</b></font>); <font color="#0000ed"><i>// postfix</i></font><br>
<br>
GF2& <font color="#b02f60"><b>operator</b></font>--(GF2& x); <font color="#0000ed"><i>// prefix</i></font><br>
<font color="#008b00"><b>void</b></font> <font color="#b02f60"><b>operator</b></font>--(GF2& x, <font color="#008b00"><b>int</b></font>); <font color="#0000ed"><i>// postfix</i></font><br>
<br>
<font color="#0000ed"><i>// procedural versions:</i></font><br>
<br>
<br>
<font color="#008b00"><b>void</b></font> add(GF2& x, GF2 a, GF2 b); <font color="#0000ed"><i>// x = a + b</i></font><br>
<font color="#008b00"><b>void</b></font> sub(GF2& x, GF2 a, GF2 b); <font color="#0000ed"><i>// x = a - b </i></font><br>
<font color="#008b00"><b>void</b></font> negate(GF2& x, GF2 a); <font color="#0000ed"><i>// x = -a</i></font><br>
<br>
<font color="#0000ed"><i>// PROMOTIONS: binary +, -, and procedures add, sub promote</i></font><br>
<font color="#0000ed"><i>// from long to GF2 on (a, b).</i></font><br>
<br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i> Multiplication </i></font><br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<font color="#0000ed"><i>// operator notation:</i></font><br>
<br>
GF2 <font color="#b02f60"><b>operator</b></font>*(GF2 a, GF2 b);<br>
<br>
GF2& <font color="#b02f60"><b>operator</b></font>*=(GF2& x, GF2 a);<br>
GF2& <font color="#b02f60"><b>operator</b></font>*=(GF2& x, <font color="#008b00"><b>long</b></font> a);<br>
<br>
<font color="#0000ed"><i>// procedural versions:</i></font><br>
<br>
<font color="#008b00"><b>void</b></font> mul(GF2& x, GF2 a, GF2 b); <font color="#0000ed"><i>// x = a * b</i></font><br>
<br>
<font color="#008b00"><b>void</b></font> sqr(GF2& x, GF2 a); <font color="#0000ed"><i>// x = a^2</i></font><br>
GF2 sqr(GF2 a); <br>
<br>
<font color="#0000ed"><i>// PROMOTIONS: operator * and procedure mul promote from long to GF2</i></font><br>
<font color="#0000ed"><i>// on (a, b).</i></font><br>
<br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i> Division</i></font><br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<font color="#b02f60"><b>operator</b></font> notation:<br>
<br>
GF2 <font color="#b02f60"><b>operator</b></font>/(z_p a, GF2 b);<br>
<br>
GF2& <font color="#b02f60"><b>operator</b></font>/=(GF2& x, GF2 a);<br>
GF2& <font color="#b02f60"><b>operator</b></font>/=(GF2& x, <font color="#008b00"><b>long</b></font> a);<br>
<br>
procedural versions:<br>
<br>
<font color="#008b00"><b>void</b></font> div(GF2& x, GF2 a, GF2 b);<br>
<font color="#0000ed"><i>// x = a/b</i></font><br>
<br>
<font color="#008b00"><b>void</b></font> inv(GF2& x, GF2 a);<br>
GF2 inv(GF2 a);<br>
<font color="#0000ed"><i>// x = 1/a</i></font><br>
<br>
<font color="#0000ed"><i>// PROMOTIONS: operator / and procedure div promote from long to GF2</i></font><br>
<font color="#0000ed"><i>// on (a, b).</i></font><br>
<br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i> Exponentiation</i></font><br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<br>
<font color="#008b00"><b>void</b></font> power(GF2& x, GF2 a, <font color="#008b00"><b>long</b></font> e); <font color="#0000ed"><i>// x = a^e (e may be negative)</i></font><br>
GF2 power(GF2 a, <font color="#008b00"><b>long</b></font> e); <br>
<br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i> Random Elements</i></font><br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<br>
<font color="#008b00"><b>void</b></font> random(GF2& x);<br>
GF2 random_GF2();<br>
<font color="#0000ed"><i>// x = random element in GF2. Uses RandomBnd from ZZ.</i></font><br>
<br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i> Input/Output</i></font><br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<br>
ostream& <font color="#b02f60"><b>operator</b></font><<(ostream& s, GF2 a);<br>
<br>
istream& <font color="#b02f60"><b>operator</b></font>>>(istream& s, GF2& x);<br>
<font color="#0000ed"><i>// a ZZ is read and reduced mod 2</i></font><br>
<br>
<br>
<font color="#0000ed"><i>/*</i></font><font color="#0000ed"><i>*************************************************************************\</i></font><br>
<br>
<font color="#0000ed"><i> Miscellany</i></font><br>
<br>
<font color="#0000ed"><i>\*************************************************************************</i></font><font color="#0000ed"><i>*/</i></font><br>
<br>
<br>
<font color="#008b00"><b>void</b></font> clear(GF2& x); <font color="#0000ed"><i>// x = 0</i></font><br>
<font color="#008b00"><b>void</b></font> set(GF2& x); <font color="#0000ed"><i>// x = 1</i></font><br>
<br>
<font color="#008b00"><b>void</b></font> GF2::swap(GF2& x);<br>
<font color="#008b00"><b>void</b></font> swap(GF2& x, GF2& y);<br>
<font color="#0000ed"><i>// swap </i></font><br>
<br>
<font color="#008b00"><b>static</b></font> GF2 GF2::zero();<br>
<font color="#0000ed"><i>// GF2::zero() yields a read-only reference to zero</i></font><br>
<br>
<font color="#008b00"><b>static</b></font> <font color="#008b00"><b>long</b></font> GF2::modulus();<br>
<font color="#0000ed"><i>// GF2::modulus() returns the value 2</i></font><br>
<br>
<font color="#008b00"><b>template</b></font><> <font color="#008b00"><b>class</b></font> Vec<GF2>;<br>
<font color="#0000ed"><i>// Forward declaration of the explicit specialization</i></font><br>
<font color="#0000ed"><i>// of Vec<GF2>. This specialization is defined in <NTL/vec_GF2.h>,</i></font><br>
<font color="#0000ed"><i>// which must be included in source files that need to use Vec<GF2>.</i></font><br>
<br>
GF2::GF2(INIT_NO_ALLOC_TYPE);<br>
<font color="#0000ed"><i>// provided for consistency with other classes, initialize to zero</i></font><br>
<br>
GF2::GF2(INIT_ALLOC_TYPE);<br>
<font color="#0000ed"><i>// provided for consistency with other classes, initialize to zero</i></font><br>
<br>
GF2::allocate();<br>
<font color="#0000ed"><i>// provided for consistency with other classes, no action</i></font><br>
<br>
<br>
<br>
</font></body>
</html>
|