1 | |
---|
2 | /**************************************************************************\ |
---|
3 | |
---|
4 | MODULE: mat_GF2E |
---|
5 | |
---|
6 | SUMMARY: |
---|
7 | |
---|
8 | Defines the class mat_GF2E. |
---|
9 | |
---|
10 | \**************************************************************************/ |
---|
11 | |
---|
12 | |
---|
13 | #include <NTL/matrix.h> |
---|
14 | #include <NTL/vec_vec_GF2E.h> |
---|
15 | |
---|
16 | NTL_matrix_decl(GF2E,vec_GF2E,vec_vec_GF2E,mat_GF2E) |
---|
17 | NTL_io_matrix_decl(GF2E,vec_GF2E,vec_vec_GF2E,mat_GF2E) |
---|
18 | NTL_eq_matrix_decl(GF2E,vec_GF2E,vec_vec_GF2E,mat_GF2E) |
---|
19 | |
---|
20 | void add(mat_GF2E& X, const mat_GF2E& A, const mat_GF2E& B); |
---|
21 | // X = A + B |
---|
22 | |
---|
23 | void sub(mat_GF2E& X, const mat_GF2E& A, const mat_GF2E& B); |
---|
24 | // X = A - B = A + B |
---|
25 | |
---|
26 | void negate(mat_GF2E& X, const mat_GF2E& A); |
---|
27 | // X = - A = A |
---|
28 | |
---|
29 | void mul(mat_GF2E& X, const mat_GF2E& A, const mat_GF2E& B); |
---|
30 | // X = A * B |
---|
31 | |
---|
32 | void mul(vec_GF2E& x, const mat_GF2E& A, const vec_GF2E& b); |
---|
33 | // x = A * b |
---|
34 | |
---|
35 | void mul(vec_GF2E& x, const vec_GF2E& a, const mat_GF2E& B); |
---|
36 | // x = a * B |
---|
37 | |
---|
38 | void mul(mat_GF2E& X, const mat_GF2E& A, const GF2E& b); |
---|
39 | void mul(mat_GF2E& X, const mat_GF2E& A, GF2 b); |
---|
40 | void mul(mat_GF2E& X, const mat_GF2E& A, long b); |
---|
41 | // X = A * b |
---|
42 | |
---|
43 | void mul(mat_GF2E& X, const GF2E& a, const mat_GF2E& B); |
---|
44 | void mul(mat_GF2E& X, GF2 a, const mat_GF2E& B); |
---|
45 | void mul(mat_GF2E& X, long a, const mat_GF2E& B); |
---|
46 | // X = a * B |
---|
47 | |
---|
48 | |
---|
49 | |
---|
50 | void determinant(GF2E& d, const mat_GF2E& A); |
---|
51 | GF2E determinant(const mat_GF2E& a); |
---|
52 | // d = determinant(A) |
---|
53 | |
---|
54 | |
---|
55 | void transpose(mat_GF2E& X, const mat_GF2E& A); |
---|
56 | mat_GF2E transpose(const mat_GF2E& A); |
---|
57 | // X = transpose of A |
---|
58 | |
---|
59 | void solve(GF2E& d, vec_GF2E& X, |
---|
60 | const mat_GF2E& A, const vec_GF2E& b); |
---|
61 | // A is an n x n matrix, b is a length n vector. Computes d = |
---|
62 | // determinant(A). If d != 0, solves x*A = b. |
---|
63 | |
---|
64 | void inv(GF2E& d, mat_GF2E& X, const mat_GF2E& A); |
---|
65 | // A is an n x n matrix. Computes d = determinant(A). If d != 0, |
---|
66 | // computes X = A^{-1}. |
---|
67 | |
---|
68 | void sqr(mat_GF2E& X, const mat_GF2E& A); |
---|
69 | mat_GF2E sqr(const mat_GF2E& A); |
---|
70 | // X = A*A |
---|
71 | |
---|
72 | void inv(mat_GF2E& X, const mat_GF2E& A); |
---|
73 | mat_GF2E inv(const mat_GF2E& A); |
---|
74 | // X = A^{-1}; error is raised if A is singular |
---|
75 | |
---|
76 | void power(mat_GF2E& X, const mat_GF2E& A, const ZZ& e); |
---|
77 | mat_GF2E power(const mat_GF2E& A, const ZZ& e); |
---|
78 | |
---|
79 | void power(mat_GF2E& X, const mat_GF2E& A, long e); |
---|
80 | mat_GF2E power(const mat_GF2E& A, long e); |
---|
81 | // X = A^e; e may be negative (in which case A must be nonsingular). |
---|
82 | |
---|
83 | |
---|
84 | void ident(mat_GF2E& X, long n); |
---|
85 | mat_GF2E ident_mat_GF2E(long n); |
---|
86 | // X = n x n identity matrix |
---|
87 | |
---|
88 | long IsIdent(const mat_GF2E& A, long n); |
---|
89 | // test if A is the n x n identity matrix |
---|
90 | |
---|
91 | void diag(mat_GF2E& X, long n, const GF2E& d); |
---|
92 | mat_GF2E diag(long n, const GF2E& d); |
---|
93 | // X = n x n diagonal matrix with d on diagonal |
---|
94 | |
---|
95 | long IsDiag(const mat_GF2E& A, long n, const GF2E& d); |
---|
96 | // test if X is an n x n diagonal matrix with d on diagonal |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | |
---|
101 | long gauss(mat_GF2E& M); |
---|
102 | long gauss(mat_GF2E& M, long w); |
---|
103 | // Performs unitary row operations so as to bring M into row echelon |
---|
104 | // form. If the optional argument w is supplied, stops when first w |
---|
105 | // columns are in echelon form. The return value is the rank (or the |
---|
106 | // rank of the first w columns). |
---|
107 | |
---|
108 | void image(mat_GF2E& X, const mat_GF2E& A); |
---|
109 | // The rows of X are computed as basis of A's row space. X is is row |
---|
110 | // echelon form |
---|
111 | |
---|
112 | void kernel(mat_GF2E& X, const mat_GF2E& A); |
---|
113 | // Computes a basis for the kernel of the map x -> x*A. where x is a |
---|
114 | // row vector. |
---|
115 | |
---|
116 | |
---|
117 | |
---|
118 | |
---|
119 | // miscellaneous: |
---|
120 | |
---|
121 | void clear(mat_GF2E& a); |
---|
122 | // x = 0 (dimension unchanged) |
---|
123 | |
---|
124 | long IsZero(const mat_GF2E& a); |
---|
125 | // test if a is the zero matrix (any dimension) |
---|
126 | |
---|
127 | |
---|
128 | // operator notation: |
---|
129 | |
---|
130 | mat_GF2E operator+(const mat_GF2E& a, const mat_GF2E& b); |
---|
131 | mat_GF2E operator-(const mat_GF2E& a, const mat_GF2E& b); |
---|
132 | mat_GF2E operator*(const mat_GF2E& a, const mat_GF2E& b); |
---|
133 | |
---|
134 | mat_GF2E operator-(const mat_GF2E& a); |
---|
135 | |
---|
136 | |
---|
137 | // matrix/scalar multiplication: |
---|
138 | |
---|
139 | mat_GF2E operator*(const mat_GF2E& a, const GF2E& b); |
---|
140 | mat_GF2E operator*(const mat_GF2E& a, GF2 b); |
---|
141 | mat_GF2E operator*(const mat_GF2E& a, long b); |
---|
142 | |
---|
143 | mat_GF2E operator*(const GF2E& a, const mat_GF2E& b); |
---|
144 | mat_GF2E operator*(GF2 a, const mat_GF2E& b); |
---|
145 | mat_GF2E operator*(long a, const mat_GF2E& b); |
---|
146 | |
---|
147 | // matrix/vector multiplication: |
---|
148 | |
---|
149 | vec_GF2E operator*(const mat_GF2E& a, const vec_GF2E& b); |
---|
150 | |
---|
151 | vec_GF2E operator*(const vec_GF2E& a, const mat_GF2E& b); |
---|
152 | |
---|
153 | |
---|
154 | // assignment operator notation: |
---|
155 | |
---|
156 | mat_GF2E& operator+=(mat_GF2E& x, const mat_GF2E& a); |
---|
157 | mat_GF2E& operator-=(mat_GF2E& x, const mat_GF2E& a); |
---|
158 | mat_GF2E& operator*=(mat_GF2E& x, const mat_GF2E& a); |
---|
159 | |
---|
160 | mat_GF2E& operator*=(mat_GF2E& x, const GF2E& a); |
---|
161 | mat_GF2E& operator*=(mat_GF2E& x, GF2 a); |
---|
162 | mat_GF2E& operator*=(mat_GF2E& x, long a); |
---|
163 | |
---|
164 | vec_GF2E& operator*=(vec_GF2E& x, const mat_GF2E& a); |
---|
165 | |
---|
166 | |
---|