source: git/ntl/include/NTL/mat_GF2.h @ 92c0ac

spielwiese
Last change on this file since 92c0ac was 92c0ac, checked in by Hans Schönemann <hannes@…>, 21 years ago
NTL-5.2 git-svn-id: file:///usr/local/Singular/svn/trunk@6320 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.7 KB
Line 
1
2#ifndef NTL_mat_GF2__H
3#define NTL_mat_GF2__H
4
5
6#include <NTL/vec_vec_GF2.h>
7
8NTL_OPEN_NNS
9
10
11class mat_GF2 { 
12public: 
13 
14   vec_vec_GF2 _mat_GF2__rep; 
15   long _mat_GF2__numcols; 
16 
17   mat_GF2() { _mat_GF2__numcols = 0; } 
18   mat_GF2(const mat_GF2& a); 
19   mat_GF2& operator=(const mat_GF2& a); 
20   ~mat_GF2() { } 
21 
22   mat_GF2(INIT_SIZE_TYPE, long n, long m); 
23 
24   void kill(); 
25 
26   void SetDims(long n, long m); 
27 
28   long NumRows() const { return _mat_GF2__rep.length(); } 
29   long NumCols() const { return _mat_GF2__numcols; } 
30 
31   vec_GF2& operator[](long i) { return _mat_GF2__rep[i]; } 
32   const vec_GF2& operator[](long i) const { return _mat_GF2__rep[i]; } 
33 
34   vec_GF2& operator()(long i) { return _mat_GF2__rep[i-1]; } 
35   const vec_GF2& operator()(long i) const { return _mat_GF2__rep[i-1]; } 
36
37   GF2 get(long i, long j) const { return _mat_GF2__rep[i].get(j); }
38   void put(long i, long j, GF2 a) { _mat_GF2__rep[i].put(j, a); }
39   void put(long i, long j, long a) { _mat_GF2__rep[i].put(j, a); }
40
41   subscript_GF2 operator()(long i, long j)
42      { return subscript_GF2(_mat_GF2__rep[i-1], j-1); }
43
44   const_subscript_GF2 operator()(long i, long j) const
45      { return const_subscript_GF2(_mat_GF2__rep[i-1], j-1); }
46
47   long position(const vec_GF2& a) const { return _mat_GF2__rep.position(a); }
48 
49   mat_GF2(mat_GF2& x, INIT_TRANS_TYPE)  :
50      _mat_GF2__rep(x._mat_GF2__rep, INIT_TRANS), _mat_GF2__numcols(x._mat_GF2__numcols) { }
51}; 
52 
53inline const vec_vec_GF2& _mat_GF2__rep(const mat_GF2& a) 
54   { return a._mat_GF2__rep; } 
55
56 
57void swap(mat_GF2& X, mat_GF2& Y); 
58 
59void conv(mat_GF2& x, const vec_vec_GF2& a); 
60inline mat_GF2 to_mat_GF2(const vec_vec_GF2& a)
61   { mat_GF2 x; conv(x, a); NTL_OPT_RETURN(mat_GF2, x); }
62
63
64
65long operator==(const mat_GF2& a, const mat_GF2& b); 
66long operator!=(const mat_GF2& a, const mat_GF2& b); 
67
68
69NTL_SNS istream& operator>>(NTL_SNS istream&, mat_GF2&); 
70NTL_SNS ostream& operator<<(NTL_SNS ostream&, const mat_GF2&); 
71
72
73
74void add(mat_GF2& X, const mat_GF2& A, const mat_GF2& B); 
75
76inline void sub(mat_GF2& X, const mat_GF2& A, const mat_GF2& B)
77   { add(X, A, B); }
78
79inline void negate(mat_GF2& X, const mat_GF2& A)
80   { X = A; }
81
82void mul(mat_GF2& X, const mat_GF2& A, const mat_GF2& B); 
83void mul(vec_GF2& x, const mat_GF2& A, const vec_GF2& b); 
84void mul(vec_GF2& x, const vec_GF2& a, const mat_GF2& B); 
85
86void mul(mat_GF2& X, const mat_GF2& A, GF2 b);
87inline void mul(mat_GF2& X, GF2 a, const mat_GF2& B)
88   { mul(X, B, a); }
89
90inline void mul(mat_GF2& X, const mat_GF2& A, long b)
91   { mul(X, A, to_GF2(b)); }
92inline void mul(mat_GF2& X, long a, const mat_GF2& B)
93   { mul(X, B, a); }
94
95void ident(mat_GF2& X, long n); 
96inline mat_GF2 ident_mat_GF2(long n)
97   { mat_GF2 X; ident(X, n); NTL_OPT_RETURN(mat_GF2, X); }
98
99long IsIdent(const mat_GF2& A, long n);
100void transpose(mat_GF2& X, const mat_GF2& A);
101void solve(GF2& d, vec_GF2& X, const mat_GF2& A, const vec_GF2& b);
102void inv(GF2& d, mat_GF2& X, const mat_GF2& A);
103
104inline void sqr(mat_GF2& X, const mat_GF2& A)
105   { mul(X, A, A); }
106
107inline mat_GF2 sqr(const mat_GF2& A)
108   { mat_GF2 X; sqr(X, A); NTL_OPT_RETURN(mat_GF2, X); }
109
110void inv(mat_GF2& X, const mat_GF2& A);
111
112inline mat_GF2 inv(const mat_GF2& A)
113   { mat_GF2 X; inv(X, A); NTL_OPT_RETURN(mat_GF2, X); }
114
115void power(mat_GF2& X, const mat_GF2& A, const ZZ& e);
116inline mat_GF2 power(const mat_GF2& A, const ZZ& e)
117   { mat_GF2 X; power(X, A, e); NTL_OPT_RETURN(mat_GF2, X); }
118
119inline void power(mat_GF2& X, const mat_GF2& A, long e)
120   { power(X, A, ZZ_expo(e)); }
121inline mat_GF2 power(const mat_GF2& A, long e)
122   { mat_GF2 X; power(X, A, e); NTL_OPT_RETURN(mat_GF2, X); }
123
124
125void diag(mat_GF2& X, long n, GF2 d);
126inline mat_GF2 diag(long n, GF2 d)
127   { mat_GF2 X; diag(X, n, d); NTL_OPT_RETURN(mat_GF2, X); }
128
129long IsDiag(const mat_GF2& A, long n, GF2 d);
130
131
132long gauss(mat_GF2& M);
133long gauss(mat_GF2& M, long w);
134void image(mat_GF2& X, const mat_GF2& A);
135void kernel(mat_GF2& X, const mat_GF2& A);
136
137
138
139
140void determinant(GF2& x, const mat_GF2& a);
141inline GF2 determinant(const mat_GF2& a)
142   { GF2 x; determinant(x, a); return x; }
143
144inline mat_GF2 transpose(const mat_GF2 & a)
145   { mat_GF2 x; transpose(x, a); NTL_OPT_RETURN(mat_GF2, x); }
146
147
148void clear(mat_GF2& a);
149// x = 0 (dimension unchanged)
150
151long IsZero(const mat_GF2& a);
152// test if a is the zero matrix (any dimension)
153
154
155// operator notation:
156
157mat_GF2 operator+(const mat_GF2& a, const mat_GF2& b);
158mat_GF2 operator-(const mat_GF2& a, const mat_GF2& b);
159mat_GF2 operator*(const mat_GF2& a, const mat_GF2& b);
160
161inline mat_GF2 operator-(const mat_GF2& a)
162   { return a; }
163
164
165// matrix/scalar multiplication:
166
167inline mat_GF2 operator*(const mat_GF2& a, GF2 b)
168   { mat_GF2 x; mul(x, a, b); NTL_OPT_RETURN(mat_GF2, x); }
169
170inline mat_GF2 operator*(const mat_GF2& a, long b)
171   { mat_GF2 x; mul(x, a, b); NTL_OPT_RETURN(mat_GF2, x); }
172
173inline mat_GF2 operator*(GF2 a, const mat_GF2& b)
174   { mat_GF2 x; mul(x, a, b); NTL_OPT_RETURN(mat_GF2, x); }
175
176inline mat_GF2 operator*(long a, const mat_GF2& b)
177   { mat_GF2 x; mul(x, a, b); NTL_OPT_RETURN(mat_GF2, x); }
178
179
180
181
182// matrix/vector multiplication:
183
184vec_GF2 operator*(const mat_GF2& a, const vec_GF2& b);
185
186vec_GF2 operator*(const vec_GF2& a, const mat_GF2& b);
187
188
189// assignment operator notation:
190
191inline mat_GF2& operator+=(mat_GF2& x, const mat_GF2& a)
192{
193   add(x, x, a);
194   return x;
195}   
196
197inline mat_GF2& operator-=(mat_GF2& x, const mat_GF2& a)
198{
199   sub(x, x, a);
200   return x;
201}   
202
203
204inline mat_GF2& operator*=(mat_GF2& x, const mat_GF2& a)
205{
206   mul(x, x, a);
207   return x;
208}   
209
210inline mat_GF2& operator*=(mat_GF2& x, GF2 a)
211{
212   mul(x, x, a);
213   return x;
214}   
215
216inline mat_GF2& operator*=(mat_GF2& x, long a)
217{
218   mul(x, x, a);
219   return x;
220}   
221   
222
223inline vec_GF2& operator*=(vec_GF2& x, const mat_GF2& a)
224{
225   mul(x, x, a);
226   return x;
227}   
228
229
230NTL_CLOSE_NNS
231
232#endif
Note: See TracBrowser for help on using the repository browser.