Changeset d1d27f in git


Ignore:
Timestamp:
Aug 3, 2012, 7:33:11 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '96ce329119711a2b80858c8365abd29f8460bbfa')
Children:
6993c8371c2a089de1e05f7e0a7e9ab0f8c76145
Parents:
69c542f9869e7a3e82b1cc481139d89110b7afd3
Message:
add: nlClearContent
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/longrat.cc

    r69c542 rd1d27f  
    26602660  } while (numberCollectionEnumerator.MoveNext() );
    26612661 
     2662  cand=nlCopy(cand,cf);
    26622663  // part 2: compute gcd(cand,all coeffs)
    26632664  numberCollectionEnumerator.Reset();
     
    26832684}
    26842685
    2685 static void nlClearDenominators(ICoeffsEnumerator& /*numberCollectionEnumerator*/, number& c, const coeffs cf)
     2686static void nlClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf)
    26862687{
    26872688  assume(cf != NULL);
    26882689  assume(getCoeffType(cf) == ID);
    2689   // all coeffs are given by integers!!!
    2690 
    2691   c = n_Init(1, cf);
    2692   assume(FALSE); // TODO: NOT YET IMPLEMENTED!!!
     2690  // all coeffs are given by integers after returning from this routine
     2691
     2692  // part 1, collect product of all denominators /gcds
     2693  number cand,cand1;
     2694  cand=ALLOC_RNUMBER();
     2695  #if defined(LDEBUG)
     2696  cand->debug=123456;
     2697  #endif
     2698  cand->s=3;
     2699
     2700  int s=0;
     2701  mpz_t tmp;
     2702  mpz_init(tmp);
     2703  numberCollectionEnumerator.Reset();
     2704  do
     2705  {
     2706    if (!(SR_HDL(cand1)&SR_INT))
     2707    {
     2708      nlNormalize(numberCollectionEnumerator.Current(),cf);
     2709      cand1= numberCollectionEnumerator.Current();
     2710      if ((!(SR_HDL(cand1)&SR_INT)) // not a short int
     2711      && (cand1->s==1))             // and is rational
     2712      {
     2713        if (s==0) // first denom, we meet
     2714        {
     2715          mpz_init_set(cand->z,cand1->n);
     2716          s=1;
     2717        }
     2718        else // we have already something
     2719        {
     2720          mpz_gcd(tmp,cand->z,cand1->n);
     2721          if (mpz_cmp_si(tmp,1)!=0)
     2722          {
     2723            mpz_div(cand->z,cand->z,tmp);
     2724          }
     2725          mpz_mul(cand->z,cand->z,cand1->n);
     2726        }
     2727      }
     2728    }
     2729  } while (numberCollectionEnumerator.MoveNext() );
     2730
     2731  if (s==0) // nothing to do, all coeffs are already integers
     2732  {
     2733    mpz_clear(tmp);
     2734    nlDelete(&cand,cf);
     2735    c=nlInit(1,cf);
     2736    return;
     2737  }
     2738  cand=nlShort3(cand);
     2739 
     2740  // part2: all coeffs = all coeffs * cand
     2741  c=cand;
     2742  numberCollectionEnumerator.Reset();
     2743  do
     2744  {
     2745    number t=nlMult(numberCollectionEnumerator.Current(),cand,cf);
     2746    nlDelete(&numberCollectionEnumerator.Current(),cf);
     2747    nlNormalize(t,cf);
     2748    numberCollectionEnumerator.Current()=t;
     2749  } while (numberCollectionEnumerator.MoveNext() );
     2750 
    26932751}
    26942752
Note: See TracChangeset for help on using the changeset viewer.