source: git/standalone.test/test.cc @ 615ca8

fieker-DuValspielwiese
Last change on this file since 615ca8 was 77bb59, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
CHG: minor changes
  • Property mode set to 100644
File size: 3.1 KB
Line 
1#include <omalloc/omalloc.h>
2#include <misc/auxiliary.h>
3
4#include <coeffs/coeffs.h>
5#include <coeffs/numbers.h>
6
7#include <reporter/reporter.h>
8#include <resources/feResource.h>
9
10#ifdef HAVE_FACTORY
11int initializeGMP(){ return 1; }
12#endif
13
14#include <polys/monomials/ring.h>
15#include <polys/monomials/p_polys.h>
16
17
18BOOLEAN Test(const n_coeffType type, void* param)
19{
20  BOOLEAN ret = TRUE;
21
22  const coeffs r = nInitChar( type, param );
23
24  if( r == NULL )
25  {
26    PrintS( "Test: could not get this coeff. domain" ); PrintLn();
27    return FALSE;
28  }
29
30  assume( r->cfCoeffWrite != NULLp );
31
32  if( r->cfCoeffWrite != NULL )
33  {
34    PrintS( "Coeff-domain: " ); n_CoeffWrite(r); PrintLn();
35  }
36
37  number t = n_Init(1, r); 
38  ndInpAdd(t, t, r); 
39 
40  number two = n_Init(2, r);
41  assume(n_Equal(two, t, r));
42  ret = ret && n_Equal(two, t, r);
43  n_Delete(&t, r);
44  n_Delete(&two, r);
45 
46
47  const int N = 2; // number of vars
48  char* n[N] = {"x", "y"}; // teir names
49 
50  ring R = rDefault( r, N, n);  // now r belongs to R!
51
52  if( R == NULL )
53  {
54    PrintS( "Test: could not get a polynomial ring over this coeff. domain" ); PrintLn();
55    nKillChar( r );
56    return FALSE;
57  }
58
59
60  rWrite(R); PrintLn();
61  #define RDEBUG
62  #ifdef  RDEBUG
63//    rDebugPrint(R); PrintLn();
64  #endif
65
66  const int exp[N] = {5, 8};
67 
68  poly p = p_ISet(1, R);
69  assume( p != NULL );
70  assume(pNext(p) == NULL);
71  ret = ret && (pNext(p) == NULL);
72
73  p_SetExp(p,1,exp[0],R);
74  p_SetExp(p,2,exp[1],R);
75  p_Setm(p, R);
76
77  assume( p_GetExp(p, 1, R) == exp[0] );
78  assume( p_GetExp(p, 2, R) == exp[1] );
79
80  p = p_Add_q(p_Copy(p, R), p, R); 
81
82  ret = ret && p_EqualPolys(p, p, R);
83
84 
85  poly p2 = p_ISet(2, R);
86  assume( p2 != NULL );
87  assume(pNext(p2) == NULL);
88  ret = ret && (pNext(p2) == NULL);
89 
90  p_SetExp(p2,1,exp[0],R);
91  p_SetExp(p2,2,exp[1],R);
92  p_Setm(p, R);
93
94  assume( p_GetExp(p2, 1, R) == exp[0] );
95  assume( p_GetExp(p2, 2, R) == exp[1] );
96
97  number s = p_GetCoeff(p, R);
98  two = n_Init(2, r);
99  assume(n_Equal(two, s, r));
100  ret = ret && n_Equal(s, two, r); 
101  n_Delete(&two, r);
102
103  assume(p_EqualPolys(p2, p, R));
104  ret = ret && p_EqualPolys(p, p, R);
105
106  p_Delete(&p, R);
107 
108  p_Delete(&p2, R);
109
110
111  rDelete(R);
112
113  return ret;
114}
115
116
117BOOLEAN simple(const n_coeffType _type, void* param = NULLp)
118{
119//  n_coeffType type = nRegister( _type, p);
120//  assume( type == _type ); // ?
121  return ( Test(_type, param) );
122}
123
124
125
126int main( int, char *argv[] ) 
127{
128  feInitResources(argv[0]);
129
130  StringSetS("ressources in use (as reported by feStringAppendResources(0):\n");
131  feStringAppendResources(0);
132  PrintS(StringAppendS("\n"));
133  // longrat
134  if( simple(n_Q) )
135    PrintS("Q: Test Passed!");
136  else 
137    PrintS("Q: Test: Failed!");
138  PrintLn();
139
140  // modulop
141  if( simple(n_Zp, (void*)7) )
142    PrintS("Zp: Test Passed!");
143  else 
144    PrintS("Zp: Test: Failed!");
145  PrintLn();
146 
147  // due to coeffs/ffields.h
148  struct 
149  {
150    int GFChar;
151    int GFDegree;
152    char* GFPar_name;
153  } param;
154
155  param.GFChar= 5;
156  param.GFDegree= 2;
157  param.GFPar_name= (const char*)"Q";
158
159  if( simple(n_GF, (void*)&param) )
160    PrintS("GF: Test Passed!");
161  else 
162    PrintS("GF: Test: Failed!");
163  PrintLn();
164 
165  return 0;
166}
Note: See TracBrowser for help on using the repository browser.