Changeset 67e0dc in git for libpolys/polys


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

Std over rings
Location:
libpolys/polys
Files:
1 deleted
10 edited

Legend:

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

    ref1a968 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}
  • libpolys/polys/kbuckets.cc

    ra1b6c91 r67e0dc  
    1414#include <coeffs/coeffs.h>
    1515#include <polys/monomials/ring.h>
    16 //#include <kernel/p_Procs.h>
    1716//#include <kernel/GBEngine/kutil.h>
    1817#include <polys/kbuckets.h>
  • libpolys/polys/kbuckets.h

    ref1a968 r67e0dc  
    193193
    194194#ifndef HAVE_PSEUDO_BUCKETS
    195 inline void kBucketAdjustBucketsUsed(kBucket_pt bucket)
     195static inline void kBucketAdjustBucketsUsed(kBucket_pt bucket)
    196196{
    197197  while ( bucket->buckets_used > 0 &&
  • libpolys/polys/monomials/p_polys.cc

    ref1a968 r67e0dc  
    116116    {
    117117      hh=xx[j];
    118       if ((hh!=NULL) && (p_LmCmp(r,hh,R)==0))
     118      if ((hh!=NULL) && (p_LmCmp(h,hh,R)==0))
    119119      {
    120120        x[j]=pGetCoeff(hh);
     
    22582258    n_Normalize(pGetCoeff(ph),r->cf);
    22592259    if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
    2260     if (rField_is_Q(r)) // should not be used anymore if CLEARENUMERATORS is 1
     2260    if (rField_is_Q(r)||(getCoeffType(r->cf)==n_transExt)) // should not be used anymore if CLEARENUMERATORS is 1
    22612261    {
    22622262      h=p_InitContent(ph,r);
     
    24482448
    24492449static number p_InitContent(poly ph, const ring r)
    2450 // only for coefficients in Q
     2450// only for coefficients in Q and rational functions
    24512451#if 0
    24522452{
     
    24992499{
    25002500  number d=pGetCoeff(ph);
    2501   if(SR_HDL(d)&SR_INT) return d;
    2502   int s=mpz_size1(d->z);
     2501  int s;
    25032502  int s2=-1;
    2504   number d2;
     2503  if(rField_is_Q(r))
     2504  {
     2505    if  (SR_HDL(d)&SR_INT) return d;
     2506    s=mpz_size1(d->z);
     2507  }
     2508  else
     2509    s=n_Size(d,r);
     2510  number d2=d;
    25052511  loop
    25062512  {
     
    25112517      break;
    25122518    }
    2513     if (SR_HDL(pGetCoeff(ph))&SR_INT)
    2514     {
    2515       s2=s;
    2516       d2=d;
    2517       s=0;
    2518       d=pGetCoeff(ph);
    2519       if (s2==0) break;
     2519    if (rField_is_Q(r))
     2520    {
     2521      if (SR_HDL(pGetCoeff(ph))&SR_INT)
     2522      {
     2523        s2=s;
     2524        d2=d;
     2525        s=0;
     2526        d=pGetCoeff(ph);
     2527        if (s2==0) break;
     2528      }
     2529      else if (mpz_size1((pGetCoeff(ph)->z))<=s)
     2530      {
     2531        s2=s;
     2532        d2=d;
     2533        d=pGetCoeff(ph);
     2534        s=mpz_size1(d->z);
     2535      }
    25202536    }
    25212537    else
    2522     if (mpz_size1((pGetCoeff(ph)->z))<=s)
    2523     {
    2524       s2=s;
    2525       d2=d;
    2526       d=pGetCoeff(ph);
    2527       s=mpz_size1(d->z);
    2528     }
    2529   }
    2530   return n_Gcd(d,d2,r->cf);
     2538    {
     2539      int ns=n_Size(pGetCoeff(ph),r);
     2540      if (ns<=3)
     2541      {
     2542        s2=s;
     2543        d2=d;
     2544        d=pGetCoeff(ph);
     2545        s=ns;
     2546        if (s2<=3) break;
     2547      }
     2548      else if (ns<s)
     2549      {
     2550        s2=s;
     2551        d2=d;
     2552        d=pGetCoeff(ph);
     2553        s=ns;
     2554      }
     2555    }
     2556  }
     2557  return n_SubringGcd(d,d2,r->cf);
    25312558}
    25322559#endif
     
    30953122{
    30963123  int count = 0;
     3124  if (r->cf->has_simple_Alloc)
     3125    return pLength(p);
    30973126  while ( p != NULL )
    30983127  {
     
    45314560{
    45324561  assume(p != NULL);
    4533   if (p == NULL) return 0;
    45344562  unsigned long ev = 0; // short exponent vector
    45354563  unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
    45364564  unsigned int m1; // highest bit which is filled with (n+1)
    4537   unsigned int i = 0, j=1;
     4565  int i=0,j=1;
    45384566
    45394567  if (n == 0)
     
    45464574    else
    45474575    {
    4548       for (; j<=(unsigned long) r->N; j++)
     4576      for (; j<=r->N; j++)
    45494577      {
    45504578        if (p_GetExp(p,j,r) > 0) i++;
     
    45524580      }
    45534581      if (i>0)
    4554         ev = ~((unsigned long)0) >> ((unsigned long) (BIT_SIZEOF_LONG - i));
     4582        ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
    45554583      return ev;
    45564584    }
     
    45804608
    45814609
     4610///  p_GetShortExpVector of p * pp
    45824611unsigned long p_GetShortExpVector(const poly p, const poly pp, const ring r)
    45834612{
    45844613  assume(p != NULL);
    45854614  assume(pp != NULL);
    4586   if (p == NULL || pp == NULL) return 0;
    45874615
    45884616  unsigned long ev = 0; // short exponent vector
    45894617  unsigned int n = BIT_SIZEOF_LONG / r->N; // number of bits per exp
    45904618  unsigned int m1; // highest bit which is filled with (n+1)
    4591   unsigned int i = 0, j=1;
     4619  int j=1;
     4620  unsigned long i = 0L;
    45924621
    45934622  if (n == 0)
     
    46004629    else
    46014630    {
    4602       for (; j<=(unsigned long) r->N; j++)
     4631      for (; j<=r->N; j++)
    46034632      {
    46044633        if (p_GetExp(p,j,r) > 0 || p_GetExp(pp,j,r) > 0) i++;
     
    46064635      }
    46074636      if (i>0)
    4608         ev = ~((unsigned long)0) >> ((unsigned long) (BIT_SIZEOF_LONG - i));
     4637        ev = ~(0UL) >> (BIT_SIZEOF_LONG - i);
    46094638      return ev;
    46104639    }
  • libpolys/polys/monomials/p_polys.h

    ra1b6c91 r67e0dc  
    15831583    while (i>=0);
    15841584  }
    1585 #ifdef HAVE_RINGS
     1585/*#ifdef HAVE_RINGS
    15861586  pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf));
    15871587  return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf);
    15881588#else
     1589*/
    15891590  pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == TRUE);
    15901591  return TRUE;
    1591 #endif
     1592//#endif
    15921593}
    15931594
     
    16041605  }
    16051606  while (i);
    1606 #ifdef HAVE_RINGS
     1607/*#ifdef HAVE_RINGS
    16071608  return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
    16081609#else
     1610*/
    16091611  return TRUE;
    1610 #endif
     1612//#endif
    16111613}
    16121614
     
    16241626  }
    16251627  while (i>=start);
    1626 #ifdef HAVE_RINGS
     1628/*#ifdef HAVE_RINGS
    16271629  return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf);
    16281630#else
     1631*/
    16291632  return TRUE;
    1630 #endif
     1633//#endif
    16311634}
    16321635static inline BOOLEAN _p_LmDivisibleByPart(poly a, const ring r_a, poly b, const ring r_b,const int start, const int end)
  • libpolys/polys/monomials/ring.cc

    ra1b6c91 r67e0dc  
    48914891{
    48924892  return rAssure_Global(ringorder_C, ringorder_dp, r);
     4893}
     4894
     4895ring rAssure_c_dp(const ring r)
     4896{
     4897  return rAssure_Global(ringorder_c, ringorder_dp, r);
    48934898}
    48944899
  • libpolys/polys/monomials/ring.h

    ra1b6c91 r67e0dc  
    728728ring   rAssure_dp_C(const ring r);
    729729ring   rAssure_C_dp(const ring r);
     730ring   rAssure_c_dp(const ring r);
    730731
    731732/// makes sure that c/C ordering is last ordering
  • libpolys/polys/prCopy.cc

    ref1a968 r67e0dc  
    5454  poly dest = &dest_s;
    5555
     56  poly prev;
    5657  while (src != NULL)
    5758  {
    58     poly prev=dest;
    59     pNext(dest) = (poly) p_Init(dest_r); pIter(dest);
     59    pNext(dest) = (poly) p_Init(dest_r);
     60    prev = dest;
     61    pIter(dest);
    6062
    6163    pSetCoeff0(dest, nMap(pGetCoeff(src),src_r->cf,dest_r->cf));
     
    6365    if (n_IsZero(pGetCoeff(dest),dest_r->cf))
    6466    {
    65       p_LmDelete(pNext(prev),dest_r);
    66       dest=pNext(prev);
     67      p_LmDelete(&pNext(prev),dest_r);
    6768    }
    6869    pIter(src);
  • libpolys/polys/simpleideals.cc

    ra1b6c91 r67e0dc  
    7373    for (int i = 0; i <= j; i++)
    7474    {
    75       Print("generator %d: ",i); p_wrp(id->m[i], lmRing, tailRing);
     75      Print("generator %d: ",i); p_wrp(id->m[i], lmRing, tailRing);PrintLn();
    7676    }
    7777  }
  • libpolys/polys/simpleideals.h

    ref1a968 r67e0dc  
    1414/// thoughout Singular. Basic use-cases for it are:
    1515/// * ideal/module: nrows = 1, ncols >=0 and rank:1 for ideals, rank>=0 for modules
    16 /// * matrix: nrows, ncols >=0, rank == nrows! see mp_* procedures 
     16/// * matrix: nrows, ncols >=0, rank == nrows! see mp_* procedures
    1717/// NOTE: the m member point to memory chunk of size (ncols*nrows*sizeof(poly)) or is NULL
    1818struct sip_sideal
Note: See TracChangeset for help on using the changeset viewer.