Changeset d1d27f1 in git for libpolys/coeffs/longrat.cc
- Timestamp:
- Aug 3, 2012, 7:33:11 PM (12 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 6993c8371c2a089de1e05f7e0a7e9ab0f8c76145
- Parents:
- 69c542f9869e7a3e82b1cc481139d89110b7afd3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/longrat.cc
r69c542 rd1d27f1 2660 2660 } while (numberCollectionEnumerator.MoveNext() ); 2661 2661 2662 cand=nlCopy(cand,cf); 2662 2663 // part 2: compute gcd(cand,all coeffs) 2663 2664 numberCollectionEnumerator.Reset(); … … 2683 2684 } 2684 2685 2685 static void nlClearDenominators(ICoeffsEnumerator& /*numberCollectionEnumerator*/, number& c, const coeffs cf)2686 static void nlClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf) 2686 2687 { 2687 2688 assume(cf != NULL); 2688 2689 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 2693 2751 } 2694 2752
Note: See TracChangeset
for help on using the changeset viewer.