Changeset 7af488e in git
 Timestamp:
 May 27, 2011, 11:39:02 AM (12 years ago)
 Branches:
 (u'jengelhdatetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
 Children:
 9bb545791780a99344a26d6177decb3870f6da87
 Parents:
 6ccdd3ad26bd7de442ab57e7cc95352fcf0de398
 gitauthor:
 Hans Schoenemann <hannes@mathematik.unikl.de>20110527 11:39:02+02:00
 gitcommitter:
 Mohamed Barakat <mohamed.barakat@rwthaachen.de>20111109 12:39:06+01:00
 Location:
 libpolys
 Files:

 6 edited
Legend:
 Unmodified
 Added
 Removed

libpolys/coeffs/numbers.cc
r6ccdd3a r7af488e 30 30 #endif 31 31 32 #ifdef HAVE_POLYEXTENSIONS 33 #include <polys/ext_fields/algext.h> 34 #endif 35 32 36 #ifdef HAVE_FACTORY 33 37 #include <factory/factory.h> … … 153 157 } 154 158 155 static n_coeffType nLastCoeffs=n_Z2m; 156 static cfInitCharProc *nInitCharTable=NULL; 159 static n_coeffType nLastCoeffs=n_CF; 160 cfInitCharProc nInitCharTableDefault[]= 161 { NULL, /*n_unknown */ 162 npInitChar, /* n_Zp */ 163 nlInitChar, /* n_Q */ 164 nrInitChar, /* n_R */ 165 nfInitChar, /* n_GF */ 166 ngfInitChar, /* n_long_R */ 167 #ifdef HAVE_POLYEXTENSIONS 168 naInitChar, /* n_algExt */ 169 #else 170 NULL, /* n_algExt */ 171 #endif 172 NULL, /* n_transExt */ 173 ngcInitChar, /* n_long_C */ 174 #ifdef HAVE_RINGS 175 nrzInitChar, /* n_Z */ 176 nrnInitChar, /* n_Zn */ 177 NULL, /* n_Zpn */ 178 nr2mInitChar, /* n_Z2m */ 179 #else 180 NULL, /* n_Z */ 181 NULL, /* n_Zn */ 182 NULL, /* n_Zpn */ 183 NULL, /* n_Z2m */ 184 #endif 185 NULL /* n_CF */ 186 }; 187 188 static cfInitCharProc *nInitCharTable=nInitCharTableDefault; 157 189 /*2 158 190 * init operations for coeffs r … … 206 238 BOOLEAN nOK=TRUE; 207 239 // init 208 if (( nInitCharTable!=NULL) && (t<=nLastCoeffs))240 if ((t<=nLastCoeffs) && (nInitCharTable[t]!=NULL)) 209 241 nOK = (nInitCharTable[t])(n,parameter); 210 242 else 211 Werror(" coeff init missing for %d",(int)t);243 Werror("nInitCharTable[%d] missing",(int)t); 212 244 if (nOK) 213 245 { … … 311 343 } 312 344 345 313 346 n_coeffType nRegister(n_coeffType n, cfInitCharProc p) 314 347 { … … 316 349 { 317 350 nLastCoeffs=(n_coeffType)(int(nLastCoeffs)+1); 318 if (nInitCharTable== NULL)351 if (nInitCharTable==nInitCharTableDefault) 319 352 { 320 353 nInitCharTable=(cfInitCharProc*)omAlloc0( 321 354 nLastCoeffs*sizeof(cfInitCharProc)); 355 memcpy(nInitCharTable,nInitCharTableDefault, 356 (nLastCoeffs1)*sizeof(cfInitCharProc)); 322 357 } 323 358 else … … 333 368 else 334 369 { 335 if (nInitCharTable==NULL) 336 { 337 nInitCharTable=(cfInitCharProc*)omAlloc0( 338 ((int) nLastCoeffs)*sizeof(cfInitCharProc)); 339 } 370 if (nInitCharTable[n]!=NULL) Print("coeff %d already initialized\n",n); 340 371 nInitCharTable[n]=p; 341 372 return n; 
libpolys/coeffs/test.cc
r6ccdd3a r7af488e 274 274 #ifdef HAVE_RINGS 275 275 // TODO(Frank, Segmentation fault! (if used wihout omalloc???). Please_ investigate!); 276 type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m );276 type = n_Z2m; 277 277 if( Test(type, (void*) 4) ) 278 278 c ++; 279 279 #endif 280 280 281 type = nRegister( n_Zp, npInitChar); assume( type == n_Zp );281 type = n_Zp; 282 282 if( Test(type, (void*) 101) ) 283 283 c ++; … … 286 286 // TODO(Frank, memmory corruption_ if used wihout omalloc??? Please_ investigate!); 287 287 288 type = n Register( n_Z2m, nr2mInitChar); assume( type == n_Z2m );288 type = n_Z2m; 289 289 if( Test(type, (void*) 8) ) 290 290 c ++; … … 293 293 294 294 295 type = nRegister( n_Q, nlInitChar); assume( type == n_Q );296 if( Test(type) ) 297 c ++; 298 299 type = n Register( n_R, nrInitChar); assume( type == n_R );300 if( Test(type) ) 301 c ++; 302 303 #ifdef HAVE_RINGS 304 type = n Register( n_Z, nrzInitChar); assume( type == n_Z ); // No need in GMP?305 if( Test(type) ) 306 c ++; 307 #endif 308 type = n Register( n_GF, nfInitChar); assume( type == n_GF );295 type = n_Q; 296 if( Test(type) ) 297 c ++; 298 299 type = n_R; 300 if( Test(type) ) 301 c ++; 302 303 #ifdef HAVE_RINGS 304 type = n_Z; 305 if( Test(type) ) 306 c ++; 307 #endif 308 type = n_GF; 309 309 310 310 … … 340 340 // TODO(Somebody, This will result in memory corruption at Z_2^m later on (due to the succs. setGMPFloatDigits?)...!?); // ???? 341 341 342 type = n Register( n_Zn, nrnInitChar); assume( type == n_Zn );342 type = n_Zn; 343 343 344 344 if( Test(type, (void*) 3) ) … … 351 351 352 352 353 type = n Register( n_long_C, ngcInitChar); assume( type == n_long_C );354 if( Test(type) ) 355 c ++; 356 357 type = n Register( n_long_R, ngfInitChar); assume( type == n_long_R );358 if( Test(type) ) 359 c ++; 360 361 #ifdef HAVE_RINGS 362 type = n Register( n_Z2m, nr2mInitChar); assume( type == n_Z2m );353 type = n_long_C; 354 if( Test(type) ) 355 c ++; 356 357 type = n_long_R; 358 if( Test(type) ) 359 c ++; 360 361 #ifdef HAVE_RINGS 362 type = n_Z2m; 363 363 if( Test(type, (void*) 2) ) 364 364 c ++; … … 367 367 368 368 #ifdef HAVE_RINGS 369 type = n Register( n_Zn, nrnInitChar); assume( type == n_Zn );369 type = n_Zn; 370 370 371 371 if( Test(type, (void*) 3) ) 
libpolys/misc/auxiliary.h.in
r6ccdd3a r7af488e 39 39 #endif 40 40 41 #ifndef HAVE_POLYEXTENSIONS 42 #undef HAVE_POLYEXTENSIONS 43 #endif 41 44 //  end of parts/extensions 42 45 //  configure stuff 
libpolys/tests/coeffs_test.h
r6ccdd3a r7af488e 370 370 { 371 371 #ifdef HAVE_RINGS 372 n_coeffType type = n Register( n_Z2m, nr2mInitChar); TS_ASSERT( type == n_Z2m );372 n_coeffType type = n_Z2m; 373 373 TS_ASSERT( Test(type, (void*) 4) ); 374 374 #endif … … 377 377 void test_Zp101() 378 378 { 379 n_coeffType type = n Register( n_Zp, npInitChar); TS_ASSERT( type == n_Zp );379 n_coeffType type = n_Zp; 380 380 TS_ASSERT( Test(type, (void*) 101) ); 381 381 } … … 384 384 { 385 385 #ifdef HAVE_RINGS 386 n_coeffType type = nRegister( n_Z2m, nr2mInitChar); TS_ASSERT( type == n_Z2m );386 n_coeffType type = n_Z2m; 387 387 TS_ASSERT( Test(type, (void*) 8) ); 388 388 #endif 389 389 } 390 390 391 void simple(const n_coeffType _type , cfInitCharProc p)392 { 393 n_coeffType type = nRegister( _type, p);391 void simple(const n_coeffType _type) 392 { 393 n_coeffType type = _type; 394 394 TS_ASSERT( type == _type ); // ? 395 395 TS_ASSERT( Test(type) ); … … 398 398 void test_Q() 399 399 { 400 simple(n_Q , nlInitChar);400 simple(n_Q); 401 401 } 402 402 403 403 void test_R() 404 404 { 405 simple(n_R , nrInitChar);405 simple(n_R); 406 406 } 407 407 … … 410 410 { 411 411 #ifdef HAVE_RINGS 412 simple(n_Z , nrzInitChar); // No need in GMP?412 simple(n_Z); // No need in GMP? 413 413 #endif 414 414 } … … 417 417 void test_GF_toobig() 418 418 { 419 n_coeffType type = nRegister( n_GF, nfInitChar); 420 TS_ASSERT( type == n_GF ); 419 n_coeffType type = n_GF; 421 420 422 421 GFInfo param; … … 436 435 // TODO: what if it was already registered? 437 436 // Q: no way to deRegister a type? 438 n_coeffType type = nRegister( n_GF, nfInitChar); 439 TS_ASSERT( type == n_GF ); 437 n_coeffType type = n_GF; 440 438 441 439 GFInfo param; … … 456 454 #ifdef HAVE_RINGS 457 455 // TODO(Somebody, This will result in memory corruption at Z_2^m later on (due to the succs. setGMPFloatDigits?)...!?); // ???? 458 n_coeffType type = n Register( n_Zn, nrnInitChar); TS_ASSERT( type == n_Zn );456 n_coeffType type = n_Zn; 459 457 460 458 TS_ASSERT( Test(type, (void*) 3) ); … … 465 463 { 466 464 #ifdef HAVE_RINGS 467 n_coeffType type = n Register( n_Z2m, nr2mInitChar); TS_ASSERT( type == n_Z2m );465 n_coeffType type = n_Z2m; 468 466 469 467 TS_ASSERT( Test(type, (void*) 2) ); … … 476 474 { 477 475 setGMPFloatDigits( 10, 5 ); // Init global variables in mpr_complex.cc for gmp_float's... // Note that this seems also to be required for Z_2^m (and Zn?)!???? 478 simple(n_long_R , ngfInitChar);476 simple(n_long_R); 479 477 } 480 478 … … 482 480 { 483 481 setGMPFloatDigits( 10, 5 ); // Init global variables in mpr_complex.cc for gmp_float's... // Note that this seems also to be required for Z_2^m (and Zn?)!???? 484 simple(n_long_C , ngcInitChar);482 simple(n_long_C); 485 483 } 486 484 
libpolys/tests/polys_test.h
r6ccdd3a r7af488e 31 31 virtual bool setUpWorld() 32 32 { 33 33 34 34 GlobalPrintingFixture::setUpWorld(); 35 36 37 TS_ASSERT_EQUALS( nRegister( n_Zp, npInitChar), n_Zp );38 TS_ASSERT_EQUALS( nRegister( n_GF, nfInitChar), n_GF );39 TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );40 TS_ASSERT_EQUALS( nRegister( n_Q, nlInitChar), n_Q );41 TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );42 35 36 37 //TS_ASSERT_EQUALS( nRegister( n_Zp, npInitChar), n_Zp ); 38 //TS_ASSERT_EQUALS( nRegister( n_GF, nfInitChar), n_GF ); 39 //TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R ); 40 //TS_ASSERT_EQUALS( nRegister( n_Q, nlInitChar), n_Q ); 41 //TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R ); 42 43 43 #ifdef HAVE_RINGS 44 TS_ASSERT_EQUALS( nRegister( n_Z, nrzInitChar), n_Z ); // these are UNusable at the moment!44 //TS_ASSERT_EQUALS( nRegister( n_Z, nrzInitChar), n_Z ); // these are UNusable at the moment! 45 45 #endif 46 46 47 47 return true; 48 48 } … … 59 59 namespace 60 60 { 61 61 62 62 void PrintRing(const ring r) 63 63 { … … 71 71 { 72 72 p_Test(a,r); 73 73 74 74 StringSetS(""); 75 75 p_Write(a, r); … … 79 79 std::stringstream ss; ss << s; 80 80 81 StringSetS(""); 81 StringSetS(""); 82 82 return ss.str(); 83 83 } … … 87 87 std::clog << _2S(a, r) << ", of size: " << p_Size(a, r); 88 88 89 if( eoln ) 90 std::clog << std::endl; 89 if( eoln ) 90 std::clog << std::endl; 91 91 } 92 92 … … 103 103 TS_ASSERT_DIFFERS( r , NULLp); 104 104 TS_ASSERT_DIFFERS( r>cf, NULLp); 105 106 105 106 107 107 clog << ( _2S("TEST: sum[0..") + _2S(N) + "]: "); 108 108 clog << endl; … … 111 111 112 112 const int ssss = (N * (N+1)) / 2; 113 113 114 114 poly sum1 = p_ISet(ssss, r); 115 115 clog<< "poly(N*(N+1)/2) (int: " << ssss << "): "; PrintSized(sum1, r); … … 122 122 i = p_Mult_q(s, i, r); s = NULL; 123 123 124 clog<< "poly(N)*poly(N+1): (int: "<< N*(N+1) << "): "; PrintSized(i, r); 124 clog<< "poly(N)*poly(N+1): (int: "<< N*(N+1) << "): "; PrintSized(i, r); 125 125 126 126 number t = n_Init(2, r>cf); 127 clog<< "number(2): "; PrintSized(t, r>cf); 127 clog<< "number(2): "; PrintSized(t, r>cf); 128 128 129 129 if( !n_IsZero( t, r>cf) ) … … 132 132 { 133 133 number ii = p_GetCoeff(i, r); 134 clog<< "number(poly(N)*poly(N+1)): "; PrintSized(ii, r>cf); 134 clog<< "number(poly(N)*poly(N+1)): "; PrintSized(ii, r>cf); 135 135 136 136 #ifdef HAVE_RINGS … … 139 139 res = p_Div_nn(i, t, r); i = NULL; 140 140 } 141 142 141 142 143 143 144 144 clog<< "(poly(N)*poly(N+1))/number(2): "; PrintSized(res, r); … … 157 157 } else 158 158 TS_ASSERT_EQUALS( n_GetChar(r>cf), 2); 159 159 160 160 n_Delete(&t, r>cf); 161 161 … … 171 171 ss = p_Add_q(ss, i, r); // ss = i 172 172 } 173 174 clog<< "ss(sum): "; PrintSized(ss, r); 173 174 clog<< "ss(sum): "; PrintSized(ss, r); 175 175 176 176 ss = p_Neg(ss, r); // ss = ss 177 177 178 178 clog<< "real sum : "; PrintSized(s, r); 179 clog<< "real sum(): "; PrintSized(ss, r); 179 clog<< "real sum(): "; PrintSized(ss, r); 180 180 181 181 TS_ASSERT( p_EqualPolys(s, ss, r) ); … … 184 184 TODO(somebody, fix the delete method!); 185 185 186 Delete(sum1, r); 186 Delete(sum1, r); 187 187 Delete(res, r); 188 188 189 Delete(s, r); 190 Delete(ss, r); 189 Delete(s, r); 190 Delete(ss, r); 191 191 192 192 clog << ( " >>> TEST DONE!" ); … … 194 194 195 195 } 196 196 197 197 void Test(const ring r) 198 198 { … … 211 211 } 212 212 213 class PolysTestSuite : public CxxTest::TestSuite 213 class PolysTestSuite : public CxxTest::TestSuite 214 214 { 215 215 private: … … 238 238 number two = n_Init(2, r); 239 239 240 number t = n_Init(1, r); 241 ndInpAdd(t, t, r); 240 number t = n_Init(1, r); 241 ndInpAdd(t, t, r); 242 242 TS_ASSERT( n_Equal(two, t, r) ); 243 243 n_Delete(&t, r); 244 244 245 245 if( getCoeffType(r) == n_Q ) 246 246 { 247 number t = n_Init(1, r); 247 number t = n_Init(1, r); 248 248 nlInpAdd(t, t, r); 249 249 TS_ASSERT( n_Equal(two, t, r) ); 250 250 n_Delete(&t, r); 251 251 } 252 252 253 253 const int N = 66666; 254 254 255 255 number a = n_Init(N, r); 256 256 257 257 clog<< "a: "; PrintSized(a, r); 258 258 … … 264 264 265 265 clog<< "aa = a + a: "; PrintSized(aa, r); 266 266 267 267 number aa2 = n_Mult(a, two, r); 268 268 … … 270 270 271 271 number aa1 = n_Mult(two, a, r); 272 272 273 273 clog<< "aa1 = 2 * a: "; PrintSized(aa1, r); 274 274 … … 277 277 278 278 a = n_Sub( aa, aa1, r ); 279 279 280 280 clog<< "a = aa  aa1: "; PrintSized(a, r); 281 281 … … 303 303 TS_ASSERT( n_Equal(aa, aa2, r) ); 304 304 TS_ASSERT( n_Equal(aa1, aa2, r) ); 305 305 306 306 TS_ASSERT( n_Equal(aa0, aa, r) ); 307 307 TS_ASSERT( n_Equal(aa0, aa1, r) ); … … 325 325 326 326 const unsigned long ssss = (N * (N+1)) / 2; 327 327 328 328 number sum1 = n_Init(ssss, r); 329 329 clog<< "N*(N+1)/2 (int: " << ssss << "): "; PrintSized(sum1, r); … … 335 335 ndInpMult(s, i, r); 336 336 n_Delete(&i, r); 337 338 clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r); 339 337 338 clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r); 339 340 340 i = n_Init(2, r); 341 clog<< "2: "; PrintSized(i, r); 341 clog<< "2: "; PrintSized(i, r); 342 342 343 343 if( !n_IsZero( i, r) ) … … 346 346 TS_ASSERT( n_DivBy(s, i, r) ); 347 347 #endif 348 348 349 349 res = n_Div(s, i, r); 350 350 351 351 clog<< "N*(N+1)/2: "; PrintSized(res, r); 352 352 … … 355 355 TS_ASSERT( n_IsZeroDivisor(d, r) ); 356 356 n_Delete(&d, r); 357 357 358 358 if( n_GetChar(r) == 0 ) 359 359 { … … 363 363 } else 364 364 TS_ASSERT_EQUALS( n_GetChar(r), 2); 365 365 366 366 367 367 n_Delete(&s, r); n_Delete(&i, r); 368 369 n_Delete(&sum1, r); n_Delete(&res, r); 370 368 369 n_Delete(&sum1, r); n_Delete(&res, r); 370 371 371 372 372 s = n_Init(0 , r); … … 379 379 i = n_Neg(i, r); 380 380 ndInpAdd(ss, i, r); // ss = i 381 382 n_Delete(&i, r); 381 382 n_Delete(&i, r); 383 383 } 384 clog<< "ss: "; PrintSized(ss, r); 384 clog<< "ss: "; PrintSized(ss, r); 385 385 386 386 ss = n_Neg(ss, r); // ss = ss 387 387 388 388 clog<< "real sum : "; PrintSized(s, r); 389 clog<< "real sum(): "; PrintSized(ss, r); 389 clog<< "real sum(): "; PrintSized(ss, r); 390 390 391 391 TS_ASSERT( n_Equal(s, ss, r) ); 392 392 TS_ASSERT( n_Equal(ss, s, r) ); 393 393 394 n_Delete(&s, r); 395 n_Delete(&ss, r); 394 n_Delete(&s, r); 395 n_Delete(&ss, r); 396 396 397 397 clog << ( " >>> TEST DONE!" ); … … 405 405 406 406 char* n[] = {"t"}; 407 ring r = rDefault( 13, 1, n); 407 ring r = rDefault( 13, 1, n); 408 408 TS_ASSERT_DIFFERS( r, NULLp ); 409 409 … … 420 420 421 421 Test(r); 422 422 423 423 rDelete(r); 424 424 } … … 429 429 430 430 char* n[] = {"s"}; 431 ring r = rDefault( 0, 1, n); 431 ring r = rDefault( 0, 1, n); 432 432 TS_ASSERT_DIFFERS( r, NULLp ); 433 433 … … 436 436 TS_ASSERT( rField_is_Domain(r) ); 437 437 TS_ASSERT( rField_is_Q(r) ); 438 438 439 439 TS_ASSERT( !rField_is_Zp(r) ); 440 440 TS_ASSERT( !rField_is_Zp(r, 11) ); … … 446 446 rDelete(r); 447 447 } 448 448 449 449 void test_Z11_x_y_z() 450 450 { 451 451 clog << "Creating Z/11[x, y, z]: " << endl; 452 452 453 453 char* n[] = {"x", "y", "z"}; 454 ring r = rDefault( 11, 3, n); 454 ring r = rDefault( 11, 3, n); 455 455 TS_ASSERT_DIFFERS( r, NULLp ); 456 456 457 457 PrintRing(r); 458 458 459 459 TS_ASSERT( rField_is_Domain(r) ); 460 460 TS_ASSERT( !rField_is_Q(r) ); … … 467 467 468 468 Test(r); 469 469 470 470 rDelete(r); 471 471 } … … 475 475 476 476 char* n[] = {"x", "y", "z", "u"}; 477 ring r = rDefault( 0, 4, n); 477 ring r = rDefault( 0, 4, n); 478 478 TS_ASSERT_DIFFERS( r, NULLp ); 479 479 … … 489 489 490 490 Test(r); 491 491 492 492 rDelete(r); 493 493 } … … 535 535 rDelete(r); // kills 'cf' as well! 536 536 } 537 537 538 538 void test_Q_Ext_a() 539 539 { … … 548 548 TS_ASSERT( rField_is_Domain(r) ); 549 549 TS_ASSERT( rField_is_Q(r) ); 550 550 551 551 TS_ASSERT( !rField_is_Zp(r) ); 552 552 TS_ASSERT( !rField_is_Zp(r, 11) ); … … 560 560 minIdeal>m[0] = minPoly; // minIdeal = < a^2 + 1 > 561 561 562 n_coeffType type = nRegister(n_algExt, naInitChar); 562 n_coeffType type = nRegister(n_algExt, naInitChar); 563 563 TS_ASSERT(type == n_algExt); 564 564 … … 566 566 extParam.r = r; 567 567 extParam.i = minIdeal; 568 568 569 569 clog << "Next create the extension field Q[a]/<a2+1>..." << endl; 570 570 571 571 const coeffs cf = nInitChar(type, &extParam); // Q[a]/<a2+1> 572 572 573 573 if( cf == NULL ) 574 574 TS_FAIL("Could not get needed coeff. domain"); 575 575 576 576 TS_ASSERT_DIFFERS( cf>cfCoeffWrite, NULLp ); 577 577 578 578 if( cf>cfCoeffWrite != NULL ) 579 579 { 580 clog << "Coeffdomain: " << endl; 580 clog << "Coeffdomain: " << endl; 581 581 n_CoeffWrite(cf); PrintLn(); 582 582 } 583 583 584 584 TS_ASSERT( nCoeff_is_algExt(cf) ); 585 585 TS_ASSERT( !nCoeff_is_transExt(cf) ); 586 586 587 587 // some tests for the coefficient field represented by cf: 588 588 TestArithCf(cf); … … 595 595 clog << "Finally create the polynomial ring (Q[a]/<a2+1>)[x, y]..." 596 596 << endl; 597 597 598 598 char* m[] = {"x", "y"}; 599 599 ring s = rDefault(cf, 2, m); // (Q[a]/<a2+1>)[x, y] … … 613 613 614 614 Test(s); 615 615 616 616 clog << endl 617 617 << "Now let's compute some inverses in Q[a]/<a^2+1>..." 618 618 << endl; 619 619 620 620 poly u; 621 621 u = NULL; plusTerm(u, 1, 1, 1, cf>extRing); … … 649 649 TS_ASSERT( rField_is_Domain(r) ); 650 650 TS_ASSERT( rField_is_Q(r) ); 651 651 652 652 TS_ASSERT( !rField_is_Zp(r) ); 653 653 TS_ASSERT( !rField_is_Zp(r, 11) ); … … 661 661 minIdeal>m[0] = minPoly; // minIdeal = < b^7 + 17 > 662 662 663 n_coeffType type = nRegister(n_algExt, naInitChar); 663 n_coeffType type = nRegister(n_algExt, naInitChar); 664 664 TS_ASSERT(type == n_algExt); 665 665 … … 667 667 extParam.r = r; 668 668 extParam.i = minIdeal; 669 669 670 670 clog << "Next create the extension field Q[b]/<b^7+17>..." << endl; 671 671 672 672 const coeffs cf = nInitChar(type, &extParam); // Q[b]/<b^7+17> 673 673 674 674 if( cf == NULL ) 675 675 TS_FAIL("Could not get needed coeff. domain"); 676 676 677 677 TS_ASSERT_DIFFERS( cf>cfCoeffWrite, NULLp ); 678 678 679 679 if( cf>cfCoeffWrite != NULL ) 680 680 { 681 clog << "Coeffdomain: " << endl; 681 clog << "Coeffdomain: " << endl; 682 682 n_CoeffWrite(cf); PrintLn(); 683 683 } 684 684 685 685 TS_ASSERT( nCoeff_is_algExt(cf) ); 686 686 TS_ASSERT( !nCoeff_is_transExt(cf) ); 687 687 688 688 // some tests for the coefficient field represented by cf: 689 689 TestArithCf(cf); … … 696 696 clog << "Finally create the polynomial ring (Q[b]/<b^7+17>)[u, v, w]..." 697 697 << endl; 698 698 699 699 char* m[] = {"u", "v", "w"}; 700 700 ring s = rDefault(cf, 3, m); // (Q[b]/<b^7+17>)[u, v, w] … … 714 714 715 715 Test(s); 716 716 717 717 clog << endl 718 718 << "Now let's compute some inverses in Q[b]/<b^7+17>..." 719 719 << endl; 720 720 721 721 poly u; 722 722 u = NULL; plusTerm(u, 1, 1, 2, cf>extRing); … … 730 730 << "Now let's check a gcd computation in Q[b]..." 731 731 << endl; 732 732 733 733 poly v; 734 734 v = NULL; plusTerm(v, 1, 1, 2, cf>extRing); … … 743 743 (number)v, cf); // (b^2 + 7b + 1)^2 * (2b^2  61b) 744 744 p_Delete(&v, cf>extRing); 745 745 746 746 clog << "z = "; p_Write((poly)z, cf>extRing); 747 747 clog << "y = "; p_Write((poly)y, cf>extRing); 748 748 number theGcd = n_Gcd(z, y, cf); // should yield w = (b^2 + 7b + 1)^2 749 749 clog << "gcd(z, y) = "; p_Write((poly)theGcd, cf>extRing); 750 750 751 751 v = (poly)n_Sub(theGcd, w, cf); 752 752 TS_ASSERT( v == NULL ); 753 753 p_Delete(&v, cf>extRing); 754 754 755 755 clog << endl 756 756 << "Now let's check an ext_gcd computation in Q[b]..." 757 757 << endl; 758 758 759 759 poly zFactor; poly yFactor; 760 760 poly ppp = p_ExtGcd((poly)z, zFactor, (poly)y, yFactor, cf>extRing); … … 772 772 number v4 = n_Sub(v3, w, cf); 773 773 TS_ASSERT( v4 == NULL ); 774 774 775 775 p_Delete(&ppp, cf>extRing); p_Delete(&zFactor, cf>extRing); 776 776 p_Delete(&yFactor, cf>extRing); … … 793 793 TS_ASSERT( rField_is_Domain(r) ); 794 794 TS_ASSERT( !rField_is_Q(r) ); 795 795 796 796 TS_ASSERT( rField_is_Zp(r) ); 797 797 TS_ASSERT( rField_is_Zp(r, 17) ); … … 805 805 minIdeal>m[0] = minPoly; // minIdeal = < a^2 + 3 > 806 806 807 n_coeffType type = nRegister(n_algExt, naInitChar); 807 n_coeffType type = nRegister(n_algExt, naInitChar); 808 808 TS_ASSERT(type == n_algExt); 809 809 … … 811 811 extParam.r = r; 812 812 extParam.i = minIdeal; 813 813 814 814 clog << "Next create the extension field Z_17[a]/<a^2+3>..." << endl; 815 815 816 816 const coeffs cf = nInitChar(type, &extParam); // Z_17[a]/<a^2+3> 817 817 818 818 if( cf == NULL ) 819 819 TS_FAIL("Could not get needed coeff. domain"); 820 820 821 821 TS_ASSERT_DIFFERS( cf>cfCoeffWrite, NULLp ); 822 822 823 823 if( cf>cfCoeffWrite != NULL ) 824 824 { 825 clog << "Coeffdomain: " << endl; 825 clog << "Coeffdomain: " << endl; 826 826 n_CoeffWrite(cf); PrintLn(); 827 827 } 828 828 829 829 TS_ASSERT( nCoeff_is_algExt(cf) ); 830 830 TS_ASSERT( !nCoeff_is_transExt(cf) ); 831 831 832 832 // some tests for the coefficient field represented by cf: 833 833 TestArithCf(cf); … … 840 840 clog << "Finally create the polynomial ring (Z_17[a]/<a^2+3>)[u, v, w]..." 841 841 << endl; 842 842 843 843 char* m[] = {"u", "v", "w"}; 844 844 ring s = rDefault(cf, 3, m); // (Z_17[a]/<a^2+3>)[u, v, w] 
libpolys/tests/rings_test.h
r6ccdd3a r7af488e 31 31 32 32 33 TS_ASSERT_EQUALS( nRegister( n_Zp, npInitChar), n_Zp );34 TS_ASSERT_EQUALS( nRegister( n_GF, nfInitChar), n_GF );35 TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );36 TS_ASSERT_EQUALS( nRegister( n_Q, nlInitChar), n_Q );37 TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R );33 //TS_ASSERT_EQUALS( nRegister( n_Zp, npInitChar), n_Zp ); 34 //TS_ASSERT_EQUALS( nRegister( n_GF, nfInitChar), n_GF ); 35 //TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R ); 36 //TS_ASSERT_EQUALS( nRegister( n_Q, nlInitChar), n_Q ); 37 //TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R ); 38 38 39 39 #ifdef HAVE_RINGS 40 TS_ASSERT_EQUALS( nRegister( n_Z, nrzInitChar), n_Z ); // these are UNusable at the moment!40 //TS_ASSERT_EQUALS( nRegister( n_Z, nrzInitChar), n_Z ); // these are UNusable at the moment! 41 41 #endif 42 42
Note: See TracChangeset
for help on using the changeset viewer.