source: git/factory/test.cc @ c4682e0

spielwiese
Last change on this file since c4682e0 was 546f7ff, checked in by Martin Lee <martinlee84@…>, 13 years ago
added tests to factory
  • Property mode set to 100644
File size: 2.0 KB
Line 
1#include <factory/factory.h>
2
3int mmInit(void) {return 1; }
4
5int test2 (int p)
6{
7  setCharacteristic (p);
8  CanonicalForm d1= Variable (1) + Variable (2) + 1;
9  CanonicalForm f1= Variable (1) - Variable (2) - 2;
10  CanonicalForm g1= Variable (1) + Variable (2) + 2;
11  CanonicalForm d= power (d1, 2);
12  CanonicalForm f= d* power (f1, 2);
13  CanonicalForm g= d* power (g1, 2);
14  CanonicalForm h= gcd (f,g);
15  h /= Lc (h);
16  if (h != d)
17    return -1;
18  printf ("h==d? %d\n", (h == d));
19  for (int i= 3; i <= 11; i++)
20  {
21    d1 += power (Variable (i), i);
22    f1 -= power (Variable (i), i);
23    g1 += power (Variable (i), i);
24    d= power (d1, 2);
25    f= d*power (f1, 2);
26    g= d*power (g1, 2);
27    h= gcd (f,g);
28    h /= Lc (h);
29    if (h != d)
30      return -1;
31    printf ("h==d? %d\n", (h == d));
32  }
33  return 1;
34}
35
36/*int test5 (int p)
37{
38  setCharacteristic (p);
39  Variable x= Variable (1);
40  CanonicalForm d1= x + 1;
41  CanonicalForm d2= Variable (2) + 1;
42  CanonicalForm f1= x - 2;
43  CanonicalForm f2= Variable (2) - 2;
44  CanonicalForm g1= x + 2;
45  CanonicalForm g2= Variable (2) + 2;
46  CanonicalForm d= d1*d2 - 2;
47  CanonicalForm f= f1*f2 + 2;
48  CanonicalForm g= g1*g2 - 2;
49  f *= d;
50  g *= d;
51  CanonicalForm h= gcd (f, g);
52  h /= Lc (h);
53  if (h != d)
54    return - 1;
55  printf ("h==d? %d\n", (h == d));
56  for (int i= 3; i <= 11; i++)
57  {
58    d2 *= power (Variable (i), i) + 1;
59    f2 *= power (Variable (i), i) - 2;
60    g2 *= power (Variable (i), i) + 2;
61
62    d= d1*d2 - 2;
63    f= f1*f2 + 2;
64    g= g1*g2 - 2;
65    f *= d;
66    g *= d;
67    h= gcd (f, g);
68    h /= Lc (h);
69    if (h != d)
70      return -1;
71    printf ("h==d? %d\n", (h == d));
72  }
73  return 1;
74}*/
75
76int main( int, char *argv[] )
77{
78  int t= test2 (0);
79  if (t < 0)
80    return t;
81  /*t= test5 (0);
82  if (t < 0)
83    return t;
84  t= test5 (3);
85  if (t < 0)
86    return t;
87  t= test5 (101);
88  if (t < 0)
89    return t;
90  t= test5 (43051);
91  if (t < 0)
92    return t;*/
93  t= test2 (3);
94  if (t < 0)
95    return t;
96  t= test2 (101);
97  if (t < 0)
98    return t;
99  t= test2 (43051);
100  if (t < 0)
101    return t;
102  return 0;
103}
Note: See TracBrowser for help on using the repository browser.