spielwiese
Last change
on this file since 33a041 was
2cfffe,
checked in by Hans Schönemann <hannes@…>, 21 years ago
|
This commit was generated by cvs2svn to compensate for changes in r6316,
which included commits to RCS files with non-trunk default branches.
git-svn-id: file:///usr/local/Singular/svn/trunk@6317 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #include <NTL/mat_poly_lzz_p.h> |
---|
2 | |
---|
3 | #include <NTL/new.h> |
---|
4 | |
---|
5 | NTL_START_IMPL |
---|
6 | |
---|
7 | static |
---|
8 | void HessCharPoly(zz_pX& g, const zz_pX& a, const zz_pX& f) |
---|
9 | { |
---|
10 | long n = deg(f); |
---|
11 | if (n <= 0 || deg(a) >= n) |
---|
12 | Error("HessCharPoly: bad args"); |
---|
13 | |
---|
14 | mat_zz_p M; |
---|
15 | M.SetDims(n, n); |
---|
16 | |
---|
17 | long i, j; |
---|
18 | |
---|
19 | zz_pX t; |
---|
20 | t = a; |
---|
21 | |
---|
22 | for (i = 0; i < n; i++) { |
---|
23 | for (j = 0; j < n; j++) |
---|
24 | M[i][j] = coeff(t, j); |
---|
25 | |
---|
26 | if (i < n-1) |
---|
27 | MulByXMod(t, t, f); |
---|
28 | } |
---|
29 | |
---|
30 | CharPoly(g, M); |
---|
31 | } |
---|
32 | |
---|
33 | void CharPolyMod(zz_pX& g, const zz_pX& a, const zz_pX& ff) |
---|
34 | { |
---|
35 | zz_pX f = ff; |
---|
36 | MakeMonic(f); |
---|
37 | long n = deg(f); |
---|
38 | |
---|
39 | if (n <= 0 || deg(a) >= n) |
---|
40 | Error("CharPoly: bad args"); |
---|
41 | |
---|
42 | if (IsZero(a)) { |
---|
43 | clear(g); |
---|
44 | SetCoeff(g, n); |
---|
45 | return; |
---|
46 | } |
---|
47 | |
---|
48 | if (n > 90 || (zz_p::PrimeCnt() <= 1 && n > 45)) { |
---|
49 | zz_pX h; |
---|
50 | MinPolyMod(h, a, f); |
---|
51 | if (deg(h) == n) { |
---|
52 | g = h; |
---|
53 | return; |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | if (zz_p::modulus() < n+1) { |
---|
58 | HessCharPoly(g, a, f); |
---|
59 | return; |
---|
60 | } |
---|
61 | |
---|
62 | vec_zz_p u(INIT_SIZE, n+1), v(INIT_SIZE, n+1); |
---|
63 | |
---|
64 | zz_pX h, h1; |
---|
65 | negate(h, a); |
---|
66 | long i; |
---|
67 | |
---|
68 | for (i = 0; i <= n; i++) { |
---|
69 | u[i] = i; |
---|
70 | add(h1, h, u[i]); |
---|
71 | resultant(v[i], f, h1); |
---|
72 | } |
---|
73 | |
---|
74 | interpolate(g, u, v); |
---|
75 | } |
---|
76 | |
---|
77 | NTL_END_IMPL |
---|
Note: See
TracBrowser
for help on using the repository browser.