Ignore:
Timestamp:
Aug 14, 2013, 5:44:47 PM (11 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
e7af713b2118666efd56a51c8fd09dcc0b99e0ee
Parents:
adae8b2811aa80401958b914b4cfc7d0ad8eb36b
Message:
chg: improve ntNormalize etc.
File:
1 edited

Legend:

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

    radae8b r5a4e17  
    11001100
    11011101  fraction f = (fraction)a;
    1102   if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; ntTest(a); return; }
     1102  if (COM(f)!=0) p_Normalize(NUM(f), ntRing);
     1103  if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }
     1104
     1105  p_Normalize(DEN(f), ntRing);
    11031106
    11041107  assume( DEN(f) != NULL );
     
    11531156
    11541157  if (IS0(a)) return;
    1155   if (NUM(f)!=NULL) p_Normalize(NUM(f), ntRing);
    1156   if (DEN(f)!=NULL) p_Normalize(DEN(f), ntRing);
    11571158  if (!simpleTestsHaveAlreadyBeenPerformed)
    11581159  {
     1160    p_Normalize(NUM(f), ntRing);
     1161    if (DEN(f)!=NULL) p_Normalize(DEN(f), ntRing);
    11591162    if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }
    11601163
     
    11691172    }
    11701173  }
     1174  if (rField_is_Q(ntRing))
     1175  {
     1176    number c=n_Copy(pGetCoeff(NUM(f)),ntCoeffs);
     1177    poly p=pNext(NUM(f));
     1178    while((p!=NULL)&&(!n_IsOne(c,ntCoeffs)))
     1179    {
     1180      number cc=n_Gcd(c,pGetCoeff(p),ntCoeffs);
     1181      n_Delete(&c,ntCoeffs);
     1182      c=cc;
     1183      pIter(p);
     1184    };
     1185    p=DEN(f);
     1186    while((p!=NULL)&&(!n_IsOne(c,ntCoeffs)))
     1187    {
     1188      number cc=n_Gcd(c,pGetCoeff(p),ntCoeffs);
     1189      n_Delete(&c,ntCoeffs);
     1190      c=cc;
     1191      pIter(p);
     1192    };
     1193    if(!n_IsOne(c,ntCoeffs))
     1194    {
     1195      p=NUM(f);
     1196      do
     1197      {
     1198        number cc=n_Div(pGetCoeff(p),c,ntCoeffs);
     1199        n_Normalize(cc,ntCoeffs);
     1200        p_SetCoeff(p,cc,ntRing);
     1201        pIter(p);
     1202      } while(p!=NULL);
     1203      p=DEN(f);
     1204      do
     1205      {
     1206        number cc=n_Div(pGetCoeff(p),c,ntCoeffs);
     1207        n_Normalize(cc,ntCoeffs);
     1208        p_SetCoeff(p,cc,ntRing);
     1209        pIter(p);
     1210      } while(p!=NULL);
     1211      n_Delete(&c,ntCoeffs);
     1212      if(pNext(DEN(f))==NULL)
     1213      {
     1214        if (p_IsOne(DEN(f),ntRing))
     1215        {
     1216          p_LmDelete(&DEN(f),ntRing);
     1217          COM(f)=0;
     1218          return;
     1219        }
     1220        else
     1221        {
     1222          return;
     1223        }
     1224      }
     1225    }
     1226  }
    11711227
    11721228#ifdef HAVE_FACTORY
    1173   /* Note that, over Q, singclap_gcd will remove the denominators in all
    1174      rational coefficients of pNum and pDen, before starting to compute
    1175      the gcd. Thus, we do not need to ensure that the coefficients of
    1176      pNum and pDen live in Z; they may well be elements of Q\Z. */
    1177   /* singclap_gcd destroys its arguments; we hence need copies: */
    1178   poly pGcd = singclap_gcd(p_Copy(NUM(f), ntRing), p_Copy(DEN(f), ntRing), cf->extRing);
    1179   if (p_IsConstant(pGcd, ntRing) &&
    1180       n_IsOne(p_GetCoeff(pGcd, ntRing), ntCoeffs))
     1229  poly pGcd;
     1230  /* here we assume: NUM(f), DEN(f) !=NULL, in Z_a reqp. Z/p_a */
     1231    pGcd = singclap_gcd_r(NUM(f), DEN(f), ntRing);
     1232  if (p_IsConstant(pGcd, ntRing)
     1233  //&& n_IsOne(p_GetCoeff(pGcd, ntRing), ntCoeffs)
     1234  )
    11811235  { /* gcd = 1; nothing to cancel;
    11821236       Suppose the given rational function field is over Q. Although the
     
    13501404     the gcd. Thus, we do not need to ensure that the coefficients of
    13511405     pa and pb live in Z; they may well be elements of Q\Z. */
    1352   poly pGcd = singclap_gcd(pa, pb, cf->extRing);
     1406  poly pGcd = singclap_gcd(pa, pb, ntRing);
    13531407  if (p_IsConstant(pGcd, ntRing) &&
    13541408      n_IsOne(p_GetCoeff(pGcd, ntRing), ntCoeffs))
Note: See TracChangeset for help on using the changeset viewer.