Changeset 488808e in git


Ignore:
Timestamp:
May 26, 2011, 12:12:01 PM (13 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
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
Message:
removed calls to nCoeff_is_Q_a and nCoeff_is_Zp_a (kept definitions for compatibility towards svn trunk); changed map in algext.cc
Location:
libpolys
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/coeffs.h

    r73a9ffb r488808e  
    4545typedef struct snumber *   number;
    4646
    47 struct snumber;
    48 typedef struct snumber *   number;
    49 
    5047/* standard types */
    5148#ifdef HAVE_RINGS
     
    5855
    5956struct n_Procs_s;
    60 typedef struct  n_Procs_s  n_Procs_s;
    6157typedef struct  n_Procs_s  *coeffs;
    6258
     
    182178//-------------------------------------------
    183179
    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
    187184  //number     minpoly;  //< no longer needed: replaced by
    188185  //                     //<  algring->minideal->[0]
     
    222219                     intermediate extension fields, i.e., in this case
    223220                     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 */
    226227
    227228  short      float_len; /* additional char-flags, rInit */
     
    233234  // for n_GF
    234235
    235   int m_nfCharQ;  ///< the number of elemts: q
     236  int m_nfCharQ;  ///< the number of elements: q
    236237  int m_nfM1;       ///< representation of -1
    237238  int m_nfCharP;  ///< the characteristic: p
     
    438439
    439440static 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)); }
    441442
    442443static inline BOOLEAN nCoeff_is_Q(const coeffs r)
     
    447448// (r->ringtype == 0) && (r->ch ==  -1); ??
    448449
    449 
    450450static inline BOOLEAN nCoeff_is_R(const coeffs r)
    451451{ assume(r != NULL); return getCoeffType(r)==n_R; }
     
    457457{ assume(r != NULL); return (getCoeffType(r)==n_GF) && (r->ch == q); }
    458458
    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 */
     460static 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) */
    461473static inline BOOLEAN nCoeff_is_Zp_a(const coeffs r)
    462474{
    463475  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) */
    471486static inline BOOLEAN nCoeff_is_Zp_a(const coeffs r, int p)
    472487{
    473488  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) */
    481498static inline BOOLEAN nCoeff_is_Q_a(const coeffs r)
    482499{
    483500  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));
    487502}
    488503
     
    507522// #endif
    508523
    509 
    510 
    511524/// TRUE if n_Delete/n_New are empty operations
    512525static inline BOOLEAN nCoeff_has_simple_Alloc(const coeffs r)
     
    520533//             || rField_is_R(r)); }
    521534
    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 
    529535/* TRUE iff r represents an algebraic extension field */
    530536static inline BOOLEAN nCoeff_is_algExt(const coeffs r)
  • libpolys/coeffs/numbers.cc

    r73a9ffb r488808e  
    7474{
    7575  int c = n_GetChar(r);
    76 printf("### c = %d\n", c);
    7776  BOOLEAN ret = n_IsZero(a, r);
    7877  if( (c != 0) && !ret )
  • libpolys/polys/ext_fields/algext.cc

    r73a9ffb r488808e  
    8787void definiteReduce(poly &p, poly reducer, const coeffs cf);
    8888
     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) */
     93static 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
    89107BOOLEAN naIsZero(number a, const coeffs cf)
    90108{
     
    526544nMapFunc naSetMap(const coeffs src, const coeffs dst)
    527545{
    528   /* dst is expected to be an algebraic extension field */
     546  /* dst is expected to be an algebraic field extension */
    529547  assume(getCoeffType(dst) == n_algExt);
    530548 
    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))
    537558    return naMap00;                                      /// Q     -->  Q(a)
    538559 
    539   if (nCoeff_is_Zp(src) && nCoeff_is_Q_a(dst))
     560  if (nCoeff_is_Zp(src) && nCoeff_is_Q(bDst))
    540561    return naMapP0;                                      /// Z/p   -->  Q(a)
    541562 
    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))
    543577  {
    544578    if (strcmp(rParameter(src->algring)[0],
     
    549583  }
    550584 
    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))
    561586  {
    562587    if (strcmp(rParameter(src->algring)[0],
  • libpolys/polys/monomials/ring.cc

    r73a9ffb r488808e  
    736736}
    737737
    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 */
     740int rChar(ring r) { return r->cf->ch; }
    768741
    769742typedef char *             char_ptr;
  • libpolys/polys/monomials/ring.h

    r73a9ffb r488808e  
    470470{ assume(r != NULL); return nCoeff_is_GF(r->cf, q); }
    471471
     472/* DO NOT USE; just here for compatibility reasons towards
     473   the SINGULAR svn trunk */
    472474static inline BOOLEAN rField_is_Zp_a(const ring r)
    473475{ assume(r != NULL); return nCoeff_is_Zp_a(r->cf); }
    474476
     477/* DO NOT USE; just here for compatibility reasons towards
     478   the SINGULAR svn trunk */
    475479static inline BOOLEAN rField_is_Zp_a(const ring r, int p)
    476480{ assume(r != NULL); return nCoeff_is_Zp_a(r->cf, p); }
    477481
     482/* DO NOT USE; just here for compatibility reasons towards
     483   the SINGULAR svn trunk */
    478484static inline BOOLEAN rField_is_Q_a(const ring r)
    479485{ assume(r != NULL); return nCoeff_is_Q_a(r->cf); }
  • libpolys/tests/coeffs_test.h

    r73a9ffb r488808e  
    278278      TS_ASSERT( !nCoeff_is_numeric( r ));
    279279      TS_ASSERT( !nCoeff_is_R( r ));
    280       TS_ASSERT( !nCoeff_is_Q_a( r ));
    281       TS_ASSERT( !nCoeff_is_Zp_a( r ));
    282280      TS_ASSERT( !nCoeff_is_GF( r ));
    283281      TS_ASSERT( !nCoeff_is_long_R( r ));
  • libpolys/tests/polys_test.h

    r73a9ffb r488808e  
    584584    TS_ASSERT( nCoeff_is_algExt(cf) );
    585585    TS_ASSERT( !nCoeff_is_transExt(cf) );
    586     TS_ASSERT( nCoeff_is_Q_a(cf) );
    587     TS_ASSERT( !nCoeff_is_Zp_a(cf) );
    588586   
    589587    // some tests for the coefficient field represented by cf:
     
    687685    TS_ASSERT( nCoeff_is_algExt(cf) );
    688686    TS_ASSERT( !nCoeff_is_transExt(cf) );
    689     TS_ASSERT( nCoeff_is_Q_a(cf) );
    690     TS_ASSERT( !nCoeff_is_Zp_a(cf) );
    691687   
    692688    // some tests for the coefficient field represented by cf:
     
    833829    TS_ASSERT( nCoeff_is_algExt(cf) );
    834830    TS_ASSERT( !nCoeff_is_transExt(cf) );
    835     TS_ASSERT( !nCoeff_is_Q_a(cf) );
    836     TS_ASSERT( nCoeff_is_Zp_a(cf) );
    837831   
    838832    // some tests for the coefficient field represented by cf:
Note: See TracChangeset for help on using the changeset viewer.