Data Structures | Functions | Variables
coeffs_test.h File Reference
#include <misc/auxiliary.h>
#include <omalloc/omalloc.h>
#include <reporter/reporter.h>
#include <resources/feResource.h>
#include <coeffs/coeffs.h>
#include <coeffs/numbers.h>
#include <coeffs/longrat.h>
#include <coeffs/gnumpfl.h>
#include <coeffs/gnumpc.h>
#include <coeffs/shortfl.h>
#include <coeffs/ffields.h>
#include <coeffs/modulop.h>
#include <coeffs/rmodulon.h>
#include <coeffs/rmodulo2m.h>
#include <coeffs/rintegers.h>
#include "common.h"

Go to the source code of this file.

Data Structures

class  CoeffsTestSuite
 

Functions

void TestSum (const coeffs r, const unsigned long N)
 
void TestArith (const coeffs r)
 
BOOLEAN Test (const n_coeffType type, void *p=NULLp)
 

Variables

static GlobalPrintingFixture globalPrintingFixture
 

Function Documentation

BOOLEAN Test ( const n_coeffType  type,
void *  p = NULLp 
)

Definition at line 215 of file coeffs_test.h.

216 {
217 
218  clog << endl;
219  clog << ( "----------------------- Testing coeffs: [" + _2S(type) + ", " + _2S(p) + "]: -----------------------");
220  clog << endl;
221 
222  const coeffs r = nInitChar( type, p );
223 
224  if( r == NULLp )
225  {
226  clog << ( "Test: could not get this coeff. domain" );
227  return FALSE;
228  };
229 
230  TS_ASSERT_DIFFERS( r->cfCoeffWrite, NULLp );
231 
232  if( r->cfCoeffWrite != NULL )
233  {
234  clog << "Coeff-domain: " << endl;
235  n_CoeffWrite(r); PrintLn();
236  }
237 
238  if (n_NumberOfParameters(r) > 0)
239  {
240  number z = n_Param(1, r); // also any integer instead of 0//?
241  PrintS("Parameter: "); PrintSized(z, r);
242  n_Delete(&z, r);
243  }
244 
245 
246  clog << "Char: " << n_GetChar(r) << endl;
247 
248 
249  TS_ASSERT_DIFFERS( r, NULLp );
250  nSetChar( r );
251  TS_ASSERT_EQUALS( getCoeffType(r), type );
252 
253  TS_ASSERT_DIFFERS( r->cfInit, NULLp );
254  TS_ASSERT_DIFFERS( r->cfWriteLong, NULLp );
255  TS_ASSERT_DIFFERS( r->cfAdd, NULLp );
256  TS_ASSERT_DIFFERS( r->cfDelete, NULLp );
257 
258  switch( type )
259  {
260  case n_Q:
261  {
262  //TS_ASSERT_EQUALS( r->cfInit, nlInit );
263  //TS_ASSERT_EQUALS( r->cfAdd, nlAdd );
264  //TS_ASSERT_EQUALS( r->cfDelete, nlDelete );
265 
266  TS_ASSERT( nCoeff_is_Q( r ));
268 
269  TS_ASSERT( !nCoeff_has_Units( r )); // ?
271  TS_ASSERT( !nCoeff_has_simple_Alloc( r )); // ?
272 
276  TS_ASSERT( !nCoeff_is_Ring_Z( r ));
277  TS_ASSERT( !nCoeff_is_Ring( r ));
278  TS_ASSERT( !nCoeff_is_Zp( r ));
280  TS_ASSERT( !nCoeff_is_R( r ));
281  TS_ASSERT( !nCoeff_is_GF( r ));
282  TS_ASSERT( !nCoeff_is_long_R( r ));
283  TS_ASSERT( !nCoeff_is_long_C( r ));
284  TS_ASSERT( !nCoeff_is_CF( r ));
286 
287  break;
288  }
289  case n_long_R:
290  {
291  //TS_ASSERT_EQUALS( r->cfInit, ngfInit );
292  //TS_ASSERT_EQUALS( r->cfAdd, ngfAdd );
293  //TS_ASSERT_EQUALS( r->cfDelete, ngfDelete );
294  break;
295  }
296  case n_long_C:
297  {
298 // TS_ASSERT_EQUALS( r->cfInit, ngcInit );
299 // TS_ASSERT_EQUALS( r->cfAdd, ngcAdd );
300 // TS_ASSERT_EQUALS( r->cfDelete, ngcDelete );
301  break;
302  }
303  case n_R:
304  {
305  //TS_ASSERT_EQUALS( r->cfInit, nrInit );
306  //TS_ASSERT_EQUALS( r->cfAdd, nrAdd );
307  // TS_ASSERT_EQUALS( r->cfDelete, nrDelete ); // No?
308  break;
309  }
310  case n_GF:
311  {
312 // TS_ASSERT_EQUALS( r->cfInit, nfInit );
313 // TS_ASSERT_EQUALS( r->cfAdd, nfAdd );
314  //TS_ASSERT_EQUALS( r->cfDelete, nfDelete );
315  break;
316  }
317 #ifdef HAVE_RINGS
318  case n_Z2m:
319  {
320  //TS_ASSERT_EQUALS( r->cfInit, nr2mInit );
321  //TS_ASSERT_EQUALS( r->cfAdd, nr2mAdd );
322  //TS_ASSERT_EQUALS( r->cfDelete, ndDelete );
323  break;
324  }
325  case n_Zn:
326  {
327  //TS_ASSERT_EQUALS( r->cfInit, nrnInit );
328  //TS_ASSERT_EQUALS( r->cfAdd, nrnAdd );
329  //TS_ASSERT_EQUALS( r->cfDelete, nrnDelete );
330  break;
331  }
332 #endif
333  default:
334  {
335  // ...
336  }
337  }
338 
339  TestArith( r );
340  TestSum( r, 10 );
341  TestSum( r, 100 );
342  TestSum( r, 101 );
343  TestSum( r, 1001 );
344  TestSum( r, 9000 );
345 
346  nKillChar( r );
347 
348  return TRUE;
349 }
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_ModN(const coeffs r)
Definition: coeffs.h:749
#define NULLp
Definition: auxiliary.h:152
void TestSum(const coeffs r, const unsigned long N)
Definition: coeffs_test.h:31
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
Definition: coeffs.h:835
void PrintLn()
Definition: reporter.cc:327
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:43
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:823
only used if HAVE_RINGS is defined: ?
Definition: coeffs.h:45
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:894
#define TS_ASSERT_EQUALS(x, y)
Definition: TestSuite.h:255
static FORCE_INLINE void nSetChar(const coeffs r)
initialisations after each ring change
Definition: coeffs.h:437
rational (GMP) numbers
Definition: coeffs.h:31
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
Definition: coeffs.h:755
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:839
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:746
static FORCE_INLINE BOOLEAN nCoeff_has_simple_inverse(const coeffs r)
TRUE, if the computation of the inverse is fast, i.e. prefer leading coeff. 1 over content...
Definition: coeffs.h:905
void TestArith(const coeffs r)
Definition: coeffs_test.h:115
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:445
#define TRUE
Definition: auxiliary.h:144
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:829
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:897
#define TS_ASSERT(e)
Definition: TestSuite.h:239
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:758
real floating point (GMP) numbers
Definition: coeffs.h:34
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:797
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1..n_NumberOfParameters(...)
Definition: coeffs.h:806
single prescision (6,6) real numbers
Definition: coeffs.h:32
const ring r
Definition: syzextra.cc:208
static FORCE_INLINE BOOLEAN nCoeff_is_CF(const coeffs r)
Definition: coeffs.h:900
The main handler for Singular numbers which are suitable for Singular polynomials.
static FORCE_INLINE BOOLEAN nCoeff_has_Units(const coeffs r)
returns TRUE, if r is not a field and r has non-trivial units
Definition: coeffs.h:820
static FORCE_INLINE BOOLEAN nCoeff_has_simple_Alloc(const coeffs r)
TRUE if n_Delete/n_New are empty operations.
Definition: coeffs.h:909
complex floating point (GMP) numbers
Definition: coeffs.h:41
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
Definition: coeffs.h:752
void PrintS(const char *s)
Definition: reporter.cc:294
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:842
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static FORCE_INLINE void n_CoeffWrite(const coeffs r, BOOLEAN details=TRUE)
output the coeff description
Definition: coeffs.h:742
static FORCE_INLINE BOOLEAN nCoeff_is_Domain(const coeffs r)
returns TRUE, if r is a field or r has no zero divisors (i.e is a domain)
Definition: coeffs.h:762
#define NULL
Definition: omList.c:10
{p^n < 2^16}
Definition: coeffs.h:33
#define TS_ASSERT_DIFFERS(x, y)
Definition: TestSuite.h:287
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:849
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:488
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:327
void TestArith ( const coeffs  r)

Definition at line 115 of file coeffs_test.h.

116 {
117  clog << ("TEST: Simple Arithmetics: ");
118  clog << endl;
119 
120  number two = n_Init(2, r);
121 
122  number t = n_Init(1, r);
123  n_InpAdd(t, t, r);
124  TS_ASSERT( n_Equal(two, t, r) );
125  n_Delete(&t, r);
126 
127  if( getCoeffType(r) == n_Q )
128  {
129  number t = n_Init(1, r);
130  n_InpAdd(t, t, r);
131  TS_ASSERT( n_Equal(two, t, r) );
132  n_Delete(&t, r);
133  }
134 
135 
136 
137 
138  const int N = 66666;
139 
140  number a = n_Init(N, r);
141 
142  clog<< "a: "; PrintSized(a, r);
143 
144 
145  clog<< "two: "; PrintSized(two, r);
146 
147  number aa0 = n_Init(N*2, r);
148 
149  number aa = n_Add(a, a, r);
150 
151  clog<< "aa = a + a: "; PrintSized(aa, r);
152 
153  number aa2 = n_Mult(a, two, r);
154 
155  clog<< "aa2 = a * 2: "; PrintSized(aa2, r);
156 
157  number aa1 = n_Mult(two, a, r);
158 
159  clog<< "aa1 = 2 * a: "; PrintSized(aa1, r);
160 
161  n_Delete(&a, r);
162  n_Delete(&two, r);
163 
164 
165  a = n_Sub( aa, aa1, r );
166 
167  clog<< "a = aa - aa1: "; PrintSized(a, r);
168 
169  TS_ASSERT( n_IsZero(a, r) );
170 
171  n_Delete(&a, r);
172 
173  a = n_Sub( aa, aa2, r );
174 
175  clog<< "a = aa - aa2: "; PrintSized(a, r);
176 
177  TS_ASSERT( n_IsZero(a, r) );
178 
179  n_Delete(&a, r);
180 
181 
182  a = n_Sub( aa1, aa2, r );
183 
184  clog<< "a = aa1 - aa2: "; PrintSized(a, r);
185 
186  TS_ASSERT( n_IsZero(a, r) );
187 
188  n_Delete(&a, r);
189 
190 
191 
192  TS_ASSERT( n_Equal(aa, aa1, r) );
193  TS_ASSERT( n_Equal(aa, aa2, r) );
194  TS_ASSERT( n_Equal(aa1, aa2, r) );
195 
196  TS_ASSERT( n_Equal(aa0, aa, r) );
197  TS_ASSERT( n_Equal(aa0, aa1, r) );
198  TS_ASSERT( n_Equal(aa0, aa2, r) );
199 
200  n_Delete(&aa, r);
201  n_Delete(&aa1, r);
202  n_Delete(&aa2, r);
203 
204  n_Delete(&aa0, r);
205 
206  clog << ( " >>> TEST DONE!" );
207  clog << endl;
208 
209 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:670
const poly a
Definition: syzextra.cc:212
rational (GMP) numbers
Definition: coeffs.h:31
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
#define TS_ASSERT(e)
Definition: TestSuite.h:239
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the sum a+b
Definition: coeffs.h:647
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:637
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:657
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff &#39;a&#39; and &#39;b&#39; represent the same number; they may have different representations.
Definition: coeffs.h:461
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
void TestSum ( const coeffs  r,
const unsigned long  N 
)

Definition at line 31 of file coeffs_test.h.

32 {
33  clog << ( _2S("TEST: sum[0..") + _2S(N) + "]: ");
34  clog << endl;
35 
36  assume( N > 0 ); // just for now...
37 
38  const unsigned long ssss = (N * (N+1)) / 2;
39 
40  number sum1 = n_Init(ssss, r);
41  clog<< "N*(N+1)/2 (int: " << ssss << "): "; PrintSized(sum1, r);
42 
43  number s, ss, i, res;
44 
45  s = n_Init(N , r);
46  i = n_Init(N+1, r);
47  n_InpMult(s, i, r);
48  n_Delete(&i, r);
49 
50  clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r);
51 
52  i = n_Init(2, r);
53  clog<< "2: "; PrintSized(i, r);
54 
55  if( !n_IsZero( i, r) )
56  {
57 #ifdef HAVE_RINGS
58  TS_ASSERT( n_DivBy(s, i, r) );
59 #endif
60 
61  res = n_Div(s, i, r);
62 
63  clog<< "N*(N+1)/2: "; PrintSized(res, r);
64 
65 
66  number d = n_Sub(res, sum1, r);
67  TS_ASSERT( n_IsZeroDivisor(d, r) );
68  n_Delete(&d, r);
69 
70  if( n_GetChar(r) == 0 )
71  {
72  TS_ASSERT( n_Equal(sum1, res, r) );
73  TS_ASSERT( n_Equal(res, sum1, r) );
74  }
75  } else
77 
78 
79  n_Delete(&s, r); n_Delete(&i, r);
80 
81  n_Delete(&sum1, r); n_Delete(&res, r);
82 
83 
84  s = n_Init(0 , r);
85  ss = n_Init(0 , r);
86  for( int k = N; k >= 0; k-- )
87  {
88  i = n_Init(k, r);
89  n_InpAdd(s, i, r); // s += i
90 
91  i = n_InpNeg(i, r);
92  n_InpAdd(ss, i, r); // ss -= i
93 
94  n_Delete(&i, r);
95  }
96  clog<< "ss: "; PrintSized(ss, r);
97 
98  ss = n_InpNeg(ss, r); // ss = -ss
99 
100  clog<< "real sum : "; PrintSized(s, r);
101  clog<< "real sum(--): "; PrintSized(ss, r);
102 
103  TS_ASSERT( n_Equal(s, ss, r) );
104  TS_ASSERT( n_Equal(ss, s, r) );
105 
106  n_Delete(&s, r);
107  n_Delete(&ss, r);
108 
109  clog << ( " >>> TEST DONE!" );
110  clog << endl;
111 
112 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:670
const CanonicalForm int s
Definition: facAbsFact.cc:55
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the product a*b
Definition: coeffs.h:642
#define TS_ASSERT_EQUALS(x, y)
Definition: TestSuite.h:255
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
BOOLEAN n_IsZeroDivisor(number a, const coeffs r)
Test whether a is a zero divisor in r i.e. not coprime with char. of r very inefficient implementatio...
Definition: numbers.cc:131
static FORCE_INLINE int n_GetChar(const coeffs r)
Return the characteristic of the coeff. domain.
Definition: coeffs.h:445
int k
Definition: cfEzgcd.cc:93
#define TS_ASSERT(e)
Definition: TestSuite.h:239
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of &#39;a&#39; and &#39;b&#39;; replacement of &#39;a&#39; by the sum a+b
Definition: coeffs.h:647
poly res
Definition: myNF.cc:322
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether &#39;a&#39; is divisible &#39;b&#39;; for r encoding a field: TRUE iff &#39;b&#39; does not represent zero in Z:...
Definition: coeffs.h:776
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:558
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:616
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff &#39;a&#39; and &#39;b&#39; represent the same number; they may have different representations.
Definition: coeffs.h:461
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456

Variable Documentation

GlobalPrintingFixture globalPrintingFixture
static

Definition at line 356 of file coeffs_test.h.