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