Changeset 488808e in git
- Timestamp:
- May 26, 2011, 12:12:01 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 5a4b26f3e00776270c3ba83b16c92a69f3cca0e0
- Parents:
- 73a9ffb72679635d0a4389f31022ac7b37564499
- git-author:
- Frank Seelisch <seelisch@mathematik.uni-kl.de>2011-05-26 12:12:01+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:36:53+01:00
- Location:
- libpolys
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/coeffs.h
r73a9ffb r488808e 45 45 typedef struct snumber * number; 46 46 47 struct snumber;48 typedef struct snumber * number;49 50 47 /* standard types */ 51 48 #ifdef HAVE_RINGS … … 58 55 59 56 struct n_Procs_s; 60 typedef struct n_Procs_s n_Procs_s;61 57 typedef struct n_Procs_s *coeffs; 62 58 … … 182 178 //------------------------------------------- 183 179 184 /// For Zp_a, Q_a we need polynomials (due to polys) 185 ring algring; //< implementation of extensions needs polynomials... 186 // // for Q_a/Zp_a, rInit 180 /* for extension fields we need to be able to represent polynomials, 181 so here is the polynomial ring: */ 182 ring algring; 183 187 184 //number minpoly; //< no longer needed: replaced by 188 185 // //< algring->minideal->[0] … … 222 219 intermediate extension fields, i.e., in this case 223 220 it is redundant along the chain of field extensions; 224 CONTRARY to SINGULAR as it was, we do NOT LONGER use 225 negative values for ch. */ 221 CONTRARY to SINGULAR as it was, we do NO LONGER use 222 negative values for ch; 223 for rings, ch will also be set and is - per def - 224 the smallest number of 1's that sum up to zero; 225 however, in this case ch may not fit in an int, 226 thus ch may contain a faulty value */ 226 227 227 228 short float_len; /* additional char-flags, rInit */ … … 233 234 // for n_GF 234 235 235 int m_nfCharQ; ///< the number of elem ts: q236 int m_nfCharQ; ///< the number of elements: q 236 237 int m_nfM1; ///< representation of -1 237 238 int m_nfCharP; ///< the characteristic: p … … 438 439 439 440 static inline BOOLEAN nCoeff_is_Zp(const coeffs r, int p) 440 { assume(r != NULL); return (getCoeffType(r) && (r->ch == ABS(p))); }441 { assume(r != NULL); return (getCoeffType(r) && (r->ch == p)); } 441 442 442 443 static inline BOOLEAN nCoeff_is_Q(const coeffs r) … … 447 448 // (r->ringtype == 0) && (r->ch == -1); ?? 448 449 449 450 450 static inline BOOLEAN nCoeff_is_R(const coeffs r) 451 451 { assume(r != NULL); return getCoeffType(r)==n_R; } … … 457 457 { assume(r != NULL); return (getCoeffType(r)==n_GF) && (r->ch == q); } 458 458 459 /* TRUE iff an extension tower is build upon some Zp, i.e., the bottom 460 field in this tower is Zp */ 459 /* TRUE iff r represents an algebraic or transcendental extension field */ 460 static inline BOOLEAN nCoeff_is_Extension(const coeffs r) 461 { 462 assume(r != NULL); 463 return (getCoeffType(r)==n_algExt) || (getCoeffType(r)==n_transExt); 464 } 465 466 /* DO NOT USE (only kept for compatibility reasons towards the SINGULAR 467 svn trunk); 468 intension: should be TRUE iff the given r is an extension field above 469 some Z/pZ; 470 actually: TRUE iff the given r is an extension tower of arbitrary 471 height above some field of characteristic p (may be Z/pZ or some 472 Galois field of characteristic p) */ 461 473 static inline BOOLEAN nCoeff_is_Zp_a(const coeffs r) 462 474 { 463 475 assume(r != NULL); 464 return (r->ringtype == 0) && 465 ((getCoeffType(r)==n_algExt) || (getCoeffType(r)==n_transExt)) && 466 (r->ch != 0); 467 } 468 469 /* TRUE iff an extension tower is build upon Zp (p as provided), i.e., 470 the bottom field in this tower is Zp */ 476 return ((r->ringtype == 0) && (r->ch != 0) && nCoeff_is_Extension(r)); 477 } 478 479 /* DO NOT USE (only kept for compatibility reasons towards the SINGULAR 480 svn trunk); 481 intension: should be TRUE iff the given r is an extension field above 482 Z/pZ (with p as provided); 483 actually: TRUE iff the given r is an extension tower of arbitrary 484 height above some field of characteristic p (may be Z/pZ or some 485 Galois field of characteristic p) */ 471 486 static inline BOOLEAN nCoeff_is_Zp_a(const coeffs r, int p) 472 487 { 473 488 assume(r != NULL); 474 return (r->ringtype == 0) && 475 ((getCoeffType(r)==n_algExt) || (getCoeffType(r)==n_transExt)) && 476 (r->ch != 0) && (r->ch == p); 477 } 478 479 /* TRUE iff an extension tower is build upon Q, i.e., 480 the bottom field in this tower is Q */ 489 return ((r->ringtype == 0) && (r->ch == p) && nCoeff_is_Extension(r)); 490 } 491 492 /* DO NOT USE (only kept for compatibility reasons towards the SINGULAR 493 svn trunk); 494 intension: should be TRUE iff the given r is an extension field 495 above Q; 496 actually: TRUE iff the given r is an extension tower of arbitrary 497 height above some field of characteristic 0 (may be Q, R, or C) */ 481 498 static inline BOOLEAN nCoeff_is_Q_a(const coeffs r) 482 499 { 483 500 assume(r != NULL); 484 return (r->ringtype == 0) && 485 ((getCoeffType(r)==n_algExt) || (getCoeffType(r)==n_transExt)) && 486 (r->ch == 0); 501 return ((r->ringtype == 0) && (r->ch == 0) && nCoeff_is_Extension(r)); 487 502 } 488 503 … … 507 522 // #endif 508 523 509 510 511 524 /// TRUE if n_Delete/n_New are empty operations 512 525 static inline BOOLEAN nCoeff_has_simple_Alloc(const coeffs r) … … 520 533 // || rField_is_R(r)); } 521 534 522 /* TRUE iff r represents an algebraic or transcendental extension field */523 static inline BOOLEAN nCoeff_is_Extension(const coeffs r)524 {525 assume(r != NULL);526 return (getCoeffType(r)==n_algExt) || (getCoeffType(r)==n_transExt);527 }528 529 535 /* TRUE iff r represents an algebraic extension field */ 530 536 static inline BOOLEAN nCoeff_is_algExt(const coeffs r) -
libpolys/coeffs/numbers.cc
r73a9ffb r488808e 74 74 { 75 75 int c = n_GetChar(r); 76 printf("### c = %d\n", c);77 76 BOOLEAN ret = n_IsZero(a, r); 78 77 if( (c != 0) && !ret ) -
libpolys/polys/ext_fields/algext.cc
r73a9ffb r488808e 87 87 void definiteReduce(poly &p, poly reducer, const coeffs cf); 88 88 89 /* returns the bottom field in this field extension tower; if the tower 90 is flat, i.e., if there is no extension, then r itself is returned; 91 as a side-effect, the counter 'height' is filled with the height of 92 the extension tower (in case the tower is flat, 'height' is zero) */ 93 static coeffs nCoeff_bottom(const coeffs r, int &height) 94 { 95 assume(r != NULL); 96 coeffs cf = r; 97 height = 0; 98 while (nCoeff_is_Extension(cf)) 99 { 100 assume(cf->algring != NULL); assume(cf->algring->cf != NULL); 101 cf = cf->algring->cf; 102 height++; 103 } 104 return cf; 105 } 106 89 107 BOOLEAN naIsZero(number a, const coeffs cf) 90 108 { … … 526 544 nMapFunc naSetMap(const coeffs src, const coeffs dst) 527 545 { 528 /* dst is expected to be an algebraic extension field*/546 /* dst is expected to be an algebraic field extension */ 529 547 assume(getCoeffType(dst) == n_algExt); 530 548 531 /* ATTENTION: This code assumes that dst is an algebraic extension of Q 532 or Zp. So, dst must NOT BE an algebraic extension of some 533 extension etc. This code will NOT WORK for extension 534 towers of height >= 2. */ 535 536 if (nCoeff_is_Q(src) && nCoeff_is_Q_a(dst)) 549 int h = 0; /* the height of the extension tower given by dst */ 550 coeffs bDst = nCoeff_bottom(dst, h); /* the bottom field in the tower dst */ 551 552 /* for the time being, we only provide maps if h = 1 and if b is Q or 553 some field Z/pZ: */ 554 if (h != 1) return NULL; 555 if ((!nCoeff_is_Zp(bDst)) && (!nCoeff_is_Q(bDst))) return NULL; 556 557 if (nCoeff_is_Q(src) && nCoeff_is_Q(bDst)) 537 558 return naMap00; /// Q --> Q(a) 538 559 539 if (nCoeff_is_Zp(src) && nCoeff_is_Q _a(dst))560 if (nCoeff_is_Zp(src) && nCoeff_is_Q(bDst)) 540 561 return naMapP0; /// Z/p --> Q(a) 541 562 542 if (nCoeff_is_Q_a(src) && nCoeff_is_Q_a(dst)) 563 if (nCoeff_is_Q(src) && nCoeff_is_Zp(bDst)) 564 return naMap0P; /// Q --> Z/p(a) 565 566 if (nCoeff_is_Zp(src) && nCoeff_is_Zp(bDst)) 567 { 568 if (src->ch == dst->ch) return naMapPP; /// Z/p --> Z/p(a) 569 else return naMapUP; /// Z/u --> Z/p(a) 570 } 571 572 coeffs bSrc = nCoeff_bottom(src, h); /* the bottom field in the tower src */ 573 if (h != 1) return NULL; 574 if ((!nCoeff_is_Zp(bSrc)) && (!nCoeff_is_Q(bSrc))) return NULL; 575 576 if (nCoeff_is_Q(bSrc) && nCoeff_is_Q(bDst)) 543 577 { 544 578 if (strcmp(rParameter(src->algring)[0], … … 549 583 } 550 584 551 if (nCoeff_is_Q(src) && nCoeff_is_Zp_a(dst)) 552 return naMap0P; /// Q --> Z/p(a) 553 554 if (nCoeff_is_Zp(src) && nCoeff_is_Zp_a(dst)) 555 { 556 if (src->ch == dst->ch) return naMapPP; /// Z/p --> Z/p(a) 557 else return naMapUP; /// Z/u --> Z/p(a) 558 } 559 560 if (nCoeff_is_Zp_a(src) && nCoeff_is_Zp_a(dst)) 585 if (nCoeff_is_Zp(bSrc) && nCoeff_is_Zp(bDst)) 561 586 { 562 587 if (strcmp(rParameter(src->algring)[0], -
libpolys/polys/monomials/ring.cc
r73a9ffb r488808e 736 736 } 737 737 738 int rChar(ring r) 739 { 740 TODO(Somabody, move this proc. over to coeffs!?); 741 742 #ifdef HAVE_RINGS 743 if (rField_is_Ring_2toM(r)) 744 return binaryPower(2, (int)(unsigned long)r->cf->modExponent); 745 if (rField_is_Ring_ModN(r)) 746 return (int)mpz_get_ui(r->cf->modBase); 747 if (rField_is_Ring_PtoM(r)) 748 return binaryPower((int)mpz_get_ui(r->cf->modBase), 749 (int)(unsigned long)r->cf->modExponent); 750 751 #endif 752 if (rField_is_numeric(r)) 753 return 0; 754 if (!rIsExtension(r)) /* Q, Fp */ 755 return r->cf->ch; 756 if (rField_is_Zp_a(r)) /* Fp(a) */ 757 return -r->cf->ch; 758 if (rField_is_Q_a(r)) /* Q(a) */ 759 return 0; 760 /*else*/ /* GF(p,n) */ 761 { 762 if ((r->cf->ch & 1)==0) return 2; 763 int i=3; 764 while ((r->cf->ch % i)!=0) i+=2; 765 return i; 766 } 767 } 738 /* we keep this otherwise superfluous method for compatibility reasons 739 towards the SINGULAR svn trunk */ 740 int rChar(ring r) { return r->cf->ch; } 768 741 769 742 typedef char * char_ptr; -
libpolys/polys/monomials/ring.h
r73a9ffb r488808e 470 470 { assume(r != NULL); return nCoeff_is_GF(r->cf, q); } 471 471 472 /* DO NOT USE; just here for compatibility reasons towards 473 the SINGULAR svn trunk */ 472 474 static inline BOOLEAN rField_is_Zp_a(const ring r) 473 475 { assume(r != NULL); return nCoeff_is_Zp_a(r->cf); } 474 476 477 /* DO NOT USE; just here for compatibility reasons towards 478 the SINGULAR svn trunk */ 475 479 static inline BOOLEAN rField_is_Zp_a(const ring r, int p) 476 480 { assume(r != NULL); return nCoeff_is_Zp_a(r->cf, p); } 477 481 482 /* DO NOT USE; just here for compatibility reasons towards 483 the SINGULAR svn trunk */ 478 484 static inline BOOLEAN rField_is_Q_a(const ring r) 479 485 { assume(r != NULL); return nCoeff_is_Q_a(r->cf); } -
libpolys/tests/coeffs_test.h
r73a9ffb r488808e 278 278 TS_ASSERT( !nCoeff_is_numeric( r )); 279 279 TS_ASSERT( !nCoeff_is_R( r )); 280 TS_ASSERT( !nCoeff_is_Q_a( r ));281 TS_ASSERT( !nCoeff_is_Zp_a( r ));282 280 TS_ASSERT( !nCoeff_is_GF( r )); 283 281 TS_ASSERT( !nCoeff_is_long_R( r )); -
libpolys/tests/polys_test.h
r73a9ffb r488808e 584 584 TS_ASSERT( nCoeff_is_algExt(cf) ); 585 585 TS_ASSERT( !nCoeff_is_transExt(cf) ); 586 TS_ASSERT( nCoeff_is_Q_a(cf) );587 TS_ASSERT( !nCoeff_is_Zp_a(cf) );588 586 589 587 // some tests for the coefficient field represented by cf: … … 687 685 TS_ASSERT( nCoeff_is_algExt(cf) ); 688 686 TS_ASSERT( !nCoeff_is_transExt(cf) ); 689 TS_ASSERT( nCoeff_is_Q_a(cf) );690 TS_ASSERT( !nCoeff_is_Zp_a(cf) );691 687 692 688 // some tests for the coefficient field represented by cf: … … 833 829 TS_ASSERT( nCoeff_is_algExt(cf) ); 834 830 TS_ASSERT( !nCoeff_is_transExt(cf) ); 835 TS_ASSERT( !nCoeff_is_Q_a(cf) );836 TS_ASSERT( nCoeff_is_Zp_a(cf) );837 831 838 832 // some tests for the coefficient field represented by cf:
Note: See TracChangeset
for help on using the changeset viewer.