Changeset 17e473 in git
- Timestamp:
- Apr 20, 2011, 9:43:24 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 03bf555de3ab718b020a7fd0a086b5c2e493dbd0
- Parents:
- 1ddd044275ba5d4433a597ff9edee1abfce81a0e
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-04-20 21:43:24+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:31:23+01:00
- Location:
- libpolys
- Files:
-
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/coeffs.h
r1ddd04 r17e473 207 207 static inline n_coeffType getCoeffType(const coeffs r) 208 208 { 209 assume(r != NULL); 209 210 return r->type; 210 211 } 211 212 212 /// returns true for coeffs being a domain213 static inline bool nField_is_Domain(const coeffs r)214 {215 #ifdef HAVE_RINGS216 return (r->ringtype == 4 || r->ringtype == 0);217 #else218 return true;219 #endif220 }221 222 223 213 static inline int nInternalChar(const coeffs r) 224 214 { 215 assume(r != NULL); 225 216 return r->ch; 226 217 } … … 248 239 /// return a copy of a 249 240 static inline number n_Copy(number n, const coeffs r) 250 { return r->cfCopy(n, r); }241 { assume(r != NULL); return r->cfCopy(n, r); } 251 242 252 243 static inline void n_Delete(number* p, const coeffs r) 253 { r->cfDelete(p, r); }244 { assume(r != NULL); r->cfDelete(p, r); } 254 245 255 246 static inline BOOLEAN n_Equal(number a, number b, const coeffs r) 256 { return r->cfEqual(a, b, r); }247 { assume(r != NULL); return r->cfEqual(a, b, r); } 257 248 258 249 static inline BOOLEAN n_IsZero(number n, const coeffs r) 259 { return r->cfIsZero(n,r); }250 { assume(r != NULL); return r->cfIsZero(n,r); } 260 251 261 252 static inline BOOLEAN n_IsOne(number n, const coeffs r) 262 { return r->cfIsOne(n,r); }253 { assume(r != NULL); return r->cfIsOne(n,r); } 263 254 264 255 static inline BOOLEAN n_IsMOne(number n, const coeffs r) 265 { return r->cfIsMOne(n,r); }256 { assume(r != NULL); return r->cfIsMOne(n,r); } 266 257 267 258 static inline BOOLEAN n_GreaterZero(number n, const coeffs r) 268 { return r->cfGreaterZero(n,r); }259 { assume(r != NULL); return r->cfGreaterZero(n,r); } 269 260 // cfGreater? 270 261 271 262 #ifdef HAVE_RINGS 272 263 static inline BOOLEAN n_IsUnit(number n, const coeffs r) 273 { return r->cfIsUnit(n,r); }264 { assume(r != NULL); return r->cfIsUnit(n,r); } 274 265 275 266 static inline number n_GetUnit(number n, const coeffs r) 276 { return r->cfGetUnit(n,r); }267 { assume(r != NULL); return r->cfGetUnit(n,r); } 277 268 278 269 static inline BOOLEAN n_DivBy(number a, number b, const coeffs r) 279 { return r->cfDivBy(a,b,r); }270 { assume(r != NULL); return r->cfDivBy(a,b,r); } 280 271 #endif 281 272 282 273 /// init with an integer 283 274 static inline number n_Init(int i, const coeffs r) 284 { return r->cfInit(i,r); }275 { assume(r != NULL); return r->cfInit(i,r); } 285 276 286 277 /// changes argument inline: a:= -a 287 278 static inline number n_Neg(number n, const coeffs r) 288 { return r->cfNeg(n,r); }279 { assume(r != NULL); return r->cfNeg(n,r); } 289 280 290 281 /// return 1/a 291 282 static inline number n_Invers(number a, const coeffs r) 292 { return r->cfInvers(a,r); }283 { assume(r != NULL); return r->cfInvers(a,r); } 293 284 294 285 /// use for pivot strategies, (0) => 0, otherwise positive 295 286 static inline int n_Size(number n, const coeffs r) 296 { return r->cfSize(n,r); }287 { assume(r != NULL); return r->cfSize(n,r); } 297 288 298 289 /// normalize the number. i.e. go to some canonnical representation (inplace) 299 290 static inline void n_Normalize(number& n, const coeffs r) 300 { return r->cfNormalize(n,r); }291 { assume(r != NULL); return r->cfNormalize(n,r); } 301 292 302 293 /// Normalize and Write to the output buffer of reporter 303 294 static inline void n_Write(number& n, const coeffs r) 304 { return r->cfWrite(n,r); }295 { assume(r != NULL); return r->cfWrite(n,r); } 305 296 306 297 /// Normalize and get denomerator 307 298 static inline number n_GetDenom(number& n, const coeffs r) 308 { return r->cfGetDenom(n, r); }299 { assume(r != NULL); return r->cfGetDenom(n, r); } 309 300 310 301 /// Normalize and get numerator 311 302 static inline number n_GetNumerator(number& n, const coeffs r) 312 { return r->cfGetNumerator(n, r); }303 { assume(r != NULL); return r->cfGetNumerator(n, r); } 313 304 314 305 static inline void n_Power(number a, int b, number *res, const coeffs r) 315 { r->cfPower(a,b,res,r); }306 { assume(r != NULL); r->cfPower(a,b,res,r); } 316 307 317 308 static inline number n_Mult(number a, number b, const coeffs r) 318 { return r->cfMult(a, b, r); }309 { assume(r != NULL); return r->cfMult(a, b, r); } 319 310 320 311 /// Inplace multiplication: a := a * b 321 312 static inline void n_InpMult(number &a, number b, const coeffs r) 322 { r->cfInpMult(a,b,r); }313 { assume(r != NULL); r->cfInpMult(a,b,r); } 323 314 324 315 static inline number n_Sub(number a, number b, const coeffs r) 325 { return r->cfSub(a, b, r); }316 { assume(r != NULL); return r->cfSub(a, b, r); } 326 317 327 318 static inline number n_Add(number a, number b, const coeffs r) 328 { return r->cfAdd(a, b, r); }319 { assume(r != NULL); return r->cfAdd(a, b, r); } 329 320 330 321 static inline number n_Div(number a, number b, const coeffs r) 331 { return r->cfDiv(a,b,r); }322 { assume(r != NULL); return r->cfDiv(a,b,r); } 332 323 333 324 static inline number n_IntDiv(number a, number b, const coeffs r) 334 { return r->cfIntDiv(a,b,r); }325 { assume(r != NULL); return r->cfIntDiv(a,b,r); } 335 326 336 327 static inline number n_ExactDiv(number a, number b, const coeffs r) 337 { return r->cfExactDiv(a,b,r); }328 { assume(r != NULL); return r->cfExactDiv(a,b,r); } 338 329 339 330 static inline number n_Gcd(number a, number b, const coeffs r) 340 { return r->cfGcd(a,b,r); }331 { assume(r != NULL); return r->cfGcd(a,b,r); } 341 332 342 333 static inline number n_Lcm(number a, number b, const coeffs r) 343 { return r->cfLcm(a,b,r); }334 { assume(r != NULL); return r->cfLcm(a,b,r); } 344 335 345 336 static inline nMapFunc n_SetMap(const coeffs src, const coeffs dst) 346 { return dst->cfSetMap(src,dst); }337 { assume(src != NULL && dst != NULL); return dst->cfSetMap(src,dst); } 347 338 348 339 static inline number n_Par(int n, const coeffs r) 349 { return r->cfPar(n,r); }340 { assume(r != NULL); return r->cfPar(n,r); } 350 341 351 342 static inline int n_ParDeg(number n, const coeffs r) 352 { return r->cfParDeg(n,r); }343 { assume(r != NULL); return r->cfParDeg(n,r); } 353 344 354 345 /// Tests whether n is a correct number: only used if LDEBUG is defined 355 346 static inline BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r) 356 347 { 348 assume(r != NULL); 357 349 #ifdef LDEBUG 358 350 return (r)->cfDBTest(n, filename, linenumber, r); … … 364 356 // Tests: 365 357 static inline BOOLEAN nCoeff_is_Ring_2toM(const coeffs r) 366 { return (r->ringtype == 1); }358 { assume(r != NULL); return (r->ringtype == 1); } 367 359 368 360 static inline BOOLEAN nCoeff_is_Ring_ModN(const coeffs r) 369 { return (r->ringtype == 2); }361 { assume(r != NULL); return (r->ringtype == 2); } 370 362 371 363 static inline BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r) 372 { return (r->ringtype == 3); }364 { assume(r != NULL); return (r->ringtype == 3); } 373 365 374 366 static inline BOOLEAN nCoeff_is_Ring_Z(const coeffs r) 375 { return (r->ringtype == 4); }367 { assume(r != NULL); return (r->ringtype == 4); } 376 368 377 369 static inline BOOLEAN nCoeff_is_Ring(const coeffs r) 378 { return (r->ringtype != 0); }370 { assume(r != NULL); return (r->ringtype != 0); } 379 371 380 372 /// returns TRUE, if r is not a field and r has no zero divisors (i.e is a domain) 381 373 static inline BOOLEAN nCoeff_is_Domain(const coeffs r) 382 { return (r->ringtype == 4 || r->ringtype == 0); } 374 { 375 assume(r != NULL); 376 #ifdef HAVE_RINGS 377 return (r->ringtype == 4 || r->ringtype == 0); 378 #else 379 return TRUE; 380 #endif 381 } 383 382 384 383 /// returns TRUE, if r is not a field and r has non-trivial units 385 384 static inline BOOLEAN nCoeff_has_Units(const coeffs r) 386 { return ((r->ringtype == 1) || (r->ringtype == 2) || (r->ringtype == 3)); }385 { assume(r != NULL); return ((r->ringtype == 1) || (r->ringtype == 2) || (r->ringtype == 3)); } 387 386 388 387 static inline BOOLEAN nCoeff_is_Zp(const coeffs r) 389 { return getCoeffType(r)==n_Zp; }388 { assume(r != NULL); return getCoeffType(r)==n_Zp; } 390 389 391 390 static inline BOOLEAN nCoeff_is_Zp(const coeffs r, int p) 392 { return (getCoeffType(r) && (r->ch == ABS(p))); }391 { assume(r != NULL); return (getCoeffType(r) && (r->ch == ABS(p))); } 393 392 394 393 static inline BOOLEAN nCoeff_is_Q(const coeffs r) 395 { return getCoeffType(r)==n_Q; }394 { assume(r != NULL); return getCoeffType(r)==n_Q; } 396 395 397 396 static inline BOOLEAN nCoeff_is_numeric(const coeffs r) /* R, long R, long C */ 398 { return (getCoeffType(r)==n_R) || (getCoeffType(r)==n_long_R) || (getCoeffType(r)==n_long_C); } 397 { assume(r != NULL); return (getCoeffType(r)==n_R) || (getCoeffType(r)==n_long_R) || (getCoeffType(r)==n_long_C); } 398 // (r->ringtype == 0) && (r->ch == -1); ?? 399 399 400 400 401 static inline BOOLEAN nCoeff_is_R(const coeffs r) 401 { return getCoeffType(r)==n_R; }402 { assume(r != NULL); return getCoeffType(r)==n_R; } 402 403 403 404 static inline BOOLEAN nCoeff_is_GF(const coeffs r) 404 { return getCoeffType(r)==n_GF; }405 { assume(r != NULL); return getCoeffType(r)==n_GF; } 405 406 406 407 static inline BOOLEAN nCoeff_is_GF(const coeffs r, int q) 407 { return (getCoeffType(r)==n_GF) && (r->ch == q); }408 { assume(r != NULL); return (getCoeffType(r)==n_GF) && (r->ch == q); } 408 409 409 410 static inline BOOLEAN nCoeff_is_Zp_a(const coeffs r) 410 { return (r->ringtype == 0) && (r->ch < -1); }411 { assume(r != NULL); return (r->ringtype == 0) && (r->ch < -1); } 411 412 412 413 static inline BOOLEAN nCoeff_is_Zp_a(const coeffs r, int p) 413 { return (r->ringtype == 0) && (r->ch < -1 ) && (-(r->ch) == ABS(p)); }414 { assume(r != NULL); return (r->ringtype == 0) && (r->ch < -1 ) && (-(r->ch) == ABS(p)); } 414 415 415 416 static inline BOOLEAN nCoeff_is_Q_a(const coeffs r) 416 { return (r->ringtype == 0) && (r->ch == 1); }417 { assume(r != NULL); return (r->ringtype == 0) && (r->ch == 1); } 417 418 418 419 static inline BOOLEAN nCoeff_is_long_R(const coeffs r) 419 { return getCoeffType(r)==n_long_R; }420 { assume(r != NULL); return getCoeffType(r)==n_long_R; } 420 421 421 422 static inline BOOLEAN nCoeff_is_long_C(const coeffs r) 422 { return getCoeffType(r)==n_long_C; }423 { assume(r != NULL); return getCoeffType(r)==n_long_C; } 423 424 424 425 static inline BOOLEAN nCoeff_is_CF(const coeffs r) 425 { return getCoeffType(r)==n_CF; }426 { assume(r != NULL); return getCoeffType(r)==n_CF; } 426 427 427 428 /// TRUE, if the computation of the inverse is fast (i.e. prefer leading coeff. 1 over content) 428 429 static inline BOOLEAN nCoeff_has_simple_inverse(const coeffs r) 429 { return r->has_simple_Inverse; }430 { assume(r != NULL); return r->has_simple_Inverse; } 430 431 /* Z/2^n, Z/p, GF(p,n), R, long_R, long_C*/ 432 // /* { return (r->ch>1) || (r->ch== -1); } *//* Z/p, GF(p,n), R, long_R, long_C*/ 433 // #ifdef HAVE_RINGS 434 // { return (r->ringtype > 0) || (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/2^n, Z/p, GF(p,n), R, long_R, long_C*/ 435 // #else 436 // { return (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/p, GF(p,n), R, long_R, long_C*/ 437 // #endif 438 439 431 440 432 441 /// TRUE if n_Delete/n_New are empty operations 433 442 static inline BOOLEAN nCoeff_has_simple_Alloc(const coeffs r) 434 { return r->has_simple_Alloc; }443 { assume(r != NULL); return r->has_simple_Alloc; } 435 444 /* Z/p, GF(p,n), R, Ring_2toM: nCopy, nNew, nDelete are dummies*/ 445 // return (rField_is_Zp(r) 446 // || rField_is_GF(r) 447 // #ifdef HAVE_RINGS 448 // || rField_is_Ring_2toM(r) 449 // #endif 450 // || rField_is_R(r)); } 451 436 452 437 453 static inline BOOLEAN nCoeff_is_Extension(const coeffs r) 438 { return (nCoeff_is_Q_a(r)) || (nCoeff_is_Zp_a(r)); } /* Z/p(a) and Q(a)*/454 { assume(r != NULL); return (nCoeff_is_Q_a(r)) || (nCoeff_is_Zp_a(r)); } /* Z/p(a) and Q(a)*/ 439 455 440 456 /// BOOLEAN n_Test(number a, const coeffs r) … … 448 464 // Deprecated: 449 465 static inline int n_GetChar(const coeffs r) 450 { return nInternalChar(r); }451 452 453 454 #endif 455 466 { assume(r != NULL); return nInternalChar(r); } 467 468 469 470 #endif 471 -
libpolys/polys/monomials/ring.cc
r1ddd04 r17e473 138 138 ring rDefault(coeffs cf, int N, char **n,int ord_size, int *ord, int *block0, int *block1) 139 139 { 140 assume( cf != NULL); 140 141 ring r=(ring) omAlloc0Bin(sip_sring_bin); 141 142 r->ch = n_GetChar(cf); … … 167 168 if (ch==0) cf=nInitChar(n_Q,NULL); 168 169 else cf=nInitChar(n_Zp,(void*)(long)ch); 170 assume( cf != NULL); 169 171 return rDefault(cf,N,n,ord_size,ord,block0,block1); 170 172 } 171 173 ring rDefault(coeffs cf, int N, char **n) 172 174 { 175 assume( cf != NULL); 173 176 /*order: lp,0*/ 174 177 int *order = (int *) omAlloc(2* sizeof(int)); … … 190 193 if (ch==0) cf=nInitChar(n_Q,NULL); 191 194 else cf=nInitChar(n_Zp,(void*)(long)ch); 195 assume( cf != NULL); 192 196 return rDefault(cf,N,n); 193 197 } … … 286 290 else if (rField_is_Ring(r)) 287 291 { 292 TODO(Frank, "Please consider addapting the variable names..."); 293 288 294 PrintS("// coeff. ring is : "); 289 295 if (rField_is_Ring_Z(r)) PrintS("Integers\n"); 296 /* 290 297 long l = (long)mpz_sizeinbase(r->ringflaga, 10) + 2; 291 298 char* s = (char*) omAlloc(l); … … 295 302 if (rField_is_Ring_PtoM(r)) Print("Z/%s^%lu\n", s, r->ringflagb); 296 303 omFreeSize((ADDRESS)s, l); 304 */ 297 305 } 298 306 #endif … … 521 529 } 522 530 #ifdef HAVE_RINGS 531 TODO(Frank, "Please consider addapting the variable names..."); 532 /* 523 533 if (r->ringflaga != NULL) 524 534 { … … 531 541 omFree((ADDRESS)r->nrnModul); 532 542 } 543 */ 533 544 #endif 534 545 omFreeBin(r, sip_sring_bin); … … 649 660 650 661 #ifdef HAVE_RINGS 662 TODO(Frank, "Please consider addapting the variable names..."); 663 /* 651 664 if (rField_is_Ring_Z(r)) 652 665 { 653 s=omStrDup("integer"); / * Z */666 s=omStrDup("integer"); // Z 654 667 return s; 655 668 } … … 674 687 return s; 675 688 } 689 */ 676 690 #endif 677 691 if (r->parameter==NULL) … … 777 791 { 778 792 #ifdef HAVE_RINGS 793 TODO(Frank, "Please consider addapting the variable names..."); 794 /* 779 795 if (rField_is_Ring_2toM(r)) 780 796 return binaryPower(2, (int)(unsigned long)r->ringflagb); … … 784 800 return binaryPower((int)mpz_get_ui(r->ringflaga), 785 801 (int)(unsigned long)r->ringflagb); 802 */ 786 803 #endif 787 804 if (rField_is_numeric(r)) … … 1597 1614 ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering) 1598 1615 { 1616 TODO(Hans, "Please consider the change to '->cf'..."); 1617 1599 1618 if (r == NULL) return NULL; 1600 1619 int i,j; … … 1615 1634 res->ch=r->ch; /* characteristic */ 1616 1635 #ifdef HAVE_RINGS 1617 res->ringtype=r->ringtype; /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */ 1636 TODO(Frank, "Please consider addapting the variable names..."); 1637 /* 1638 res->ringtype=r->ringtype; // cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m 1618 1639 if (r->ringflaga!=NULL) 1619 1640 { … … 1627 1648 mpz_init_set(res->nrnModul,r->nrnModul); 1628 1649 } 1650 */ 1629 1651 #endif 1630 1652 //memset: res->ref=0; /* reference counter to the ring */ … … 1682 1704 //memset: res->cf=NULL; 1683 1705 res->options=r->options; 1684 #ifdef HAVE_RINGS 1685 res->ringtype=r->ringtype; 1686 #endif 1706 #ifdef HAVE_RINGS 1707 TODO(Frank, "Please consider addapting the variable names..."); 1708 // res->ringtype=r->ringtype; 1709 #endif 1687 1710 // 1688 1711 if (r->algring!=NULL) … … 3473 3496 // set intStrategy 3474 3497 #ifdef HAVE_RINGS 3475 if (rField_is_Extension(r) || rField_is_Q(r) || rField_is_Ring(r)) 3498 if ( 3499 rField_is_Extension(r) 3500 || rField_is_Q(r) 3501 || rField_is_Ring(r)) 3476 3502 #else 3477 3503 if (rField_is_Extension(r) || rField_is_Q(r)) -
libpolys/polys/monomials/ring.h
r1ddd04 r17e473 222 222 intvec * pModW; /* std: module weights */ 223 223 poly ppNoether; /* variables, set by procedures from hecke/kstd1: 224 224 225 the highest monomial below pHEdge */ 225 #ifdef HAVE_RINGS 226 unsigned int ringtype; /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */ 227 int_number ringflaga; /* Z/(ringflag^ringflagb)=Z/nrnModul*/ 228 unsigned long ringflagb; 229 unsigned long nr2mModul; /* Z/nr2mModul */ 230 int_number nrnModul; 231 #endif 226 // #ifdef HAVE_RINGS 227 // unsigned int ringtype; /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */ 228 // int_number ringflaga; /* Z/(ringflag^ringflagb)=Z/nrnModul*/ 229 // unsigned long ringflagb; 230 // unsigned long nr2mModul; /* Z/nr2mModul */ 231 // int_number nrnModul; 232 // #endif 233 232 234 unsigned long options; /* ring dependent options */ 233 235 … … 347 349 static inline bool rIsPluralRing(const ring r) 348 350 { 351 assume(r != NULL); 349 352 #ifdef HAVE_PLURAL 350 353 nc_struct *n; … … 357 360 static inline bool rIsRatGRing(const ring r) 358 361 { 362 assume(r != NULL); 359 363 #ifdef HAVE_PLURAL 360 364 /* nc_struct *n; */ … … 413 417 414 418 #ifdef HAVE_RINGS 415 static inline BOOLEAN rField_is_Ring_2toM( ring r)416 { return (getCoeffType(r->cf) == n_Z2m); }417 418 static inline BOOLEAN rField_is_Ring_ModN( ring r)419 { return (getCoeffType(r->cf) == n_Zn); }420 421 static inline BOOLEAN rField_is_Ring_PtoM( ring r)422 { return (getCoeffType(r->cf) == n_Zpn); }423 424 static inline BOOLEAN rField_is_Ring_Z( ring r)425 { return (getCoeffType(r->cf) == n_Z); }426 427 static inline BOOLEAN rField_is_Ring( ring r)428 { return (r->ringtype != 0); }429 430 static inline BOOLEAN rField_is_Domain( ring r)431 { return (r->ringtype == 4 || r->ringtype == 0); }432 433 static inline BOOLEAN rField_has_Units( ring r)434 { return ((r->ringtype == 1) || (r->ringtype == 2) || (r->ringtype == 3)); }419 static inline BOOLEAN rField_is_Ring_2toM(const ring r) 420 { assume(r != NULL); return ( getCoeffType(r->cf) == n_Z2m && nCoeff_is_Ring_2toM(r->cf) ); } 421 422 static inline BOOLEAN rField_is_Ring_ModN(const ring r) 423 { assume(r != NULL); return ( getCoeffType(r->cf) == n_Zn && nCoeff_is_Ring_ModN(r->cf) ); } 424 425 static inline BOOLEAN rField_is_Ring_PtoM(const ring r) 426 { assume(r != NULL); return (getCoeffType(r->cf) == n_Zpn && nCoeff_is_Ring_PtoM(r->cf) ); } 427 428 static inline BOOLEAN rField_is_Ring_Z(const ring r) 429 { assume(r != NULL); return (getCoeffType(r->cf) == n_Z && nCoeff_is_Ring_Z(r->cf) ); } 430 431 static inline BOOLEAN rField_is_Ring(const ring r) 432 { assume(r != NULL); return nCoeff_is_Ring(r->cf); } 433 434 static inline BOOLEAN rField_is_Domain(const ring r) 435 { assume(r != NULL); return nCoeff_is_Domain(r->cf); } 436 437 static inline BOOLEAN rField_has_Units(const ring r) 438 { assume(r != NULL); return nCoeff_has_Units(r->cf); } 435 439 #else 436 440 #define rField_is_Ring(A) (0) … … 443 447 #endif 444 448 445 static inline BOOLEAN rField_is_Zp(ring r) 446 { return (getCoeffType(r->cf) == n_Zp); } 447 448 static inline BOOLEAN rField_is_Zp(ring r, int p) 449 { return (getCoeffType(r->cf) == n_Zp) && (r->ch == p); } 450 451 static inline BOOLEAN rField_is_Q(ring r) 452 { return (getCoeffType(r->cf) == n_Q); } 453 454 static inline BOOLEAN rField_is_numeric(ring r) /* R, long R, long C */ 455 { return (r->ringtype == 0) && (r->ch == -1); } 456 457 static inline BOOLEAN rField_is_R(ring r) 458 { return (getCoeffType(r->cf) == n_R); } 459 460 static inline BOOLEAN rField_is_GF(ring r) 461 { return (getCoeffType(r->cf) == n_GF); } 462 463 static inline BOOLEAN rField_is_GF(ring r, int q) 464 { return (getCoeffType(r->cf) == n_GF) && (r->ch == q); } 465 466 static inline BOOLEAN rField_is_Zp_a(ring r) 467 { return (r->ringtype == 0) && (r->ch < -1); } 468 469 static inline BOOLEAN rField_is_Zp_a(ring r, int p) 470 { return (r->ringtype == 0) && (r->ch < -1 ) && (-(r->ch) == ABS(p)); } 471 472 static inline BOOLEAN rField_is_Q_a(ring r) 473 { return (r->ringtype == 0) && (r->ch == 1); } 474 475 static inline BOOLEAN rField_is_long_R(ring r) 476 { return (getCoeffType(r->cf) == n_long_R); } 477 478 static inline BOOLEAN rField_is_long_C(ring r) 479 { return (getCoeffType(r->cf) == n_long_C); } 480 481 static inline BOOLEAN rField_has_simple_inverse(ring r) 482 /* { return (r->ch>1) || (r->ch== -1); } *//* Z/p, GF(p,n), R, long_R, long_C*/ 483 #ifdef HAVE_RINGS 484 { return (r->ringtype > 0) || (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/2^n, Z/p, GF(p,n), R, long_R, long_C*/ 485 #else 486 { return (r->ch>1) || ((r->ch== -1) && (r->float_len < 10)); } /* Z/p, GF(p,n), R, long_R, long_C*/ 487 #endif 488 489 static inline BOOLEAN rField_has_simple_Alloc(ring r) 490 { return (rField_is_Zp(r) 491 || rField_is_GF(r) 492 #ifdef HAVE_RINGS 493 || rField_is_Ring_2toM(r) 494 #endif 495 || rField_is_R(r)); } 449 static inline BOOLEAN rField_is_Zp(const ring r) 450 { assume(r != NULL); return (getCoeffType(r->cf) == n_Zp); } 451 452 static inline BOOLEAN rField_is_Zp(const ring r, int p) 453 { assume(r != NULL); return (getCoeffType(r->cf) == n_Zp) && (r->ch == p); } 454 455 static inline BOOLEAN rField_is_Q(const ring r) 456 { assume(r != NULL); return nCoeff_is_Q(r->cf); } 457 458 static inline BOOLEAN rField_is_numeric(const ring r) /* R, long R, long C */ 459 { assume(r != NULL); return nCoeff_is_numeric(r->cf); } 460 461 static inline BOOLEAN rField_is_R(const ring r) 462 { assume(r != NULL); return nCoeff_is_R(r->cf); } 463 464 static inline BOOLEAN rField_is_GF(const ring r) 465 { assume(r != NULL); return nCoeff_is_GF(r->cf); } 466 467 static inline BOOLEAN rField_is_GF(const ring r, int q) 468 { assume(r != NULL); return nCoeff_is_GF(r->cf, q); } 469 470 static inline BOOLEAN rField_is_Zp_a(const ring r) 471 { assume(r != NULL); return nCoeff_is_Zp_a(r->cf); } 472 473 static inline BOOLEAN rField_is_Zp_a(const ring r, int p) 474 { assume(r != NULL); return nCoeff_is_Zp_a(r->cf, p); } 475 476 static inline BOOLEAN rField_is_Q_a(const ring r) 477 { assume(r != NULL); return nCoeff_is_Q_a(r->cf); } 478 479 static inline BOOLEAN rField_is_long_R(const ring r) 480 { assume(r != NULL); return nCoeff_is_long_R(r->cf); } 481 482 static inline BOOLEAN rField_is_long_C(const ring r) 483 { assume(r != NULL); return nCoeff_is_long_C(r->cf); } 484 485 static inline BOOLEAN rField_has_simple_inverse(const ring r) 486 { assume(r != NULL); return nCoeff_has_simple_inverse(r->cf); } 487 488 static inline BOOLEAN rField_has_simple_Alloc(const ring r) 489 { assume(r != NULL); return nCoeff_has_simple_Alloc(r->cf); } 496 490 497 491 /* Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies*/ 498 static inline BOOLEAN rField_is_Extension( ring r)499 { return (rField_is_Q_a(r)) || (rField_is_Zp_a(r)); } /* Z/p(a) and Q(a)*/500 501 n_coeffType rFieldType( ring r);492 static inline BOOLEAN rField_is_Extension(const ring r) 493 { assume(r != NULL); return nCoeff_is_Extension(r->cf); } /* Z/p(a) and Q(a)*/ 494 495 n_coeffType rFieldType(const ring r); 502 496 503 497 /// this needs to be called whenever a new ring is created: new fields … … 510 504 static inline int rBlocks(ring r) 511 505 { 506 assume(r != NULL); 512 507 int i=0; 513 508 while (r->order[i]!=0) i++; … … 518 513 static inline char* rRingVar(short i, const ring r) 519 514 { 520 return r->names[i];515 assume(r != NULL); return r->names[i]; 521 516 } 522 517 static inline BOOLEAN rShortOut(const ring r) 523 518 { 524 return (r->ShortOut);519 assume(r != NULL); return (r->ShortOut); 525 520 } 526 521 … … 571 566 572 567 static inline BOOLEAN rIsSyzIndexRing(const ring r) 573 { return r->order[0] == ringorder_s;}568 { assume(r != NULL); return r->order[0] == ringorder_s;} 574 569 575 570 static inline int rGetCurrSyzLimit(const ring r) 576 { return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);}571 { assume(r != NULL); return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);} 577 572 578 573 // Ring Manipulations … … 619 614 static inline BOOLEAN rOrd_is_Comp_dp(ring r) 620 615 { 616 assume(r != NULL); 621 617 return ((r->order[0] == ringorder_c || r->order[0] == ringorder_C) && 622 618 r->order[1] == ringorder_dp && -
libpolys/polys/operations/p_Mult_q.cc
r1ddd04 r17e473 191 191 static poly _p_Mult_q_Normal(poly p, poly q, const int copy, const ring r) 192 192 { 193 assume(r != NULL); 193 194 assume(p != NULL && pNext(p) != NULL && q != NULL && pNext(q) != NULL); 194 195 #ifdef HAVE_RINGS 195 assume(n Field_is_Domain(r->cf));196 #endif 197 pAssume1(! p HaveCommonMonoms(p, q));196 assume(nCoeff_is_Domain(r->cf)); 197 #endif 198 pAssume1(! p_HaveCommonMonoms(p, q, r)); 198 199 p_Test(p, r); 199 200 p_Test(q, r); … … 269 270 poly _p_Mult_q(poly p, poly q, const int copy, const ring r) 270 271 { 271 #ifdef HAVE_RINGS 272 if (!nField_is_Domain(r->cf)) 272 assume(r != NULL); 273 #ifdef HAVE_RINGS 274 if (!nCoeff_is_Domain(r->cf)) 273 275 return _p_Mult_q_Normal_ZeroDiv(p, q, copy, r); 274 276 #endif -
libpolys/tests/polys_test.h
r1ddd04 r17e473 1 #include <cxxtest/TestSuite.h> 2 #include <cxxtest/GlobalFixture.h> 1 3 2 4 #include "config.h" … … 10 12 11 13 14 // the following headers are private... 15 #include <coeffs/longrat.h> 16 #include <coeffs/gnumpfl.h> 17 #include <coeffs/gnumpc.h> 18 #include <coeffs/shortfl.h> 19 #include <coeffs/ffields.h> 20 #include <coeffs/modulop.h> 21 #include <coeffs/rmodulon.h> 22 #include <coeffs/rmodulo2m.h> 23 #include <coeffs/rintegers.h> 24 25 12 26 #include <polys/monomials/ring.h> 13 27 … … 16 30 17 31 32 33 class GlobalPrintingFixture : public CxxTest::GlobalFixture 34 { 35 public: 36 bool setUpWorld() { 37 clog << ( "<world>" ) << endl; 38 TS_ASSERT_EQUALS( nRegister( n_Zp, npInitChar), n_Zp ); 39 TS_ASSERT_EQUALS( nRegister( n_GF, nfInitChar), n_GF ); 40 TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R ); 41 TS_ASSERT_EQUALS( nRegister( n_Q, nlInitChar), n_Q ); 42 TS_ASSERT_EQUALS( nRegister( n_R, nrInitChar), n_R ); 43 44 #ifdef HAVE_RINGS 45 TS_ASSERT_EQUALS( nRegister( n_Z, nrzInitChar), n_Z ); // these are UNusable at the moment! 46 #endif 47 48 return true; 49 } 50 bool tearDownWorld() { clog <<( "</world>" ) << endl; return true; } 51 bool setUp() { clog <<( "<test>" ) << endl; return true; } 52 bool tearDown() { clog <<( "</test>" ) << endl; return true; } 53 }; 54 55 56 // 57 // We can rely on this file being included exactly once 58 // and declare this global variable in the header file. 59 // 60 static GlobalPrintingFixture globalPrintingFixture; 61 62 63 namespace 64 { 65 void PrintRing(const ring r) 66 { 67 rWrite(r); PrintLn(); 68 #ifdef RDEBUG 69 rDebugPrint(r); PrintLn(); 70 #endif 71 } 72 } 18 73 19 74 class PolysTestSuite : public CxxTest::TestSuite 20 75 { 21 76 public: 22 void test_1() 77 void test_Z13_t() 78 { 79 clog << "Creating Z/13[t]: " << endl; 80 81 char* n[] = {"t"}; 82 ring r = rDefault( 13, 1, n); 83 TS_ASSERT_DIFFERS( r, NULLp ); 84 85 PrintRing(r); 86 87 TS_ASSERT( rField_is_Domain(r) ); 88 TS_ASSERT( !rField_is_Q(r) ); 89 90 TS_ASSERT( rField_is_Zp(r) ); 91 TS_ASSERT( !rField_is_Zp(r, 11) ); 92 TS_ASSERT( rField_is_Zp(r, 13) ); 93 94 TS_ASSERT_EQUALS( rVar(r), 1); 95 96 rDelete(r); 97 } 98 99 void test_QQ_t() 100 { 101 clog << "Creating Q[s]: " << endl; 102 103 char* n[] = {"s"}; 104 ring r = rDefault( 0, 1, n); 105 TS_ASSERT_DIFFERS( r, NULLp ); 106 107 PrintRing(r); 108 109 TS_ASSERT( rField_is_Domain(r) ); 110 TS_ASSERT( rField_is_Q(r) ); 111 112 TS_ASSERT( !rField_is_Zp(r) ); 113 TS_ASSERT( !rField_is_Zp(r, 11) ); 114 115 TS_ASSERT_EQUALS( rVar(r), 1); 116 117 rDelete(r); 118 } 119 120 void test_Z11_x_y_z() 121 { 122 clog << "Creating Z/11[x, y, z]: " << endl; 123 124 char* n[] = {"x", "y", "z"}; 125 ring r = rDefault( 11, 3, n); 126 TS_ASSERT_DIFFERS( r, NULLp ); 127 128 PrintRing(r); 129 130 TS_ASSERT( rField_is_Domain(r) ); 131 TS_ASSERT( !rField_is_Q(r) ); 132 133 TS_ASSERT( rField_is_Zp(r) ); 134 TS_ASSERT( rField_is_Zp(r, 11) ); 135 TS_ASSERT( !rField_is_Zp(r, 13) ); 136 137 TS_ASSERT_EQUALS( rVar(r), 3); 138 139 rDelete(r); 140 } 141 void test_QQ_x_y_z() 23 142 { 24 char* n = "x"; 25 ring r = rDefault( 11, 1, &n); 143 clog << "Creating QQ[x, y, z, u]: " << endl; 144 145 char* n[] = {"x", "y", "z", "u"}; 146 ring r = rDefault( 0, 4, n); 26 147 TS_ASSERT_DIFFERS( r, NULLp ); 27 148 28 clog << "RING: Z/11 [x]: " << endl; 29 rWrite(r); 30 #ifdef RDEBUG 31 rDebugPrint(r); 32 #endif 33 149 PrintRing(r); 150 151 TS_ASSERT( rField_is_Domain(r) ); 152 TS_ASSERT( rField_is_Q(r) ); 153 154 TS_ASSERT( !rField_is_Zp(r) ); 155 TS_ASSERT( !rField_is_Zp(r, 11) ); 156 157 TS_ASSERT_EQUALS( rVar(r), 4); 158 34 159 rDelete(r); 35 160 } 161 162 163 void test_Z13_t_GF() 164 { 165 clog << "Creating GF[t]: " << endl; 166 167 char* n[] = {"t"}; 168 169 GFInfo param; 170 171 param.GFChar= 5; 172 param.GFDegree= 2; 173 param.GFPar_name= (const char*)"Q"; 174 175 const coeffs cf = nInitChar( n_GF, ¶m ); 176 177 TS_ASSERT_DIFFERS( cf, NULLp ); 178 179 ring r = rDefault( cf, 1, n); // now cf belongs to r! 180 TS_ASSERT_DIFFERS( r, NULLp ); 181 182 PrintRing(r); 183 184 TS_ASSERT( rField_is_Domain(r) ); 185 TS_ASSERT( !rField_is_Q(r) ); 186 187 TS_ASSERT( !rField_is_Zp(r) ); 188 TS_ASSERT( !rField_is_Zp(r, 11) ); 189 TS_ASSERT( !rField_is_Zp(r, 13) ); 190 TS_ASSERT( rField_is_GF(r) ); 191 192 TS_ASSERT( !rField_is_GF(r, 5) ); 193 TS_ASSERT( rField_is_GF(r, 25) ); 194 195 TS_ASSERT_EQUALS( rVar(r), 1); 196 197 rDelete(r); // kills 'cf' as well! 198 } 199 36 200 }; 37 201
Note: See TracChangeset
for help on using the changeset viewer.