1 | #include <factory/factory.h> |
---|
2 | #include <findexec/feFopen.h> |
---|
3 | |
---|
4 | int mmInit(void) { |
---|
5 | #ifdef SINGULAR |
---|
6 | // this is a hack to make linker baheave on Mac OS X 10.6.8 / 64 bit |
---|
7 | // since otherwise both debug and release DYNAMIC tests failed there with: |
---|
8 | /* |
---|
9 | dyld: lazy symbol binding failed: Symbol not found: __Z7feFopenPKcS0_ |
---|
10 | Referenced from: ...BUILDDIR/factory/.libs/libfactory_g-3.1.3.dylib |
---|
11 | Expected in: flat namespace |
---|
12 | |
---|
13 | dyld: Symbol not found: __Z7feFopenPKcS0_ |
---|
14 | Referenced from: ...BUILDDIR/factory/.libs/libfactory_g-3.1.3.dylib |
---|
15 | Expected in: flat namespace |
---|
16 | */ |
---|
17 | const int f = (int)(long)(void*)feFopen; |
---|
18 | return (f ^ f) + 1; |
---|
19 | #else |
---|
20 | return 1; |
---|
21 | #endif |
---|
22 | } |
---|
23 | |
---|
24 | int test2 (int p) |
---|
25 | { |
---|
26 | int ret = 1; |
---|
27 | setCharacteristic (p); |
---|
28 | printf ("p: %d, i: %d", p, 0); |
---|
29 | CanonicalForm d1= Variable (1) + Variable (2) + 1; |
---|
30 | CanonicalForm f1= Variable (1) - Variable (2) - 2; |
---|
31 | CanonicalForm g1= Variable (1) + Variable (2) + 2; |
---|
32 | CanonicalForm d= power (d1, 2); |
---|
33 | CanonicalForm f= d* power (f1, 2); |
---|
34 | CanonicalForm g= d* power (g1, 2); |
---|
35 | CanonicalForm h= gcd (f,g); |
---|
36 | h /= Lc (h); |
---|
37 | printf (", h==d? %d\n", (h == d)); |
---|
38 | if (h != d) |
---|
39 | ret = -1; |
---|
40 | for (int i= 3; i <= 11; i++) |
---|
41 | { |
---|
42 | printf ("p: %d, i: %d", p, i); |
---|
43 | d1 += power (Variable (i), i); |
---|
44 | f1 -= power (Variable (i), i); |
---|
45 | g1 += power (Variable (i), i); |
---|
46 | d= power (d1, 2); |
---|
47 | f= d*power (f1, 2); |
---|
48 | g= d*power (g1, 2); |
---|
49 | h= gcd (f,g); |
---|
50 | h /= Lc (h); |
---|
51 | printf (", h==d? %d\n", (h == d)); |
---|
52 | if (h != d) |
---|
53 | ret = -1; |
---|
54 | } |
---|
55 | return ret; |
---|
56 | } |
---|
57 | |
---|
58 | /*int test5 (int p) |
---|
59 | { |
---|
60 | setCharacteristic (p); |
---|
61 | Variable x= Variable (1); |
---|
62 | CanonicalForm d1= x + 1; |
---|
63 | CanonicalForm d2= Variable (2) + 1; |
---|
64 | CanonicalForm f1= x - 2; |
---|
65 | CanonicalForm f2= Variable (2) - 2; |
---|
66 | CanonicalForm g1= x + 2; |
---|
67 | CanonicalForm g2= Variable (2) + 2; |
---|
68 | CanonicalForm d= d1*d2 - 2; |
---|
69 | CanonicalForm f= f1*f2 + 2; |
---|
70 | CanonicalForm g= g1*g2 - 2; |
---|
71 | f *= d; |
---|
72 | g *= d; |
---|
73 | CanonicalForm h= gcd (f, g); |
---|
74 | h /= Lc (h); |
---|
75 | if (h != d) |
---|
76 | return - 1; |
---|
77 | printf ("h==d? %d\n", (h == d)); |
---|
78 | for (int i= 3; i <= 11; i++) |
---|
79 | { |
---|
80 | d2 *= power (Variable (i), i) + 1; |
---|
81 | f2 *= power (Variable (i), i) - 2; |
---|
82 | g2 *= power (Variable (i), i) + 2; |
---|
83 | |
---|
84 | d= d1*d2 - 2; |
---|
85 | f= f1*f2 + 2; |
---|
86 | g= g1*g2 - 2; |
---|
87 | f *= d; |
---|
88 | g *= d; |
---|
89 | h= gcd (f, g); |
---|
90 | h /= Lc (h); |
---|
91 | if (h != d) |
---|
92 | return -1; |
---|
93 | printf ("h==d? %d\n", (h == d)); |
---|
94 | } |
---|
95 | return 1; |
---|
96 | }*/ |
---|
97 | |
---|
98 | extern void feInitResources(const char* argv0 = NULL); |
---|
99 | |
---|
100 | int main( int, char *argv[] ) |
---|
101 | { |
---|
102 | int ret = 0; |
---|
103 | |
---|
104 | feInitResources(argv[0]); |
---|
105 | |
---|
106 | // On (SW_USE_EZGCD); On (SW_USE_EZGCD_P); // TODO&NOTE: these switches lead to failed tests (with nonzero p)! |
---|
107 | |
---|
108 | Off (SW_USE_EZGCD); |
---|
109 | Off (SW_USE_CHINREM_GCD); |
---|
110 | |
---|
111 | int t= test2 (0); |
---|
112 | if (t < 0) |
---|
113 | ret = t; |
---|
114 | /*t= test5 (0); |
---|
115 | if (t < 0) |
---|
116 | return t; |
---|
117 | t= test5 (3); |
---|
118 | if (t < 0) |
---|
119 | return t; |
---|
120 | t= test5 (101); |
---|
121 | if (t < 0) |
---|
122 | return t; |
---|
123 | t= test5 (43051); |
---|
124 | if (t < 0) |
---|
125 | return t;*/ |
---|
126 | t= test2 (3); |
---|
127 | if (t < 0) |
---|
128 | ret += t; |
---|
129 | |
---|
130 | t= test2 (101); |
---|
131 | if (t < 0) |
---|
132 | ret += t; |
---|
133 | |
---|
134 | t= test2 (43051); |
---|
135 | if (t < 0) |
---|
136 | ret += t; |
---|
137 | |
---|
138 | return ret; |
---|
139 | } |
---|