Ignore:
Timestamp:
Oct 21, 2015, 2:57:17 PM (9 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
5bd9ec36b87fa8f176a21995de2b56724d67be2d
Parents:
a1b6c917a1c8886b1bba1b05680ff06cfd39c82def1a968e317a12b42f88e04cd7f9483e47fba2f7
Message:
Merge pull request #718 from adipopescu/STDChanes2

Std over rings
File:
1 edited

Legend:

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

    ref1a96 r67e0dc  
    7272
    7373#ifdef LDEBUG
    74 #define ntTest(a) ntDBTest(a,__FILE__,__LINE__,cf)
    7574BOOLEAN  ntDBTest(number a, const char *f, const int l, const coeffs r);
    76 #else
    77 #define ntTest(a) do {} while (0)
    7875#endif
     76
     77#define ntTest(a) n_Test(a, cf)
    7978
    8079/// Our own type!
     
    184183  //check_N(a,cf);
    185184  const poly num = NUM(t);
    186   assume(num != NULL);   /**< t != 0 ==> numerator(t) != 0 */
     185  assume(num != NULL);   ///< t != 0 ==> numerator(t) != 0
    187186
    188187  p_Test(num, ntRing);
    189188
     189  if (getCoeffType(ntCoeffs)==n_Q)
     190    for( poly p = num; p != NULL; pIter(p) )
     191      if (! nlIsInteger( p_GetCoeff(p, ntRing), ntCoeffs) )
     192      {
     193        Print("ERROR in %s:%d: non-integer Q coeff in num. poly\n",f,l);
     194        Print("TERM: ");  p_wrp(p, ntRing); PrintLn();
     195        return FALSE;
     196      }
     197
    190198  const poly den = DEN(t);
    191199
     
    193201  {
    194202    p_Test(den, ntRing);
     203
     204    if (getCoeffType(ntCoeffs)==n_Q)
     205      for( poly p = den; p != NULL; pIter(p) )
     206        if (! nlIsInteger( p_GetCoeff(p, ntRing), ntCoeffs) )
     207        {
     208          Print("ERROR in %s:%d: non-integer Q coeff in den. poly\n",f,l);
     209          Print("TERM: "); p_wrp(p, ntRing);  PrintLn();
     210          return FALSE;
     211        }
     212
     213    if (getCoeffType(ntCoeffs)==n_Zp)
     214    {
     215      if( p_IsConstant(den, ntRing) )
     216      {
     217        Print("ERROR in %s:%d: constant den. poly / Zp\n",f,l);
     218        Print("NUM: ");  p_Write(num, ntRing);
     219        Print("DEN: ");  p_Write(den, ntRing);
     220        return FALSE;
     221      }
     222
     223      if( !n_IsOne(pGetCoeff(den), ntCoeffs) )
     224      {
     225        Print("ERROR in %s:%d: non-monic den. poly / Zp\n",f,l);
     226        Print("NUM: ");  p_Write(num, ntRing);
     227        Print("DEN: ");  p_Write(den, ntRing);
     228        return FALSE;
     229      }
     230    }
     231
     232    if (COM(t)==0)
     233    {
     234      poly gcd = singclap_gcd_r( num, den, ntRing );
     235      if( !p_IsOne(gcd, ntRing) )
     236      {
     237        Print("ERROR in %s:%d: 1 != GCD between num. & den. poly\n",f,l);
     238        Print("GCD: ");  p_Write(gcd, ntRing);
     239        Print("NUM: ");  p_Write(num, ntRing);
     240        Print("DEN: ");  p_Write(den, ntRing);
     241        return FALSE;
     242      }
     243      p_Delete( &gcd, ntRing );
     244    }
     245    return TRUE;
     246
     247
     248
    195249    if(p_IsConstant(den, ntRing) && (n_IsOne(pGetCoeff(den), ntCoeffs)))
    196250    {
     
    206260  }
    207261  else
    208   {  // num != NULL // den == NULL
     262  {
     263    return TRUE;
     264
     265    // num != NULL // den == NULL
    209266//    if( COM(t) != 0 )
    210267//    {
     
    279336  //check_N(*a,cf);
    280337  ntTest(*a); // !!!
     338
    281339  fraction f = (fraction)(*a);
    282340  if (IS0(f)) return;
     
    580638  if (p == NULL) return NULL;
    581639
     640  p_Test( p, ntRing);
    582641  fraction f = (fraction)omAlloc0Bin(fractionObjectBin);
    583642
     
    792851     COM(result) = COM(fa);
    793852     //check_N((number)result,cf);
     853     ntTest((number)result);
    794854     return (number)result;
    795855  }
     
    804864
    805865  //check_N((number)result,cf);
     866  ntTest((number)result);
    806867  return (number)result;
    807868}
     
    845906
    846907  //check_N((number)result,cf);
     908  ntTest((number)result);
    847909  return (number)result;
    848910}
     
    883945//  ntTest((number)result);
    884946  //check_N((number)result,cf);
     947  ntTest((number)result);
    885948  return (number)result;
    886949}
     
    9531016
    9541017  //check_N((number)result,cf);
     1018  ntTest((number)result);
    9551019  return (number)result;
    9561020}
     
    9891053  }
    9901054  COM(result) = COM(fa) + COM(fb) + MULT_COMPLEXITY;
     1055//  definiteGcdCancellation((number)result, cf,FALSE);
    9911056  heuristicGcdCancellation((number)result, cf);
    9921057//  ntTest((number)result);
    9931058  //check_N((number)result,cf);
     1059  ntTest((number)result);
    9941060  return (number)result;
    9951061}
     
    11861252
    11871253/* modifies a */
     1254/* this is an intermediate simplification routine - not a comple "normalize" */
    11881255void heuristicGcdCancellation(number a, const coeffs cf)
    11891256{
    1190 //  ntTest(a); // !!!!????
    11911257  if (IS0(a)) return;
    11921258
     
    12321298        }
    12331299      }
    1234     }
    1235   }
    1236 
    1237   ntTest(a);
     1300      if ((DEN(f)!=NULL)
     1301      && (pNext(DEN(f))==NULL))
     1302      {
     1303        poly den_f=DEN(f);
     1304        poly h=NUM(f);
     1305        loop
     1306        {
     1307          if (h==NULL)
     1308          {
     1309            h=NUM(f);
     1310            do
     1311            {
     1312              p_ExpVectorDiff(h,h,den_f,ntRing);
     1313              pIter(h);
     1314            } while(h!=NULL);
     1315            p_ExpVectorDiff(den_f,den_f,den_f,ntRing);
     1316            break;
     1317          }
     1318          int i=0;
     1319          do
     1320          {
     1321            i++;
     1322            if (p_GetExp(den_f,i,ntRing) > p_GetExp(h,i,ntRing)) return;
     1323          } while(i<ntRing->N);
     1324          pIter(h);
     1325        }
     1326      }
     1327    }
     1328  }
    12381329}
    12391330
     
    12421333                             BOOLEAN simpleTestsHaveAlreadyBeenPerformed)
    12431334{
    1244   ntTest(a); // !!!!
     1335//  ntTest(a); // !!!!
    12451336
    12461337  fraction f = (fraction)a;
    12471338
    12481339  if (IS0(a)) return;
    1249   if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }
     1340  if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; ntTest(a); return; }
    12501341  if (!simpleTestsHaveAlreadyBeenPerformed)
    12511342  {
     
    13441435       to be != 1. */
    13451436    if (p_IsConstant(DEN(f), ntRing) &&
    1346         n_IsOne(p_GetCoeff(DEN(f), ntRing), ntCoeffs))
     1437      n_IsOne(p_GetCoeff(DEN(f), ntRing), ntCoeffs))
    13471438    {
    13481439      /* DEN(f) = 1 needs to be represented by NULL! */
     
    13671458    }
    13681459  }
     1460  p_Delete(&pGcd, ntRing);
    13691461  COM(f) = 0;
    1370   p_Delete(&pGcd, ntRing);
    13711462
    13721463  if( DEN(f) != NULL )
     1464  {
    13731465    if( !n_GreaterZero(pGetCoeff(DEN(f)), ntCoeffs) )
    13741466    {
     
    13831475      }
    13841476    }
     1477  }
    13851478  ntTest(a); // !!!!
    13861479}
     
    14421535  if (p == NULL) *a = NULL;
    14431536  else *a = ntInit(p, cf);
     1537  ntTest(*a);
    14441538  return result;
    14451539}
     
    15701664    return (number)result;
    15711665
    1572   return NULL;
     1666    return NULL;
    15731667}
    15741668
     
    16611755  int noOfTerms = 0;
    16621756  int numDegree = 0;
    1663   while (p != NULL)
    1664   {
    1665     noOfTerms++;
    1666     int d = 0;
    1667     for (int i = 1; i <= rVar(ntRing); i++)
    1668       d += p_GetExp(p, i, ntRing);
    1669     if (d > numDegree) numDegree = d;
    1670     pIter(p);
     1757  if (p!=NULL)
     1758  {
     1759    numDegree = p_Totaldegree(p,ntRing);
     1760    noOfTerms = pLength(p);
    16711761  }
    16721762  int denDegree = 0;
    16731763  if (!DENIS1(f))
    16741764  {
    1675     p = DEN(f);
    1676     while (p != NULL)
    1677     {
    1678       noOfTerms++;
    1679       int d = 0;
    1680       for (int i = 1; i <= rVar(ntRing); i++)
    1681         d += p_GetExp(p, i, ntRing);
    1682       if (d > denDegree) denDegree = d;
    1683       pIter(p);
    1684     }
     1765    denDegree =  p_Totaldegree(DEN(f),ntRing);
     1766    noOfTerms += pLength(DEN(f));
    16851767  }
    16861768  ntTest(a); // !!!!
     
    17481830number ntMap00(number a, const coeffs src, const coeffs dst)
    17491831{
     1832  n_Test(a, src);
     1833
    17501834  if (n_IsZero(a, src)) return NULL;
    1751   n_Test(a, src);
    17521835  assume(src->rep == dst->extRing->cf->rep);
    17531836  if ((SR_HDL(a) & SR_INT) || (a->s==3))
    17541837  {
    17551838    number res=ntInit(p_NSet(n_Copy(a, src), dst->extRing), dst);
    1756     n_Test(res,dst);
     1839    n_Test(res, dst);
    17571840    return res;
    17581841  }
     
    17631846  if (n_IsOne(nn,src)) DEN(ff)=NULL;
    17641847  else                 DEN(ff)=p_NSet(nn,dst->extRing);
     1848
    17651849  n_Test((number)ff,dst);
    17661850  //check_N((number)ff,dst);
     
    17701854number ntMapZ0(number a, const coeffs src, const coeffs dst)
    17711855{
     1856  n_Test(a, src);
    17721857  if (n_IsZero(a, src)) return NULL;
    1773   n_Test(a, src);
    17741858  nMapFunc nMap=n_SetMap(src,dst->extRing->cf);
    17751859  poly p=p_NSet(nMap(a, src,dst->extRing->cf), dst->extRing);
     
    17841868number ntMapP0(number a, const coeffs src, const coeffs dst)
    17851869{
     1870  n_Test(a, src);
    17861871  if (n_IsZero(a, src)) return NULL;
    1787   n_Test(a, src);
    17881872  /* mapping via intermediate int: */
    17891873  int n = n_Int(a, src);
     
    23802464{
    23812465  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
    2382   int i;
    23832466
    23842467  poly *P=(poly*)omAlloc(rl*sizeof(poly*));
    23852468  number *X=(number *)omAlloc(rl*sizeof(number));
     2469
     2470  int i;
    23862471
    23872472  for(i=0;i<rl;i++) P[i]=p_Copy(NUM((fraction)(x[i])),cf->extRing);
     
    24022487    p_Delete(&DEN(result),ntRing);
    24032488  }
     2489  ntTest((number)result);
    24042490  return ((number)result);
    24052491}
     
    24112497  NUM(result)=p_Farey(p_Copy(NUM((fraction)p),cf->extRing),n,cf->extRing);
    24122498  DEN(result)=p_Farey(p_Copy(DEN((fraction)p),cf->extRing),n,cf->extRing);
     2499  ntTest((number)result);
    24132500  return ((number)result);
    24142501}
Note: See TracChangeset for help on using the changeset viewer.