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