Changeset e11ed0 in git


Ignore:
Timestamp:
Aug 10, 2012, 2:45:29 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '96ce329119711a2b80858c8365abd29f8460bbfa')
Children:
e8eba79d5b1d97d0164270764c45f286deab00ca
Parents:
824c47a7ef5b40564c34a1392fd8a3a44558959b
Message:
fix: nlClearDenominator: less nlNormalize, positive leadcoeff
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/longrat.cc

    r824c47 re11ed0  
    865865    long j=SR_TO_INT(b);
    866866    if ((i==-POW_2_28) && (j== -1L))
    867     { 
     867    {
    868868      FREE_RNUMBER(u);
    869869      return nlRInit(POW_2_28);
     
    12571257
    12581258  // numerator modulo char. should fit into int
    1259   number z = n_Init( static_cast<int>(mpz_fdiv_ui(q->z, PP)), Zp ); 
     1259  number z = n_Init( static_cast<int>(mpz_fdiv_ui(q->z, PP)), Zp );
    12601260
    12611261  // denominator != 1?
     
    24402440{
    24412441  assume( getCoeffType(r) == ID );
    2442    
     2442
    24432443  nlTest(n, r);
    24442444  nlNormalize(n, r);
     
    24542454  mpz_init_set_ui(z->n, 1);
    24552455  z->s = 3;
    2456   return z;   
     2456  return z;
    24572457}
    24582458
     
    26292629      s=s1;
    26302630    }
    2631   } while (numberCollectionEnumerator.MoveNext() ); 
    2632  
     2631  } while (numberCollectionEnumerator.MoveNext() );
     2632
    26332633  cand=nlCopy(cand,cf);
    26342634  // part 2: compute gcd(cand,all coeffs)
     
    26412641    cand=cand1;
    26422642    if(nlIsOne(cand,cf)) { c=cand; return; }
    2643   } while (numberCollectionEnumerator.MoveNext() ); 
    2644  
     2643  } while (numberCollectionEnumerator.MoveNext() );
     2644
    26452645  // part3: all coeffs = all coeffs / cand
    26462646  c=cand;
     
    26512651    nlDelete(&numberCollectionEnumerator.Current(),cf);
    26522652    numberCollectionEnumerator.Current()=t;
    2653   } while (numberCollectionEnumerator.MoveNext() ); 
    2654  
     2653  } while (numberCollectionEnumerator.MoveNext() );
     2654
    26552655}
    26562656
     
    26622662
    26632663  // part 1, collect product of all denominators /gcds
    2664   number cand; 
     2664  number cand;
    26652665  cand=ALLOC_RNUMBER();
    26662666  #if defined(LDEBUG)
     
    26762676  {
    26772677    number& cand1 = numberCollectionEnumerator.Current();
    2678     nlNormalize(cand1, cf);
    2679    
     2678
    26802679    if (!(SR_HDL(cand1)&SR_INT))
    26812680    {
     2681      nlNormalize(cand1, cf);
    26822682      if ((!(SR_HDL(cand1)&SR_INT)) // not a short int
    26832683      && (cand1->s==1))             // and is rational
     
    26852685        if (s==0) // first denom, we meet
    26862686        {
    2687           mpz_init_set(cand->z,cand1->n); 
    2688           s=1; 
     2687          mpz_init_set(cand->z,cand1->n);
     2688          s=1;
    26892689        }
    26902690        else // we have already something
     
    26992699      }
    27002700    }
    2701   } while (numberCollectionEnumerator.MoveNext() ); 
     2701  } while (numberCollectionEnumerator.MoveNext() );
    27022702
    27032703  if (s==0) // nothing to do, all coeffs are already integers
    27042704  {
    27052705    mpz_clear(tmp);
    2706     FREE_RNUMBER(cand); 
    2707     c=nlInit(1,cf); 
     2706    FREE_RNUMBER(cand);
     2707    c=nlInit(1,cf);
    27082708    return;
    27092709  }
    27102710  cand=nlShort3(cand);
    2711  
     2711
    27122712  // part2: all coeffs = all coeffs * cand
     2713  // make the lead coeff positive
     2714  numberCollectionEnumerator.Reset();
     2715  if (!nlGreaterZero(numberCollectionEnumerator.Current(),cf))
     2716  {
     2717    cand=nlNeg(cand,cf);
     2718  }
    27132719  c = cand;
    2714   numberCollectionEnumerator.Reset();
    27152720  do
    27162721  {
    27172722    number &n = numberCollectionEnumerator.Current();
    27182723    n_InpMult(n, cand, cf);
    2719   } while (numberCollectionEnumerator.MoveNext() ); 
    2720  
     2724  } while (numberCollectionEnumerator.MoveNext() );
     2725
    27212726}
    27222727
     
    27322737  r->cfInitMPZ = nlInitMPZ;
    27332738  r->cfMPZ  = nlMPZ;
    2734    
     2739
    27352740  r->cfMult  = nlMult;
    27362741  r->cfSub   = nlSub;
     
    27432748  r->cfSize  = nlSize;
    27442749  r->cfInt  = nlInt;
    2745    
     2750
    27462751  r->cfChineseRemainder=nlChineseRemainder;
    27472752  r->cfFarey=nlFarey;
     
    27812786  r->cfClearContent = nlClearContent;
    27822787  r->cfClearDenominators = nlClearDenominators;
    2783  
     2788
    27842789#ifdef LDEBUG
    27852790  // debug stuff
Note: See TracChangeset for help on using the changeset viewer.