Changeset 4f9652 in git


Ignore:
Timestamp:
Aug 2, 2012, 3:33:00 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '96ce329119711a2b80858c8365abd29f8460bbfa')
Children:
d7ad81d4a58a77b7c782dc91c68ba5aa2a7f148c
Parents:
188de86ff46e2712a74ba7395b129a90c6d0b3f5
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2012-08-02 15:33:00+02:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2012-08-02 16:10:41+02:00
Message:
add: nlClearContent
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/longrat.cc

    r188de86 r4f9652  
    26372637}
    26382638
    2639 static void nlClearContent(ICoeffsEnumerator& /*numberCollectionEnumerator*/, number& c, const coeffs cf)
     2639static void nlClearContent(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf)
    26402640{
    26412641  assume(cf != NULL);
     
    26432643  // all coeffs are given by integers!!!
    26442644
    2645   c = n_Init(1, cf);
    2646   assume(FALSE); // TODO: NOT YET IMPLEMENTED!!!
    2647 
    2648 //   numberCollectionEnumerator.Reset();
    2649 //
    2650 //   c = numberCollectionEnumerator.Current();
    2651 //
    2652 //   n_Normalize(c, r);
    2653 //
    2654 //   if (!n_IsOne(c, r))
    2655 //   {   
    2656 //     numberCollectionEnumerator.Current() = n_Init(1, r); // ???
    2657 //
    2658 //     number inv = n_Invers(c, r);
    2659 //
    2660 //     while( numberCollectionEnumerator.MoveNext() )
    2661 //     {
    2662 //       number &n = numberCollectionEnumerator.Current();
    2663 //       n_Normalize(n, r); // ?
    2664 //       n_InpMult(n, inv, r);
    2665 //     }
    2666 //
    2667 //     n_Delete(&inv, r);
    2668 //   }
     2645  // part 1, find a small candidate for gcd
     2646  number cand1,cand;
     2647  int s1,s;
     2648  s=2147483647; // max. int
     2649  numberCollectionEnumerator.Reset();
     2650  do
     2651  {
     2652    cand1= numberCollectionEnumerator.Current();
     2653    if (SR_HDL(cand1)&SR_INT) { cand=cand1;break;}
     2654    s1=mpz_size1(cand1->z);
     2655    if (s>s1)
     2656    {
     2657      cand=cand1;
     2658      s=s1;
     2659    }
     2660  } while (numberCollectionEnumerator.MoveNext() );
     2661 
     2662  // part 2: compute gcd(cand,all coeffs)
     2663  numberCollectionEnumerator.Reset();
     2664  do
     2665  {
     2666    nlNormalize(numberCollectionEnumerator.Current(),cf);
     2667    cand1= nlGcd(cand,numberCollectionEnumerator.Current(),cf);
     2668    nlDelete(&cand,cf);
     2669    cand=cand1;
     2670    if(nlIsOne(cand,cf)) { c=cand; return; }
     2671  } while (numberCollectionEnumerator.MoveNext() );
     2672 
     2673  // part3: all coeffs = all coeffs / cand
     2674  c=cand;
     2675  numberCollectionEnumerator.Reset();
     2676  do
     2677  {
     2678    number t=nlIntDiv(numberCollectionEnumerator.Current(),cand,cf);
     2679    nlDelete(&numberCollectionEnumerator.Current(),cf);
     2680    numberCollectionEnumerator.Current()=t;
     2681  } while (numberCollectionEnumerator.MoveNext() );
     2682 
    26692683}
    26702684
Note: See TracChangeset for help on using the changeset viewer.