Changeset 3c0498 in git for libpolys/polys/ext_fields


Ignore:
Timestamp:
Mar 21, 2012, 8:29:49 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
1f49983e2c0b18b90d6918660ec7a49d584e535e8c8dba7f7269572699622a97ae531f403418954a
Parents:
2d2c99cd52253e2a0a953a1aa32a55546c4a67cc
Message:
fix: minpoly in ringlist (Manaul/elimRing.tst)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/ext_fields/algext.cc

    r2d2c99c r3c0498  
    7676
    7777/// forward declarations
    78 BOOLEAN  naGreaterZero(number a, const coeffs cf); 
     78BOOLEAN  naGreaterZero(number a, const coeffs cf);
    7979BOOLEAN  naGreater(number a, number b, const coeffs cf);
    8080BOOLEAN  naEqual(number a, number b, const coeffs cf);
     
    114114  if (a == NULL) return TRUE;
    115115  p_Test((poly)a, naRing);
    116   if(p_Totaldegree((poly)a, naRing) >= p_Totaldegree(naMinpoly, naRing))
     116  if((((poly)a)!=naMinpoly)
     117  && p_Totaldegree((poly)a, naRing) >= p_Totaldegree(naMinpoly, naRing))
    117118  {
    118119    Print("deg >= deg(minpoly) in %s:%d\n",f,l);
     
    153154{
    154155  if (*a == NULL) return;
     156  if (((poly)*a)==naMinpoly) { *a=NULL;return;}
    155157  poly aAsPoly = (poly)(*a);
    156158  p_Delete(&aAsPoly, naRing);
     
    161163{
    162164  naTest(a); naTest(b);
    163  
     165
    164166  /// simple tests
    165167  if (a == b) return TRUE;
     
    173175  if (b != NULL) bDeg = p_Totaldegree((poly)b, naRing);
    174176  if (aDeg != bDeg) return FALSE;
    175  
     177
    176178  /// subtraction test
    177179  number c = naSub(a, b, cf);
     
    185187  naTest(a);
    186188  if (a == NULL) return NULL;
     189  if (((poly)a)==naMinpoly) return a;
    187190  return (number)p_Copy((poly)a, naRing);
    188191}
     
    248251    return NULL;
    249252  }
    250  
     253
    251254  return (number)p_NSet(n, A);
    252255}
     
    298301{
    299302  assume( cf != NULL );
    300  
     303
    301304  const ring A = cf->extRing;
    302  
     305
    303306  assume( A != NULL );
    304307  assume( A->cf != NULL );
    305    
     308
    306309  n_CoeffWrite(A->cf, details);
    307  
     310
    308311//  rWrite(A);
    309  
     312
    310313  const int P = rVar(A);
    311314  assume( P > 0 );
    312  
     315
    313316  Print("//   %d parameter    : ", P);
    314  
     317
    315318  for (int nop=0; nop < P; nop ++)
    316319    Print("%s ", rRingVar(nop, A));
    317  
     320
    318321  PrintLn();
    319  
     322
    320323  const ideal I = A->minideal;
    321324
    322325  assume( I != NULL );
    323326  assume( IDELEMS(I) == 1 );
    324  
     327
    325328
    326329  if ( details )
     
    332335  else
    333336    PrintS("//   minpoly        : ...");
    334  
     337
    335338  PrintLn();
    336  
     339
    337340/*
    338341  char *x = rRingVar(0, A);
     
    400403{
    401404  naTest(a);
    402  
     405
    403406  /* special cases first */
    404407  if (a == NULL)
     
    410413  else if (exp ==  1) { *b = naCopy(a, cf); return; }
    411414  else if (exp == -1) { *b = naInvers(a, cf); return; }
    412  
     415
    413416  int expAbs = exp; if (expAbs < 0) expAbs = -expAbs;
    414  
     417
    415418  /* now compute a^expAbs */
    416419  poly pow; poly aAsPoly = (poly)a;
     
    446449    definiteReduce(pow, naMinpoly, cf);
    447450  }
    448  
     451
    449452  /* invert if original exponent was negative */
    450453  number n = (number)pow;
     
    552555  if( rEqual(naRing, e->r, TRUE) )
    553556  {
    554     const ideal mi = naRing->minideal; 
     557    const ideal mi = naRing->minideal;
    555558    assume( IDELEMS(mi) == 1 );
    556559    ideal ii = e->i;
     
    566569  }
    567570
    568   return FALSE; 
    569  
     571  return FALSE;
     572
    570573}
    571574
     
    604607{
    605608  poly aa=(poly)a;
    606   definiteReduce(aa,naMinpoly,cf);
     609  if (aa!=naMinpoly)
     610    definiteReduce(aa,naMinpoly,cf);
    607611  a=(number)aa;
    608612}
     
    646650  naTest((number)theGcd); naTest((number)aFactor); naTest((number)mFactor);
    647651  /* the gcd must be 1 since naMinpoly is irreducible and a != NULL: */
    648   assume(naIsOne((number)theGcd, cf));     
     652  assume(naIsOne((number)theGcd, cf));
    649653  p_Delete(&theGcd, naRing);
    650654  p_Delete(&mFactor, naRing);
     
    698702
    699703  poly result = p_NSet(q, dst->extRing);
    700  
     704
    701705  return (number)result;
    702706}
     
    730734
    731735  if( src == dst ) return ndCopyMap;
    732  
     736
    733737  int h = 0; /* the height of the extension tower given by dst */
    734738  coeffs bDst = nCoeff_bottom(dst, h); /* the bottom field in the tower dst */
    735739  coeffs bSrc = nCoeff_bottom(src, h); /* the bottom field in the tower src */
    736  
     740
    737741  /* for the time being, we only provide maps if h = 1 and if b is Q or
    738742     some field Z/pZ: */
     
    754758  if ((!nCoeff_is_Zp(bDst)) && (!nCoeff_is_Q(bDst))) return NULL;
    755759  if ((!nCoeff_is_Zp(bSrc)) && (!nCoeff_is_Q(bSrc))) return NULL;
    756  
     760
    757761  if (nCoeff_is_Q(bSrc) && nCoeff_is_Q(bDst))
    758762  {
     
    768772      return NULL;                               /// Q(b)   --> Q(a)
    769773  }
    770  
     774
    771775  if (nCoeff_is_Zp(bSrc) && nCoeff_is_Zp(bDst))
    772776  {
     
    781785      return NULL;                               /// Z/p(b) --> Z/p(a)
    782786  }
    783  
     787
    784788  return NULL;                                           /// default
    785789}
     
    798802
    799803  const ring R = cf->extRing;
    800   assume( R != NULL ); 
     804  assume( R != NULL );
    801805  assume( 0 < iParameter && iParameter <= rVar(R) );
    802806
    803807  poly p = p_One(R); p_SetExp(p, iParameter, 1, R); p_Setm(p, R);
    804808
    805   return (number) p; 
    806 }
    807 
    808 
    809 /// if m == var(i)/1 => return i, 
     809  return (number) p;
     810}
     811
     812
     813/// if m == var(i)/1 => return i,
    810814int naIsParam(number m, const coeffs cf)
    811815{
     
    813817
    814818  const ring R = cf->extRing;
    815   assume( R != NULL ); 
    816 
    817   return p_Var( (poly)m, R ); 
     819  assume( R != NULL );
     820
     821  return p_Var( (poly)m, R );
    818822}
    819823
    820824BOOLEAN naInitChar(coeffs cf, void * infoStruct)
    821 { 
     825{
    822826  assume( infoStruct != NULL );
    823827
     
    837841
    838842  ring R = e->r;
    839   assume(R != NULL);
    840  
     843
    841844  R->ref ++; // increase the ref.counter for the ground poly. ring!
    842845
    843   R->minideal = e->i; // make a copy? 
     846  R->minideal = e->i; // make a copy?
    844847
    845848  cf->extRing           = R;
     
    852855  p_Test((poly)naMinpoly, naRing);
    853856  #endif
    854  
     857
    855858  cf->cfGreaterZero  = naGreaterZero;
    856859  cf->cfGreater      = naGreater;
     
    860863  cf->cfIsMOne       = naIsMOne;
    861864  cf->cfInit         = naInit;
    862   cf->cfInit_bigint  = naInit_bigint; 
     865  cf->cfInit_bigint  = naInit_bigint;
    863866  cf->cfInt          = naInt;
    864867  cf->cfNeg          = naNeg;
     
    877880  else
    878881    cf->cfWriteShort = naWriteLong;
    879    
     882
    880883  cf->cfRead         = naRead;
    881884  cf->cfDelete       = naDelete;
     
    901904#endif
    902905  cf->cfParDeg = naParDeg;
    903  
     906
    904907  cf->iNumberOfParameters = rVar(R);
    905908  cf->pParameterNames = R->names;
    906909  cf->cfParameter = naParameter;
    907  
     910
    908911  return FALSE;
    909912}
Note: See TracChangeset for help on using the changeset viewer.