source: git/ntl/doc/GF2.txt @ 199b5c

fieker-DuValspielwiese
Last change on this file since 199b5c was 2cfffe, checked in by Hans Schönemann <hannes@…>, 22 years ago
This commit was generated by cvs2svn to compensate for changes in r6316, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@6317 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 4.2 KB
Line 
1
2
3/**************************************************************************\
4
5MODULE: GF2
6
7SUMMARY:
8
9The class GF2 represents the field GF(2).
10Computationally speaking, it is not a particularly useful class.
11Its main use is to make the interfaces to the various finite
12field classes as uniform as possible.
13
14\**************************************************************************/
15
16#include <NTL/ZZ.h>
17
18
19class GF2 {
20public:
21   
22   GF2(); // initial value 0
23
24   GF2(const GF2& a); // copy constructor
25
26   GF2& operator=(const GF2& a); // assignment
27   GF2& operator=(long a); // assignment
28
29};
30
31
32long rep(GF2 a); // read-only access to representation of a
33
34
35
36
37
38/**************************************************************************\
39
40                                  Comparison
41
42\**************************************************************************/
43
44
45long operator==(GF2 a, GF2 b);
46long operator!=(GF2 a, GF2 b);
47
48long IsZero(GF2 a);  // test for 0
49long IsOne(GF2 a);  // test for 1
50
51// PROMOTIONS: operators ==, != promote long to GF2 on (a, b).
52
53
54/**************************************************************************\
55
56                                    Addition
57
58\**************************************************************************/
59
60// operator notation:
61
62GF2 operator+(GF2 a, GF2 b);
63GF2 operator-(GF2 a, GF2 b);
64
65GF2 operator-(GF2 a); // unary -
66
67GF2& operator+=(GF2& x, GF2 a);
68GF2& operator+=(GF2& x, long a);
69
70GF2& operator-=(GF2& x, GF2 a);
71GF2& operator-=(GF2& x, long a);
72
73GF2& operator++(GF2& x);  // prefix
74void operator++(GF2& x, int);  // postfix
75
76GF2& operator--(GF2& x);  // prefix
77void operator--(GF2& x, int);  // postfix
78
79// procedural versions:
80
81
82void add(GF2& x, GF2 a, GF2 b); // x = a + b
83void sub(GF2& x, GF2 a, GF2 b); // x = a - b
84void negate(GF2& x, GF2 a); // x = -a
85
86// PROMOTIONS: binary +, -, and procedures add, sub promote
87// from long to GF2 on (a, b).
88
89
90/**************************************************************************\
91
92                                  Multiplication
93
94\**************************************************************************/
95
96// operator notation:
97
98GF2 operator*(GF2 a, GF2 b);
99
100GF2& operator*=(GF2& x, GF2 a);
101GF2& operator*=(GF2& x, long a);
102
103// procedural versions:
104
105void mul(GF2& x, GF2 a, GF2 b); // x = a * b
106
107void sqr(GF2& x, GF2 a); // x = a^2
108GF2 sqr(GF2 a);
109
110// PROMOTIONS: operator * and procedure mul promote from long to GF2
111// on (a, b).
112
113
114/**************************************************************************\
115
116                                  Division
117
118\**************************************************************************/
119
120operator notation:
121
122GF2 operator/(z_p a, GF2 b);
123
124GF2& operator/=(GF2& x, GF2 a);
125GF2& operator/=(GF2& x, long a);
126
127procedural versions:
128
129void div(GF2& x, GF2 a, GF2 b);
130// x = a/b
131
132void inv(GF2& x, GF2 a);
133GF2 inv(GF2 a);
134// x = 1/a
135
136// PROMOTIONS: operator / and procedure div promote from long to GF2
137// on (a, b).
138
139
140/**************************************************************************\
141
142                                  Exponentiation
143
144\**************************************************************************/
145
146
147void power(GF2& x, GF2 a, long e); // x = a^e (e may be negative)
148GF2 power(GF2 a, long e);
149
150
151/**************************************************************************\
152
153                               Random Elements
154
155\**************************************************************************/
156
157
158void random(GF2& x);
159GF2 random_GF2();
160// x = random element in GF2.  Uses RandomBnd from ZZ.
161
162
163/**************************************************************************\
164
165                                Input/Output
166
167\**************************************************************************/
168
169
170ostream& operator<<(ostream& s, GF2 a);
171
172istream& operator>>(istream& s, GF2& x);
173// a ZZ is read and reduced mod 2
174
175
176/**************************************************************************\
177
178                               Miscellany
179
180\**************************************************************************/
181
182
183void clear(GF2& x); // x = 0
184void set(GF2& x); // x = 1
185
186static GF2 GF2::zero();
187// GF2::zero() yields a read-only reference to zero
188
189void swap(GF2& x, GF2& y);
190// swap x and y
191
Note: See TracBrowser for help on using the repository browser.