[16f511] | 1 | #ifdef HAVE_CONFIG_H |
---|
[ba5e9e] | 2 | #include "libpolysconfig.h" |
---|
[16f511] | 3 | #endif /* HAVE_CONFIG_H */ |
---|
[1820e7] | 4 | #include <misc/auxiliary.h> |
---|
| 5 | #include <omalloc/omalloc.h> |
---|
| 6 | |
---|
[b27c052] | 7 | |
---|
[1820e7] | 8 | #include <reporter/reporter.h> |
---|
[2c889f] | 9 | #include <resources/feResource.h> |
---|
[1820e7] | 10 | |
---|
| 11 | #include <coeffs/coeffs.h> |
---|
| 12 | #include <coeffs/numbers.h> |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | // the following headers are private... |
---|
| 16 | #include <coeffs/longrat.h> |
---|
| 17 | #include <coeffs/gnumpfl.h> |
---|
| 18 | #include <coeffs/gnumpc.h> |
---|
| 19 | #include <coeffs/shortfl.h> |
---|
| 20 | #include <coeffs/ffields.h> |
---|
| 21 | #include <coeffs/modulop.h> |
---|
| 22 | #include <coeffs/rmodulon.h> |
---|
| 23 | #include <coeffs/rmodulo2m.h> |
---|
| 24 | #include <coeffs/rintegers.h> |
---|
| 25 | |
---|
| 26 | |
---|
[4f684a] | 27 | #include "common.h" |
---|
[1820e7] | 28 | using namespace std; |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | void TestSum(const coeffs r, const unsigned long N) |
---|
| 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; |
---|
[f323dd1] | 39 | |
---|
[1820e7] | 40 | number sum1 = n_Init(ssss, r); |
---|
[e5422d] | 41 | clog<< "N*(N+1)/2 (int: " << ssss << "): "; PrintSized(sum1, r); |
---|
[1820e7] | 42 | |
---|
| 43 | number s, ss, i, res; |
---|
| 44 | |
---|
| 45 | s = n_Init(N , r); |
---|
| 46 | i = n_Init(N+1, r); |
---|
| 47 | ndInpMult(s, i, r); |
---|
| 48 | n_Delete(&i, r); |
---|
[f323dd1] | 49 | |
---|
| 50 | clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r); |
---|
| 51 | |
---|
[1820e7] | 52 | i = n_Init(2, r); |
---|
[f323dd1] | 53 | clog<< "2: "; PrintSized(i, r); |
---|
[1820e7] | 54 | |
---|
| 55 | if( !n_IsZero( i, r) ) |
---|
| 56 | { |
---|
[6c5f32] | 57 | #ifdef HAVE_RINGS |
---|
[1820e7] | 58 | TS_ASSERT( n_DivBy(s, i, r) ); |
---|
[6c5f32] | 59 | #endif |
---|
[f323dd1] | 60 | |
---|
[1820e7] | 61 | res = n_Div(s, i, r); |
---|
[f323dd1] | 62 | |
---|
[e5422d] | 63 | clog<< "N*(N+1)/2: "; PrintSized(res, r); |
---|
[b27c052] | 64 | |
---|
| 65 | |
---|
[e5422d] | 66 | number d = n_Sub(res, sum1, r); |
---|
[6c084af] | 67 | TS_ASSERT( n_IsZeroDivisor(d, r) ); |
---|
[b27c052] | 68 | n_Delete(&d, r); |
---|
[f323dd1] | 69 | |
---|
[e5422d] | 70 | if( n_GetChar(r) == 0 ) |
---|
| 71 | { |
---|
| 72 | TS_ASSERT( n_Equal(sum1, res, r) ); |
---|
| 73 | TS_ASSERT( n_Equal(res, sum1, r) ); |
---|
| 74 | } |
---|
[1820e7] | 75 | } else |
---|
| 76 | TS_ASSERT_EQUALS( n_GetChar(r), 2); |
---|
[f323dd1] | 77 | |
---|
[1820e7] | 78 | |
---|
| 79 | n_Delete(&s, r); n_Delete(&i, r); |
---|
[f323dd1] | 80 | |
---|
| 81 | n_Delete(&sum1, r); n_Delete(&res, r); |
---|
| 82 | |
---|
[1820e7] | 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 | ndInpAdd(s, i, r); // s += i |
---|
| 90 | |
---|
| 91 | i = n_Neg(i, r); |
---|
| 92 | ndInpAdd(ss, i, r); // ss -= i |
---|
[f323dd1] | 93 | |
---|
| 94 | n_Delete(&i, r); |
---|
[1820e7] | 95 | } |
---|
[f323dd1] | 96 | clog<< "ss: "; PrintSized(ss, r); |
---|
[1820e7] | 97 | |
---|
| 98 | ss = n_Neg(ss, r); // ss = -ss |
---|
[f323dd1] | 99 | |
---|
[e5422d] | 100 | clog<< "real sum : "; PrintSized(s, r); |
---|
[f323dd1] | 101 | clog<< "real sum(--): "; PrintSized(ss, r); |
---|
[e5422d] | 102 | |
---|
[1820e7] | 103 | TS_ASSERT( n_Equal(s, ss, r) ); |
---|
| 104 | TS_ASSERT( n_Equal(ss, s, r) ); |
---|
| 105 | |
---|
[f323dd1] | 106 | n_Delete(&s, r); |
---|
| 107 | n_Delete(&ss, r); |
---|
[e5422d] | 108 | |
---|
| 109 | clog << ( " >>> TEST DONE!" ); |
---|
| 110 | clog << endl; |
---|
| 111 | |
---|
[1820e7] | 112 | } |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | void TestArith(const coeffs r) |
---|
| 116 | { |
---|
| 117 | clog << ("TEST: Simple Arithmetics: "); |
---|
| 118 | clog << endl; |
---|
| 119 | |
---|
[99ae0c] | 120 | number two = n_Init(2, r); |
---|
| 121 | |
---|
[f323dd1] | 122 | number t = n_Init(1, r); |
---|
| 123 | ndInpAdd(t, t, r); |
---|
[99ae0c] | 124 | TS_ASSERT( n_Equal(two, t, r) ); |
---|
| 125 | n_Delete(&t, r); |
---|
[f323dd1] | 126 | |
---|
[99ae0c] | 127 | if( getCoeffType(r) == n_Q ) |
---|
| 128 | { |
---|
[f323dd1] | 129 | number t = n_Init(1, r); |
---|
[99ae0c] | 130 | nlInpAdd(t, t, r); |
---|
| 131 | TS_ASSERT( n_Equal(two, t, r) ); |
---|
| 132 | n_Delete(&t, r); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | |
---|
[f323dd1] | 137 | |
---|
[99ae0c] | 138 | const int N = 66666; |
---|
| 139 | |
---|
| 140 | number a = n_Init(N, r); |
---|
[f323dd1] | 141 | |
---|
[1820e7] | 142 | clog<< "a: "; PrintSized(a, r); |
---|
| 143 | |
---|
[f323dd1] | 144 | |
---|
[1820e7] | 145 | clog<< "two: "; PrintSized(two, r); |
---|
| 146 | |
---|
[99ae0c] | 147 | number aa0 = n_Init(N*2, r); |
---|
| 148 | |
---|
[1820e7] | 149 | number aa = n_Add(a, a, r); |
---|
| 150 | |
---|
| 151 | clog<< "aa = a + a: "; PrintSized(aa, r); |
---|
[f323dd1] | 152 | |
---|
[1820e7] | 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); |
---|
[f323dd1] | 158 | |
---|
[1820e7] | 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 ); |
---|
[f323dd1] | 166 | |
---|
[1820e7] | 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 | |
---|
[f323dd1] | 191 | |
---|
[1820e7] | 192 | TS_ASSERT( n_Equal(aa, aa1, r) ); |
---|
| 193 | TS_ASSERT( n_Equal(aa, aa2, r) ); |
---|
| 194 | TS_ASSERT( n_Equal(aa1, aa2, r) ); |
---|
[f323dd1] | 195 | |
---|
[99ae0c] | 196 | TS_ASSERT( n_Equal(aa0, aa, r) ); |
---|
| 197 | TS_ASSERT( n_Equal(aa0, aa1, r) ); |
---|
| 198 | TS_ASSERT( n_Equal(aa0, aa2, r) ); |
---|
[1820e7] | 199 | |
---|
| 200 | n_Delete(&aa, r); |
---|
| 201 | n_Delete(&aa1, r); |
---|
| 202 | n_Delete(&aa2, r); |
---|
[e5422d] | 203 | |
---|
[99ae0c] | 204 | n_Delete(&aa0, r); |
---|
[e5422d] | 205 | |
---|
| 206 | clog << ( " >>> TEST DONE!" ); |
---|
| 207 | clog << endl; |
---|
| 208 | |
---|
[1820e7] | 209 | } |
---|
| 210 | |
---|
| 211 | |
---|
| 212 | |
---|
[f323dd1] | 213 | |
---|
[1820e7] | 214 | |
---|
| 215 | BOOLEAN Test(const n_coeffType type, void* p = NULLp) |
---|
| 216 | { |
---|
[f323dd1] | 217 | |
---|
[1820e7] | 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" ); |
---|
[ae85a3] | 227 | return FALSE; |
---|
[1820e7] | 228 | }; |
---|
| 229 | |
---|
[ae85a3] | 230 | TS_ASSERT_DIFFERS( r->cfCoeffWrite, NULLp ); |
---|
| 231 | |
---|
| 232 | if( r->cfCoeffWrite != NULL ) |
---|
| 233 | { |
---|
[f323dd1] | 234 | clog << "Coeff-domain: " << endl; |
---|
[ae85a3] | 235 | n_CoeffWrite(r); PrintLn(); |
---|
| 236 | } |
---|
| 237 | |
---|
[7fee876] | 238 | if (n_NumberOfParameters(r) > 0) |
---|
[1820e7] | 239 | { |
---|
[7fee876] | 240 | number z = n_Param(1, r); // also any integer instead of 0//? |
---|
| 241 | PrintS("Parameter: "); PrintSized(z, r); |
---|
| 242 | n_Delete(&z, r); |
---|
[1820e7] | 243 | } |
---|
[7fee876] | 244 | |
---|
[1820e7] | 245 | |
---|
[f323dd1] | 246 | clog << "Char: " << n_GetChar(r) << endl; |
---|
| 247 | |
---|
[1820e7] | 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 ); |
---|
[ce1f78] | 254 | TS_ASSERT_DIFFERS( r->cfWriteLong, NULLp ); |
---|
[1820e7] | 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 ); |
---|
[f323dd1] | 265 | |
---|
[1820e7] | 266 | TS_ASSERT( nCoeff_is_Q( r )); |
---|
| 267 | TS_ASSERT( nCoeff_is_Domain( r )); |
---|
[e5422d] | 268 | |
---|
| 269 | TS_ASSERT( !nCoeff_has_Units( r )); // ? |
---|
| 270 | TS_ASSERT( !nCoeff_has_simple_inverse( r ));// ? |
---|
| 271 | TS_ASSERT( !nCoeff_has_simple_Alloc( r )); // ? |
---|
[1820e7] | 272 | |
---|
| 273 | TS_ASSERT( !nCoeff_is_Ring_2toM( r )); |
---|
| 274 | TS_ASSERT( !nCoeff_is_Ring_ModN( r )); |
---|
| 275 | TS_ASSERT( !nCoeff_is_Ring_PtoM( r )); |
---|
| 276 | TS_ASSERT( !nCoeff_is_Ring_Z( r )); |
---|
| 277 | TS_ASSERT( !nCoeff_is_Ring( r )); |
---|
| 278 | TS_ASSERT( !nCoeff_is_Zp( r )); |
---|
| 279 | TS_ASSERT( !nCoeff_is_numeric( 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 )); |
---|
| 285 | TS_ASSERT( !nCoeff_is_Extension( r )); |
---|
[f323dd1] | 286 | |
---|
[1820e7] | 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 | { |
---|
[7fee876] | 298 | // TS_ASSERT_EQUALS( r->cfInit, ngcInit ); |
---|
| 299 | // TS_ASSERT_EQUALS( r->cfAdd, ngcAdd ); |
---|
| 300 | // TS_ASSERT_EQUALS( r->cfDelete, ngcDelete ); |
---|
[1820e7] | 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 | { |
---|
[7fee876] | 312 | // TS_ASSERT_EQUALS( r->cfInit, nfInit ); |
---|
| 313 | // TS_ASSERT_EQUALS( r->cfAdd, nfAdd ); |
---|
[1820e7] | 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 ); |
---|
[e5422d] | 340 | TestSum( r, 10 ); |
---|
[1820e7] | 341 | TestSum( r, 100 ); |
---|
[e5422d] | 342 | TestSum( r, 101 ); |
---|
| 343 | TestSum( r, 1001 ); |
---|
| 344 | TestSum( r, 9000 ); |
---|
[1820e7] | 345 | |
---|
| 346 | nKillChar( r ); |
---|
| 347 | |
---|
| 348 | return TRUE; |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | |
---|
[4f684a] | 352 | |
---|
[ae85a3] | 353 | // We can rely on this file being included exactly once |
---|
| 354 | // and declare this global variable in the header file. |
---|
| 355 | // |
---|
| 356 | static GlobalPrintingFixture globalPrintingFixture; |
---|
| 357 | |
---|
| 358 | |
---|
[f323dd1] | 359 | class CoeffsTestSuite : public CxxTest::TestSuite |
---|
[1820e7] | 360 | { |
---|
| 361 | public: |
---|
[4f684a] | 362 | // void test_dummy() { float fnum = 2.00001f; TS_ASSERT_DELTA (fnum, 2.0f, 0.0001f); } |
---|
[1820e7] | 363 | |
---|
| 364 | void test_Z2m4() |
---|
| 365 | { |
---|
| 366 | #ifdef HAVE_RINGS |
---|
[7af488e] | 367 | n_coeffType type = n_Z2m; |
---|
[1820e7] | 368 | TS_ASSERT( Test(type, (void*) 4) ); |
---|
| 369 | #endif |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | void test_Zp101() |
---|
| 373 | { |
---|
[7af488e] | 374 | n_coeffType type = n_Zp; |
---|
[1820e7] | 375 | TS_ASSERT( Test(type, (void*) 101) ); |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | void test_Z2m8() |
---|
| 379 | { |
---|
| 380 | #ifdef HAVE_RINGS |
---|
[7af488e] | 381 | n_coeffType type = n_Z2m; |
---|
[1820e7] | 382 | TS_ASSERT( Test(type, (void*) 8) ); |
---|
| 383 | #endif |
---|
| 384 | } |
---|
[f323dd1] | 385 | |
---|
[7af488e] | 386 | void simple(const n_coeffType _type) |
---|
[1820e7] | 387 | { |
---|
[7af488e] | 388 | n_coeffType type = _type; |
---|
[1820e7] | 389 | TS_ASSERT( type == _type ); // ? |
---|
| 390 | TS_ASSERT( Test(type) ); |
---|
| 391 | } |
---|
[f323dd1] | 392 | |
---|
[1820e7] | 393 | void test_Q() |
---|
| 394 | { |
---|
[7af488e] | 395 | simple(n_Q); |
---|
[1820e7] | 396 | } |
---|
[f323dd1] | 397 | |
---|
[1820e7] | 398 | void test_R() |
---|
| 399 | { |
---|
[7af488e] | 400 | simple(n_R); |
---|
[1820e7] | 401 | } |
---|
| 402 | |
---|
| 403 | |
---|
| 404 | void test_Z() |
---|
| 405 | { |
---|
| 406 | #ifdef HAVE_RINGS |
---|
[7af488e] | 407 | simple(n_Z); // No need in GMP? |
---|
[1820e7] | 408 | #endif |
---|
| 409 | } |
---|
| 410 | |
---|
[f323dd1] | 411 | |
---|
[1820e7] | 412 | void test_GF_toobig() |
---|
| 413 | { |
---|
[7af488e] | 414 | n_coeffType type = n_GF; |
---|
[1820e7] | 415 | |
---|
| 416 | GFInfo param; |
---|
| 417 | |
---|
| 418 | param.GFChar= 5; |
---|
| 419 | param.GFDegree= 12; |
---|
| 420 | param.GFPar_name= (const char*)"q"; |
---|
| 421 | |
---|
| 422 | TS_ASSERT( !Test(type, (void*) ¶m) ); |
---|
| 423 | |
---|
[f323dd1] | 424 | // it should not be used by numbers... right? |
---|
[1820e7] | 425 | // TODO: what is our policy wrt param-pointer-ownership? |
---|
| 426 | } |
---|
| 427 | |
---|
| 428 | void test_GF() |
---|
| 429 | { |
---|
| 430 | // TODO: what if it was already registered? |
---|
| 431 | // Q: no way to deRegister a type? |
---|
[7af488e] | 432 | n_coeffType type = n_GF; |
---|
[1820e7] | 433 | |
---|
| 434 | GFInfo param; |
---|
| 435 | |
---|
| 436 | param.GFChar= 5; |
---|
| 437 | param.GFDegree= 2; |
---|
| 438 | param.GFPar_name= (const char*)"Q"; |
---|
| 439 | |
---|
| 440 | TS_ASSERT( Test(type, (void*) ¶m) ); |
---|
| 441 | |
---|
[f323dd1] | 442 | // it should not be used by numbers... right? |
---|
[1820e7] | 443 | // TODO: what is our policy wrt param-pointer-ownership? |
---|
| 444 | } |
---|
[f323dd1] | 445 | |
---|
[1820e7] | 446 | |
---|
| 447 | void test_Zn3() |
---|
| 448 | { |
---|
| 449 | #ifdef HAVE_RINGS |
---|
[7af488e] | 450 | n_coeffType type = n_Zn; |
---|
[1820e7] | 451 | |
---|
[c3304a] | 452 | ZnmInfo Znmparam; |
---|
| 453 | Znmparam.base= (mpz_ptr) omAlloc (sizeof (mpz_t)); |
---|
| 454 | mpz_init_set_ui (Znmparam.base, 3); |
---|
| 455 | Znmparam.exp= 1; |
---|
[c7d05f] | 456 | |
---|
[c3304a] | 457 | TS_ASSERT( Test(type, (void*) &Znmparam) ); |
---|
[1820e7] | 458 | #endif |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | void test_Z2m2() |
---|
| 462 | { |
---|
| 463 | #ifdef HAVE_RINGS |
---|
[7af488e] | 464 | n_coeffType type = n_Z2m; |
---|
[1820e7] | 465 | |
---|
| 466 | TS_ASSERT( Test(type, (void*) 2) ); |
---|
| 467 | #endif |
---|
| 468 | } |
---|
| 469 | |
---|
| 470 | void test_LR() |
---|
| 471 | { |
---|
[7af488e] | 472 | simple(n_long_R); |
---|
[1820e7] | 473 | } |
---|
[f323dd1] | 474 | |
---|
[1820e7] | 475 | void test_LC() |
---|
| 476 | { |
---|
[7af488e] | 477 | simple(n_long_C); |
---|
[06df101] | 478 | } |
---|
[f323dd1] | 479 | |
---|
[06df101] | 480 | void test_Q_special() |
---|
| 481 | { |
---|
| 482 | const coeffs cf = nInitChar(n_Q, NULLp); |
---|
| 483 | |
---|
| 484 | if (cf == NULLp) |
---|
| 485 | clog << ( "Test: could not get this coeff. domain" ); |
---|
| 486 | |
---|
| 487 | TS_ASSERT_DIFFERS(cf->cfCoeffWrite, NULLp); |
---|
| 488 | |
---|
| 489 | if (cf->cfCoeffWrite != NULL ) |
---|
| 490 | { |
---|
[f323dd1] | 491 | clog << "Coeff-domain: " << endl; |
---|
[06df101] | 492 | n_CoeffWrite(cf); PrintLn(); |
---|
| 493 | } |
---|
[f323dd1] | 494 | |
---|
[06df101] | 495 | number q1 = n_Init(21, cf); |
---|
| 496 | number q2 = n_Init(2, cf); |
---|
| 497 | number q3 = n_Div(q1, q2, cf); |
---|
| 498 | number q4 = n_Init(30, cf); |
---|
| 499 | number q5 = n_Mult(q3, q4, cf); |
---|
| 500 | TS_ASSERT(n_Test(q5, cf)); |
---|
| 501 | Print("21/2 * 30 = %d\n", n_Int(q5, cf)); |
---|
| 502 | TS_ASSERT(n_Test(q5, cf)); |
---|
| 503 | n_Delete(&q1, cf); |
---|
| 504 | n_Delete(&q2, cf); |
---|
| 505 | n_Delete(&q3, cf); |
---|
| 506 | n_Delete(&q4, cf); |
---|
| 507 | n_Delete(&q5, cf); |
---|
| 508 | } |
---|
[1820e7] | 509 | }; |
---|
| 510 | |
---|