source: git/factory/test.cc @ 8a30b1

spielwiese
Last change on this file since 8a30b1 was 871c44, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: make test use psr gcd
  • Property mode set to 100644
File size: 3.0 KB
Line 
1#include <factory/factory.h>
2
3int mmInit(void) {
4#ifdef SINGULAR
5// this is a hack to make linker baheave on Mac OS X 10.6.8 / 64 bit
6// since otherwise both debug and release DYNAMIC tests failed there with:
7/*
8dyld: lazy symbol binding failed: Symbol not found: __Z7feFopenPKcS0_
9Referenced from: ...BUILDDIR/factory/.libs/libfactory_g-3.1.3.dylib
10Expected in: flat namespace
11   
12dyld: Symbol not found: __Z7feFopenPKcS0_
13Referenced from: ...BUILDDIR/factory/.libs/libfactory_g-3.1.3.dylib
14Expected in: flat namespace
15*/
16extern FILE * feFopen ( const char * path, const char * mode);
17const int f = (int)(long)(void*)feFopen;
18return (f ^ f) + 1; 
19#else
20return 1; 
21#endif
22}
23
24int 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
98extern void feInitResources(const char* argv0 = NULL);
99
100int 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}
Note: See TracBrowser for help on using the repository browser.