File: mat_ZZ.cpp.html

package info (click to toggle)
ntl 10.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,460 kB
  • sloc: cpp: 84,947; sh: 10,577; ansic: 2,462; makefile: 804
file content (213 lines) | stat: -rw-r--r-- 11,581 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>~/junk6/ntl-10.4.0/doc/mat_ZZ.cpp.html</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="macvim">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #ffffff; }
body { font-family: monospace; color: #000000; background-color: #ffffff; }
* { font-size: 1em; }
.String { color: #4a708b; }
.PreProc { color: #1874cd; }
.Constant { color: #ff8c00; }
.Statement { color: #b03060; font-weight: bold; }
.Comment { color: #0000ee; font-style: italic; }
.Type { color: #008b00; font-weight: bold; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>

<span class="Comment">/*</span><span class="Comment">*************************************************************************\</span>

<span class="Comment">MODULE: mat_ZZ</span>

<span class="Comment">SUMMARY:</span>

<span class="Comment">Defines the class mat_ZZ.</span>

<span class="Comment">\*************************************************************************</span><span class="Comment">*/</span>


<span class="PreProc">#include </span><span class="String">&lt;NTL/matrix.h&gt;</span>
<span class="PreProc">#include </span><span class="String">&lt;NTL/vec_vec_ZZ.h&gt;</span>

<span class="Type">typedef</span> Mat&lt;ZZ&gt; mat_ZZ; <span class="Comment">// backward compatibility</span>

<span class="Type">void</span> add(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">const</span> mat_ZZ&amp; B);
<span class="Comment">// X = A + B</span>

<span class="Type">void</span> sub(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">const</span> mat_ZZ&amp; B);
<span class="Comment">// X = A - B</span>

<span class="Type">void</span> negate(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A);
<span class="Comment">// X = - A</span>

<span class="Type">void</span> mul(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">const</span> mat_ZZ&amp; B);
<span class="Comment">// X = A * B</span>

<span class="Type">void</span> mul(vec_ZZ&amp; x, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">const</span> vec_ZZ&amp; b);
<span class="Comment">// x = A * b</span>

<span class="Type">void</span> mul(vec_ZZ&amp; x, <span class="Type">const</span> vec_ZZ&amp; a, <span class="Type">const</span> mat_ZZ&amp; B);
<span class="Comment">// x = a * B</span>

<span class="Type">void</span> mul(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">const</span> ZZ&amp; b);
<span class="Type">void</span> mul(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">long</span> b);
<span class="Comment">// X = A * b</span>

<span class="Type">void</span> mul(mat_ZZ&amp; X, <span class="Type">const</span> ZZ&amp; a, <span class="Type">const</span> mat_ZZ&amp; B);
<span class="Type">void</span> mul(mat_ZZ&amp; X, <span class="Type">long</span> a, <span class="Type">const</span> mat_ZZ&amp; B);
<span class="Comment">// X = a * B</span>



<span class="Type">void</span> determinant(ZZ&amp; d, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">long</span> deterministic=<span class="Constant">0</span>);
ZZ determinant(<span class="Type">const</span> mat_ZZ&amp; a, <span class="Type">long</span> deterministic=<span class="Constant">0</span>);
<span class="Comment">// d = determinant(A).  If !deterministic, a randomized strategy may</span>
<span class="Comment">// be used that errs with probability at most 2^{-80}.</span>



<span class="Type">void</span> solve(ZZ&amp; d, vec_ZZ&amp; x,
           <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">const</span> vec_ZZ&amp; b,
           <span class="Type">long</span> deterministic=<span class="Constant">0</span>)
<span class="Comment">// computes d = determinant(A) and solves x*A = b*d if d != 0; A must</span>
<span class="Comment">// be a square matrix and have compatible dimensions with b.  If</span>
<span class="Comment">// !deterministic, the computation of d may use a randomized strategy</span>
<span class="Comment">// that errs with probability 2^{-80}.</span>



<span class="Type">void</span> solve1(ZZ&amp; d, vec_ZZ&amp; x, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">const</span> vec_ZZ&amp; b);
<span class="Comment">// A must be a square matrix.</span>
<span class="Comment">// If A is singular, this routine sets d = 0 and returns.</span>
<span class="Comment">// Otherwise, it computes d, x such that x*A == b*d, </span>
<span class="Comment">// such that d &gt; 0 and minimal.</span>
<span class="Comment">// Note that d is a positive divisor of the determinant,</span>
<span class="Comment">// and is not in general equal to the determinant.</span>
<span class="Comment">// The routine is deterministic, and uses a Hensel lifting strategy.</span>

<span class="Comment">// For backward compatability, there is also a routine called</span>
<span class="Comment">// HenselSolve1 that simply calls solve1.</span>


<span class="Type">void</span> inv(ZZ&amp; d, mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">long</span> deterministic=<span class="Constant">0</span>);
<span class="Comment">// computes d = determinant(A) and solves X*A = I*d if d != 0; A must</span>
<span class="Comment">// be a square matrix.  If !deterministic, the computation of d may</span>
<span class="Comment">// use a randomized strategy that errs with probability 2^{-80}.</span>


<span class="Comment">// NOTE:  See LLL.txt for routines that compute the kernel and</span>
<span class="Comment">// image of an integer matrix.</span>

<span class="Comment">// NOTE: See HNF.txt for a routine that computes Hermite Normal Forms.</span>

<span class="Type">void</span> sqr(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A);
mat_ZZ sqr(<span class="Type">const</span> mat_ZZ&amp; A);
<span class="Comment">// X = A*A   </span>

<span class="Type">void</span> inv(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A);
mat_ZZ inv(<span class="Type">const</span> mat_ZZ&amp; A);
<span class="Comment">// X = A^{-1}; error is raised if |det(A)| != 1.</span>

<span class="Type">void</span> power(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">const</span> ZZ&amp; e);
mat_ZZ power(<span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">const</span> ZZ&amp; e);

<span class="Type">void</span> power(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">long</span> e);
mat_ZZ power(<span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">long</span> e);
<span class="Comment">// X = A^e; e may be negative (in which case A must be nonsingular).</span>



<span class="Type">void</span> ident(mat_ZZ&amp; X, <span class="Type">long</span> n);
mat_ZZ ident_mat_ZZ(<span class="Type">long</span> n);
<span class="Comment">// X = n x n identity matrix</span>

<span class="Type">long</span> IsIdent(<span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">long</span> n);
<span class="Comment">// test if A is the n x n identity matrix</span>

<span class="Type">void</span> diag(mat_ZZ&amp; X, <span class="Type">long</span> n, <span class="Type">const</span> ZZ&amp; d);
mat_ZZ diag(<span class="Type">long</span> n, <span class="Type">const</span> ZZ&amp; d);
<span class="Comment">// X = n x n diagonal matrix with d on diagonal</span>

<span class="Type">long</span> IsDiag(<span class="Type">const</span> mat_ZZ&amp; A, <span class="Type">long</span> n, <span class="Type">const</span> ZZ&amp; d);
<span class="Comment">// test if X is an  n x n diagonal matrix with d on diagonal</span>


<span class="Type">void</span> transpose(mat_ZZ&amp; X, <span class="Type">const</span> mat_ZZ&amp; A);
mat_ZZ transpose(<span class="Type">const</span> mat_ZZ&amp; A);
<span class="Comment">// X = transpose of A</span>


<span class="Type">long</span> CRT(mat_ZZ&amp; a, ZZ&amp; prod, <span class="Type">const</span> mat_zz_p&amp; A);
<span class="Comment">// Incremental Chinese Remaindering: If p is the current zz_p modulus with</span>
<span class="Comment">// (p, prod) = 1; Computes a' such that a' = a mod prod and a' = A mod p,</span>
<span class="Comment">// with coefficients in the interval (-p*prod/2, p*prod/2]; </span>
<span class="Comment">// Sets a := a', prod := p*prod, and returns 1 if a's value changed.</span>



<span class="Comment">// miscellaneous:</span>

<span class="Type">void</span> clear(mat_ZZ&amp; a);
<span class="Comment">// x = 0 (dimension unchanged)</span>

<span class="Type">long</span> IsZero(<span class="Type">const</span> mat_ZZ&amp; a);
<span class="Comment">// test if a is the zero matrix (any dimension)</span>


<span class="Comment">// operator notation:</span>

mat_ZZ <span class="Statement">operator</span>+(<span class="Type">const</span> mat_ZZ&amp; a, <span class="Type">const</span> mat_ZZ&amp; b);
mat_ZZ <span class="Statement">operator</span>-(<span class="Type">const</span> mat_ZZ&amp; a, <span class="Type">const</span> mat_ZZ&amp; b);
mat_ZZ <span class="Statement">operator</span>*(<span class="Type">const</span> mat_ZZ&amp; a, <span class="Type">const</span> mat_ZZ&amp; b);

mat_ZZ <span class="Statement">operator</span>-(<span class="Type">const</span> mat_ZZ&amp; a);


<span class="Comment">// matrix/scalar multiplication:</span>

mat_ZZ <span class="Statement">operator</span>*(<span class="Type">const</span> mat_ZZ&amp; a, <span class="Type">const</span> ZZ&amp; b);
mat_ZZ <span class="Statement">operator</span>*(<span class="Type">const</span> mat_ZZ&amp; a, <span class="Type">long</span> b);

mat_ZZ <span class="Statement">operator</span>*(<span class="Type">const</span> ZZ&amp; a, <span class="Type">const</span> mat_ZZ&amp; b);
mat_ZZ <span class="Statement">operator</span>*(<span class="Type">long</span> a, <span class="Type">const</span> mat_ZZ&amp; b);

<span class="Comment">// matrix/vector multiplication:</span>

vec_ZZ <span class="Statement">operator</span>*(<span class="Type">const</span> mat_ZZ&amp; a, <span class="Type">const</span> vec_ZZ&amp; b);

vec_ZZ <span class="Statement">operator</span>*(<span class="Type">const</span> vec_ZZ&amp; a, <span class="Type">const</span> mat_ZZ&amp; b);



<span class="Comment">// assignment operator notation:</span>

mat_ZZ&amp; <span class="Statement">operator</span>+=(mat_ZZ&amp; x, <span class="Type">const</span> mat_ZZ&amp; a);
mat_ZZ&amp; <span class="Statement">operator</span>-=(mat_ZZ&amp; x, <span class="Type">const</span> mat_ZZ&amp; a);
mat_ZZ&amp; <span class="Statement">operator</span>*=(mat_ZZ&amp; x, <span class="Type">const</span> mat_ZZ&amp; a);

mat_ZZ&amp; <span class="Statement">operator</span>*=(mat_ZZ&amp; x, <span class="Type">const</span> ZZ&amp; a);
mat_ZZ&amp; <span class="Statement">operator</span>*=(mat_ZZ&amp; x, <span class="Type">long</span> a);

vec_ZZ&amp; <span class="Statement">operator</span>*=(vec_ZZ&amp; x, <span class="Type">const</span> mat_ZZ&amp; a);


</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->