source: git/standalone.test/test.cc @ eb0708

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