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 <= 11; 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 | |
---|
101 | Off (SW_USE_EZGCD); |
---|
102 | Off (SW_USE_CHINREM_GCD); |
---|
103 | |
---|
104 | int t= test2 (0); |
---|
105 | if (t < 0) |
---|
106 | ret = t; |
---|
107 | /*t= test5 (0); |
---|
108 | if (t < 0) |
---|
109 | return t; |
---|
110 | t= test5 (3); |
---|
111 | if (t < 0) |
---|
112 | return t; |
---|
113 | t= test5 (101); |
---|
114 | if (t < 0) |
---|
115 | return t; |
---|
116 | t= test5 (43051); |
---|
117 | if (t < 0) |
---|
118 | return t;*/ |
---|
119 | t= test2 (3); |
---|
120 | if (t < 0) |
---|
121 | ret += t; |
---|
122 | |
---|
123 | t= test2 (101); |
---|
124 | if (t < 0) |
---|
125 | ret += t; |
---|
126 | |
---|
127 | t= test2 (43051); |
---|
128 | if (t < 0) |
---|
129 | ret += t; |
---|
130 | |
---|
131 | return ret; |
---|
132 | } |
---|