source: git/ntl/include/NTL/mat_GF2.h @ 77902f

spielwiese
Last change on this file since 77902f was 77902f, checked in by Hans Schönemann <hannes@…>, 21 years ago
*hannes: iostream adaption git-svn-id: file:///usr/local/Singular/svn/trunk@6321 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.6 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
68void add(mat_GF2& X, const mat_GF2& A, const mat_GF2& B); 
69
70inline void sub(mat_GF2& X, const mat_GF2& A, const mat_GF2& B)
71   { add(X, A, B); }
72
73inline void negate(mat_GF2& X, const mat_GF2& A)
74   { X = A; }
75
76void mul(mat_GF2& X, const mat_GF2& A, const mat_GF2& B); 
77void mul(vec_GF2& x, const mat_GF2& A, const vec_GF2& b); 
78void mul(vec_GF2& x, const vec_GF2& a, const mat_GF2& B); 
79
80void mul(mat_GF2& X, const mat_GF2& A, GF2 b);
81inline void mul(mat_GF2& X, GF2 a, const mat_GF2& B)
82   { mul(X, B, a); }
83
84inline void mul(mat_GF2& X, const mat_GF2& A, long b)
85   { mul(X, A, to_GF2(b)); }
86inline void mul(mat_GF2& X, long a, const mat_GF2& B)
87   { mul(X, B, a); }
88
89void ident(mat_GF2& X, long n); 
90inline mat_GF2 ident_mat_GF2(long n)
91   { mat_GF2 X; ident(X, n); NTL_OPT_RETURN(mat_GF2, X); }
92
93long IsIdent(const mat_GF2& A, long n);
94void transpose(mat_GF2& X, const mat_GF2& A);
95void solve(GF2& d, vec_GF2& X, const mat_GF2& A, const vec_GF2& b);
96void inv(GF2& d, mat_GF2& X, const mat_GF2& A);
97
98inline void sqr(mat_GF2& X, const mat_GF2& A)
99   { mul(X, A, A); }
100
101inline mat_GF2 sqr(const mat_GF2& A)
102   { mat_GF2 X; sqr(X, A); NTL_OPT_RETURN(mat_GF2, X); }
103
104void inv(mat_GF2& X, const mat_GF2& A);
105
106inline mat_GF2 inv(const mat_GF2& A)
107   { mat_GF2 X; inv(X, A); NTL_OPT_RETURN(mat_GF2, X); }
108
109void power(mat_GF2& X, const mat_GF2& A, const ZZ& e);
110inline mat_GF2 power(const mat_GF2& A, const ZZ& e)
111   { mat_GF2 X; power(X, A, e); NTL_OPT_RETURN(mat_GF2, X); }
112
113inline void power(mat_GF2& X, const mat_GF2& A, long e)
114   { power(X, A, ZZ_expo(e)); }
115inline mat_GF2 power(const mat_GF2& A, long e)
116   { mat_GF2 X; power(X, A, e); NTL_OPT_RETURN(mat_GF2, X); }
117
118
119void diag(mat_GF2& X, long n, GF2 d);
120inline mat_GF2 diag(long n, GF2 d)
121   { mat_GF2 X; diag(X, n, d); NTL_OPT_RETURN(mat_GF2, X); }
122
123long IsDiag(const mat_GF2& A, long n, GF2 d);
124
125
126long gauss(mat_GF2& M);
127long gauss(mat_GF2& M, long w);
128void image(mat_GF2& X, const mat_GF2& A);
129void kernel(mat_GF2& X, const mat_GF2& A);
130
131
132
133
134void determinant(GF2& x, const mat_GF2& a);
135inline GF2 determinant(const mat_GF2& a)
136   { GF2 x; determinant(x, a); return x; }
137
138inline mat_GF2 transpose(const mat_GF2 & a)
139   { mat_GF2 x; transpose(x, a); NTL_OPT_RETURN(mat_GF2, x); }
140
141
142void clear(mat_GF2& a);
143// x = 0 (dimension unchanged)
144
145long IsZero(const mat_GF2& a);
146// test if a is the zero matrix (any dimension)
147
148
149// operator notation:
150
151mat_GF2 operator+(const mat_GF2& a, const mat_GF2& b);
152mat_GF2 operator-(const mat_GF2& a, const mat_GF2& b);
153mat_GF2 operator*(const mat_GF2& a, const mat_GF2& b);
154
155inline mat_GF2 operator-(const mat_GF2& a)
156   { return a; }
157
158
159// matrix/scalar multiplication:
160
161inline mat_GF2 operator*(const mat_GF2& a, GF2 b)
162   { mat_GF2 x; mul(x, a, b); NTL_OPT_RETURN(mat_GF2, x); }
163
164inline mat_GF2 operator*(const mat_GF2& a, long b)
165   { mat_GF2 x; mul(x, a, b); NTL_OPT_RETURN(mat_GF2, x); }
166
167inline mat_GF2 operator*(GF2 a, const mat_GF2& b)
168   { mat_GF2 x; mul(x, a, b); NTL_OPT_RETURN(mat_GF2, x); }
169
170inline mat_GF2 operator*(long a, const mat_GF2& b)
171   { mat_GF2 x; mul(x, a, b); NTL_OPT_RETURN(mat_GF2, x); }
172
173
174
175
176// matrix/vector multiplication:
177
178vec_GF2 operator*(const mat_GF2& a, const vec_GF2& b);
179
180vec_GF2 operator*(const vec_GF2& a, const mat_GF2& b);
181
182
183// assignment operator notation:
184
185inline mat_GF2& operator+=(mat_GF2& x, const mat_GF2& a)
186{
187   add(x, x, a);
188   return x;
189}   
190
191inline mat_GF2& operator-=(mat_GF2& x, const mat_GF2& a)
192{
193   sub(x, x, a);
194   return x;
195}   
196
197
198inline mat_GF2& operator*=(mat_GF2& x, const mat_GF2& a)
199{
200   mul(x, x, a);
201   return x;
202}   
203
204inline mat_GF2& operator*=(mat_GF2& x, GF2 a)
205{
206   mul(x, x, a);
207   return x;
208}   
209
210inline mat_GF2& operator*=(mat_GF2& x, long a)
211{
212   mul(x, x, a);
213   return x;
214}   
215   
216
217inline vec_GF2& operator*=(vec_GF2& x, const mat_GF2& a)
218{
219   mul(x, x, a);
220   return x;
221}   
222
223
224NTL_CLOSE_NNS
225
226#endif
Note: See TracBrowser for help on using the repository browser.