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