spielwiese
Last change
on this file since 287cc8 was
287cc8,
checked in by Hans Schönemann <hannes@…>, 14 years ago
|
ntl 5.5.2
git-svn-id: file:///usr/local/Singular/svn/trunk@12402 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | |
---|
2 | #include <NTL/ZZ_pXFactoring.h> |
---|
3 | |
---|
4 | NTL_CLIENT |
---|
5 | |
---|
6 | |
---|
7 | long compare(const ZZ_pX& a, const ZZ_pX& b) |
---|
8 | { |
---|
9 | if (deg(a) < deg(b)) |
---|
10 | return 0; |
---|
11 | |
---|
12 | if (deg(a) > deg(b)) |
---|
13 | return 1; |
---|
14 | |
---|
15 | long n = a.rep.length(); |
---|
16 | long i; |
---|
17 | |
---|
18 | for (i = 0; i < n; i++) { |
---|
19 | if (rep(a.rep[i]) < rep(b.rep[i])) return 0; |
---|
20 | if (rep(a.rep[i]) > rep(b.rep[i])) return 1; |
---|
21 | } |
---|
22 | |
---|
23 | return 0; |
---|
24 | } |
---|
25 | |
---|
26 | void sort(vec_pair_ZZ_pX_long& v) |
---|
27 | { |
---|
28 | long n = v.length(); |
---|
29 | long i, j; |
---|
30 | |
---|
31 | for (i = 0; i < n-1; i++) |
---|
32 | for (j = 0; j < n-1-i; j++) |
---|
33 | if (compare(v[j].a, v[j+1].a)) { |
---|
34 | swap(v[j].a, v[j+1].a); |
---|
35 | swap(v[j].b, v[j+1].b); |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | int main() |
---|
41 | { |
---|
42 | ZZ p; |
---|
43 | cin >> p; |
---|
44 | ZZ_p::init(p); |
---|
45 | ZZ_pX f; |
---|
46 | cin >> f; |
---|
47 | |
---|
48 | vec_pair_ZZ_pX_long factors; |
---|
49 | |
---|
50 | double t = GetTime(); |
---|
51 | CanZass(factors, f, 1); |
---|
52 | t = GetTime()-t; |
---|
53 | cerr << "total time: " << t << "\n"; |
---|
54 | |
---|
55 | ZZ_pX ff; |
---|
56 | |
---|
57 | mul(ff, factors); |
---|
58 | if (f != ff) |
---|
59 | Error("Incorrect factorization!!"); |
---|
60 | |
---|
61 | sort(factors); |
---|
62 | |
---|
63 | cerr << "factorization pattern:"; |
---|
64 | long i; |
---|
65 | |
---|
66 | for (i = 0; i < factors.length(); i++) { |
---|
67 | cerr << " "; |
---|
68 | long k = factors[i].b; |
---|
69 | if (k > 1) |
---|
70 | cerr << k << "*"; |
---|
71 | cerr << deg(factors[i].a); |
---|
72 | } |
---|
73 | |
---|
74 | cerr << "\n"; |
---|
75 | |
---|
76 | |
---|
77 | cout << factors << "\n"; |
---|
78 | |
---|
79 | return 0; |
---|
80 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.