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.1 KB
|
Line | |
---|
1 | #include <NTL/ZZXFactoring.h> |
---|
2 | |
---|
3 | NTL_CLIENT |
---|
4 | |
---|
5 | |
---|
6 | long compare(const ZZX& a, const ZZX& b) |
---|
7 | { |
---|
8 | if (deg(a) < deg(b)) |
---|
9 | return 0; |
---|
10 | |
---|
11 | if (deg(a) > deg(b)) |
---|
12 | return 1; |
---|
13 | |
---|
14 | long n = a.rep.length(); |
---|
15 | long i; |
---|
16 | |
---|
17 | for (i = 0; i < n; i++) { |
---|
18 | if (a.rep[i] < b.rep[i]) return 0; |
---|
19 | if (a.rep[i] > b.rep[i]) return 1; |
---|
20 | } |
---|
21 | |
---|
22 | return 0; |
---|
23 | } |
---|
24 | |
---|
25 | |
---|
26 | void sort(vec_pair_ZZX_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 | |
---|
41 | int main(int argc, char **argv) |
---|
42 | { |
---|
43 | ZZX f1, f; |
---|
44 | |
---|
45 | if (argc > 1) |
---|
46 | ZZXFac_MaxPrune = atoi(argv[1]); |
---|
47 | |
---|
48 | cin >> f; |
---|
49 | |
---|
50 | vec_pair_ZZX_long factors; |
---|
51 | ZZ c; |
---|
52 | |
---|
53 | double t; |
---|
54 | |
---|
55 | t = GetTime(); |
---|
56 | factor(c, factors, f, 0); |
---|
57 | t = GetTime()-t; |
---|
58 | |
---|
59 | cerr << "total time: " << t << "\n"; |
---|
60 | |
---|
61 | |
---|
62 | mul(f1, factors); |
---|
63 | mul(f1, f1, c); |
---|
64 | |
---|
65 | if (f != f1) |
---|
66 | Error("FACTORIZATION INCORRECT!!!"); |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | sort(factors); |
---|
71 | |
---|
72 | cout << c << "\n"; |
---|
73 | cout << factors << "\n"; |
---|
74 | |
---|
75 | return 0; |
---|
76 | } |
---|
77 | |
---|
Note: See
TracBrowser
for help on using the repository browser.