Changeset a8b44d in git


Ignore:
Timestamp:
Mar 21, 2011, 3:55:47 PM (12 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
9cd697732c2adbda992d49885d226fc966966251
Parents:
f4a33e267c2b5be378ef1fc5426935bee8f1e4d9
Message:
changed div check in Z/m, and command simplify over rings

git-svn-id: file:///usr/local/Singular/svn/trunk@14022 2c84dea3-7e68-4137-9b89-c4e89433aadc
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/ideals.cc

    rf4a33e ra8b44d  
    299299
    300300//
    301 // Delete id[j], if Lm(j) == Lm(i) and j > i
     301// Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i
    302302//
    303303void idDelLmEquals(ideal id)
     
    312312      {
    313313        if ((id->m[j] != NULL)
    314         && pLmEqual(id->m[i], id->m[j]))
     314        && pLmEqual(id->m[i], id->m[j])
     315#ifdef HAVE_RINGS
     316        && nIsUnit(pGetCoeff(id->m[i])) && nIsUnit(pGetCoeff(id->m[j]))
     317#endif
     318        )
    315319        {
    316320          pDelete(&id->m[j]);
     
    321325}
    322326
     327//
     328// delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e.,
     329// delete id[i], if LT(i) == coeff*mon*LT(j)
     330//
    323331void idDelDiv(ideal id)
    324332{
     
    333341        if (id->m[j]!=NULL)
    334342        {
    335           if(pDivisibleBy(id->m[i], id->m[j]))
     343#ifdef HAVE_RINGS
     344          if (rField_is_Ring(currRing))
    336345          {
    337             pDelete(&id->m[j]);
    338           }
    339           else if(pDivisibleBy(id->m[j], id->m[i]))
     346            if (pDivisibleByRingCase(id->m[i], id->m[j]))
     347            {
     348              pDelete(&id->m[j]);
     349            }
     350            else if (pDivisibleByRingCase(id->m[j], id->m[i]))
    340351          {
    341352            pDelete(&id->m[i]);
    342353            break;
    343354          }
     355          }
     356          else
     357          {
     358#endif
     359          /* the case of a ground field: */
     360          if (pDivisibleBy(id->m[i], id->m[j]))
     361          {
     362            pDelete(&id->m[j]);
     363          }
     364          else if (pDivisibleBy(id->m[j], id->m[i]))
     365          {
     366            pDelete(&id->m[i]);
     367            break;
     368          }
     369#ifdef HAVE_RINGS
     370          }
     371#endif         
    344372        }
    345373      }
  • kernel/polys.cc

    rf4a33e ra8b44d  
    9999* assumes that the head term of b is a multiple of the head term of a
    100100* and return the multiplicant *m
     101* Frank's observation: If LM(b) = LM(a)*m, then we may actually set
     102* negative(!) exponents in the below loop. I suspect that the correct
     103* comment should be "assumes that LM(a) = LM(b)*m, for some monomial m..."
    101104*/
    102105poly pDivide(poly a, poly b)
     
    130133  p_Test(q, r);
    131134  return q;
     135}
     136#endif
     137
     138static void printNumber(const number z)
     139{
     140  if (nIsZero(z)) printf("number = 0\n");
     141  else
     142  {
     143    poly p = pOne();
     144    pSetCoeff(p, nCopy(z));
     145    pSetm(p);
     146    printf("number = %s\n", pString(p));
     147    pDelete(&p);
     148  }
     149}
     150
     151#ifdef HAVE_RINGS
     152/* TRUE iff LT(f) | LT(g) */
     153BOOLEAN pDivisibleByRingCase(poly f, poly g)
     154{
     155  int exponent;
     156  for(int i = (int)pVariables; i; i--)
     157  {
     158    exponent = pGetExp(g, i) - pGetExp(f, i);
     159    if (exponent < 0) return FALSE;
     160  }
     161  return nDivBy(pGetCoeff(g), pGetCoeff(f));
    132162}
    133163#endif
     
    567597
    568598/*2
    569 *divides p1 by its leading coefficient
     599* divides p1 by its leading coefficient if it is a unit
     600* (this will always be true over fields; but not over coefficient rings)
    570601*/
    571602void pNorm(poly p1)
     
    574605  if (rField_is_Ring(currRing))
    575606  {
    576     Werror("pNorm not possible in the case of coefficient rings.");
    577   }
    578   else
     607    if (!nIsUnit(pGetCoeff(p1))) return;
     608  }
    579609#endif
    580610  if (p1!=NULL)
  • kernel/polys.h

    rf4a33e ra8b44d  
    169169// tests (see polys-impl.cc )
    170170#define pGetShortExpVector(a)   p_GetShortExpVector(a, currRing)
     171#ifdef HAVE_RINGS
     172/* divisibility check over ground ring (which may contain zero divisors);
     173   TRUE iff LT(f) divides LT(g), i.e., LT(f)*c*m = LT(g), for some
     174   coefficient c and some monomial m;
     175   does not take components into account */
     176BOOLEAN pDivisibleByRingCase(poly f, poly g);
     177#endif
    171178
    172179/***************************************************************
  • kernel/polys1.cc

    rf4a33e ra8b44d  
    17201720  if (rField_is_Ring(currRing))
    17211721  {
    1722     if ((pLength(p1) == 1) && (nEqual(pGetCoeff(p1), pGetCoeff(p2))))
    1723       return TRUE;
    1724     if (!nIsUnit(pGetCoeff(p2))) return FALSE;
     1722    if (!nDivBy(pGetCoeff(p1), pGetCoeff(p2))) return FALSE;
    17251723  }
    17261724#endif
  • kernel/rmodulon.cc

    rf4a33e ra8b44d  
    270270}
    271271
    272 BOOLEAN nrnDivBy (number a,number b)
     272BOOLEAN nrnDivBy (number a, number b)
    273273{
    274274  if (a == NULL)
    275     return mpz_divisible_p(currRing->nrnModul, (int_number) b);
     275    return mpz_divisible_p(currRing->nrnModul, (int_number)b);
    276276  else
    277     return mpz_divisible_p((int_number) a, (int_number) b);
    278   /*
    279   number bs = nrnGcd(a, b, currRing);
    280   mpz_tdiv_q((int_number) bs, (int_number) b, (int_number) bs);
    281   bool res = nrnIsUnit(bs);
    282   nrnDelete(&bs, NULL);
    283   return res;
    284   */
     277  { /* b divides a iff b/gcd(a, b) is a unit in the given ring: */
     278    number n = nrnGcd(a, b, currRing);
     279    mpz_tdiv_q((int_number)n, (int_number)b, (int_number)n);
     280    bool result = nrnIsUnit(n);
     281    nrnDelete(&n, NULL);
     282    return result;
     283  }
    285284}
    286285
Note: See TracChangeset for help on using the changeset viewer.