Changeset 39d731 in git


Ignore:
Timestamp:
Aug 10, 2012, 5:52:11 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '6e5adcba05493683b94648c659a729c189812c77')
Children:
285a39387fec8e81c98db529fa68b87b73a65cd6
Parents:
73260639099e75033ef78f48ad34a0ee10e1c15e
Message:
fix: nlClearDenom/nlContent: lead coeff >0
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/longrat.cc

    r7326063 r39d731  
    26532653  s=2147483647; // max. int
    26542654  numberCollectionEnumerator.Reset();
     2655  int lc_is_pos=nlGreaterZero(numberCollectionEnumerator.Current(),cf);
    26552656  do
    26562657  {
    26572658    cand1= numberCollectionEnumerator.Current();
    26582659    if (SR_HDL(cand1)&SR_INT) { cand=cand1;break;}
     2660    assume(cand1->s==3); // all coeffs should be integers
    26592661    s1=mpz_size1(cand1->z);
    26602662    if (s>s1)
     
    26712673  {
    26722674    nlNormalize(numberCollectionEnumerator.Current(),cf);
    2673     cand1= nlGcd(cand,numberCollectionEnumerator.Current(),cf);
    2674     nlDelete(&cand,cf);
     2675    nlInpGcd(cand,numberCollectionEnumerator.Current(),cf);
    26752676    cand=cand1;
    2676     if(nlIsOne(cand,cf)) { c=cand; return; }
     2677    if(nlIsOne(cand,cf))
     2678    {
     2679      c=cand;
     2680      if(!lc_is_pos)
     2681      {
     2682        // make the leading coeff positive
     2683        c=nlNeg(c,cf);
     2684        numberCollectionEnumerator.Reset();
     2685        do
     2686        {
     2687          numberCollectionEnumerator.Current()=nlNeg(numberCollectionEnumerator.Current(),cf);
     2688        } while (numberCollectionEnumerator.MoveNext() );
     2689      }
     2690      return;
     2691    }
    26772692  } while (numberCollectionEnumerator.MoveNext() );
    26782693
    26792694  // part3: all coeffs = all coeffs / cand
     2695  if (!lc_is_pos) cand=nlNeg(cand,cf);
    26802696  c=cand;
    26812697  numberCollectionEnumerator.Reset();
     
    27072723  mpz_init(tmp);
    27082724  numberCollectionEnumerator.Reset();
     2725  int lc_is_pos=nlGreaterZero(numberCollectionEnumerator.Current(),cf);
    27092726  do
    27102727  {
     
    27392756    mpz_clear(tmp);
    27402757    FREE_RNUMBER(cand);
    2741     c=nlInit(1,cf);
     2758    if (lc_is_pos)
     2759      c=nlInit(1,cf);
     2760    else
     2761    {
     2762      // make the leading coeff positive
     2763      c=nlInit(-1,cf);
     2764      numberCollectionEnumerator.Reset();
     2765      do
     2766      {
     2767        numberCollectionEnumerator.Current()=nlNeg(numberCollectionEnumerator.Current(),cf);
     2768      } while (numberCollectionEnumerator.MoveNext() );
     2769    }
    27422770    return;
    27432771  }
Note: See TracChangeset for help on using the changeset viewer.