1 | #include "factory/factory.h" |
---|
2 | #ifdef SINGULAR |
---|
3 | #include "resources/feFopen.h" |
---|
4 | #include "resources/feResource.h" |
---|
5 | #endif |
---|
6 | #include "cf_assert.h" |
---|
7 | |
---|
8 | int test2 (int p) |
---|
9 | { |
---|
10 | int ret = 1; |
---|
11 | setCharacteristic (p); |
---|
12 | printf ("p: %d, i: %d", p, 0); |
---|
13 | CanonicalForm d1= Variable (1) + Variable (2) + 1; |
---|
14 | CanonicalForm f1= Variable (1) - Variable (2) - 2; |
---|
15 | CanonicalForm g1= Variable (1) + Variable (2) + 2; |
---|
16 | CanonicalForm d= power (d1, 2); |
---|
17 | CanonicalForm f= d* power (f1, 2); |
---|
18 | CanonicalForm g= d* power (g1, 2); |
---|
19 | CanonicalForm h= gcd (f,g); |
---|
20 | h /= Lc (h); |
---|
21 | printf (", h==d? %d\n", (h == d)); |
---|
22 | if (h != d) |
---|
23 | ret = -1; |
---|
24 | for (int i= 3; i <= 7; i++) |
---|
25 | { |
---|
26 | printf ("p: %d, i: %d", p, i); |
---|
27 | d1 += power (Variable (i), i); |
---|
28 | f1 -= power (Variable (i), i); |
---|
29 | g1 += power (Variable (i), i); |
---|
30 | d= power (d1, 2); |
---|
31 | f= d*power (f1, 2); |
---|
32 | g= d*power (g1, 2); |
---|
33 | h= gcd (f,g); |
---|
34 | h /= Lc (h); |
---|
35 | printf (", h==d? %d\n", (h == d)); |
---|
36 | if (h != d) |
---|
37 | ret = -1; |
---|
38 | } |
---|
39 | return ret; |
---|
40 | } |
---|
41 | |
---|
42 | /*int test5 (int p) |
---|
43 | { |
---|
44 | setCharacteristic (p); |
---|
45 | Variable x= Variable (1); |
---|
46 | CanonicalForm d1= x + 1; |
---|
47 | CanonicalForm d2= Variable (2) + 1; |
---|
48 | CanonicalForm f1= x - 2; |
---|
49 | CanonicalForm f2= Variable (2) - 2; |
---|
50 | CanonicalForm g1= x + 2; |
---|
51 | CanonicalForm g2= Variable (2) + 2; |
---|
52 | CanonicalForm d= d1*d2 - 2; |
---|
53 | CanonicalForm f= f1*f2 + 2; |
---|
54 | CanonicalForm g= g1*g2 - 2; |
---|
55 | f *= d; |
---|
56 | g *= d; |
---|
57 | CanonicalForm h= gcd (f, g); |
---|
58 | h /= Lc (h); |
---|
59 | if (h != d) |
---|
60 | return - 1; |
---|
61 | printf ("h==d? %d\n", (h == d)); |
---|
62 | for (int i= 3; i <= 11; i++) |
---|
63 | { |
---|
64 | d2 *= power (Variable (i), i) + 1; |
---|
65 | f2 *= power (Variable (i), i) - 2; |
---|
66 | g2 *= power (Variable (i), i) + 2; |
---|
67 | |
---|
68 | d= d1*d2 - 2; |
---|
69 | f= f1*f2 + 2; |
---|
70 | g= g1*g2 - 2; |
---|
71 | f *= d; |
---|
72 | g *= d; |
---|
73 | h= gcd (f, g); |
---|
74 | h /= Lc (h); |
---|
75 | if (h != d) |
---|
76 | return -1; |
---|
77 | printf ("h==d? %d\n", (h == d)); |
---|
78 | } |
---|
79 | return 1; |
---|
80 | }*/ |
---|
81 | |
---|
82 | int main( int, char *argv[] ) |
---|
83 | { |
---|
84 | int ret = 0; |
---|
85 | |
---|
86 | ASSERT( sizeof(long) == SIZEOF_LONG, "Bad config.h: wrong size of long!" ); |
---|
87 | |
---|
88 | if( sizeof(long) != SIZEOF_LONG ) |
---|
89 | { |
---|
90 | printf("Bad config.h: wrong size of long!"); |
---|
91 | |
---|
92 | return(1); |
---|
93 | } |
---|
94 | |
---|
95 | #ifdef SINGULAR |
---|
96 | feInitResources(argv[0]); |
---|
97 | #endif |
---|
98 | |
---|
99 | // On (SW_USE_EZGCD); On (SW_USE_EZGCD_P); // TODO&NOTE: these switches lead to failed tests (with nonzero p)! |
---|
100 | // use the default switches (depend also on NTL/FLINT): |
---|
101 | |
---|
102 | int t= test2 (0); |
---|
103 | if (t < 0) |
---|
104 | ret = t; |
---|
105 | /*t= test5 (0); |
---|
106 | if (t < 0) |
---|
107 | return t; |
---|
108 | t= test5 (3); |
---|
109 | if (t < 0) |
---|
110 | return t; |
---|
111 | t= test5 (101); |
---|
112 | if (t < 0) |
---|
113 | return t; |
---|
114 | t= test5 (43051); |
---|
115 | if (t < 0) |
---|
116 | return t;*/ |
---|
117 | t= test2 (3); |
---|
118 | if (t < 0) |
---|
119 | ret += t; |
---|
120 | |
---|
121 | t= test2 (101); |
---|
122 | if (t < 0) |
---|
123 | ret += t; |
---|
124 | |
---|
125 | t= test2 (43051); |
---|
126 | if (t < 0) |
---|
127 | ret += t; |
---|
128 | |
---|
129 | return ret; |
---|
130 | } |
---|