Changeset e11ed0 in git
- Timestamp:
- Aug 10, 2012, 2:45:29 PM (11 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- e8eba79d5b1d97d0164270764c45f286deab00ca
- Parents:
- 824c47a7ef5b40564c34a1392fd8a3a44558959b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/longrat.cc
r824c47 re11ed0 865 865 long j=SR_TO_INT(b); 866 866 if ((i==-POW_2_28) && (j== -1L)) 867 { 867 { 868 868 FREE_RNUMBER(u); 869 869 return nlRInit(POW_2_28); … … 1257 1257 1258 1258 // 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 ); 1260 1260 1261 1261 // denominator != 1? … … 2440 2440 { 2441 2441 assume( getCoeffType(r) == ID ); 2442 2442 2443 2443 nlTest(n, r); 2444 2444 nlNormalize(n, r); … … 2454 2454 mpz_init_set_ui(z->n, 1); 2455 2455 z->s = 3; 2456 return z; 2456 return z; 2457 2457 } 2458 2458 … … 2629 2629 s=s1; 2630 2630 } 2631 } while (numberCollectionEnumerator.MoveNext() ); 2632 2631 } while (numberCollectionEnumerator.MoveNext() ); 2632 2633 2633 cand=nlCopy(cand,cf); 2634 2634 // part 2: compute gcd(cand,all coeffs) … … 2641 2641 cand=cand1; 2642 2642 if(nlIsOne(cand,cf)) { c=cand; return; } 2643 } while (numberCollectionEnumerator.MoveNext() ); 2644 2643 } while (numberCollectionEnumerator.MoveNext() ); 2644 2645 2645 // part3: all coeffs = all coeffs / cand 2646 2646 c=cand; … … 2651 2651 nlDelete(&numberCollectionEnumerator.Current(),cf); 2652 2652 numberCollectionEnumerator.Current()=t; 2653 } while (numberCollectionEnumerator.MoveNext() ); 2654 2653 } while (numberCollectionEnumerator.MoveNext() ); 2654 2655 2655 } 2656 2656 … … 2662 2662 2663 2663 // part 1, collect product of all denominators /gcds 2664 number cand; 2664 number cand; 2665 2665 cand=ALLOC_RNUMBER(); 2666 2666 #if defined(LDEBUG) … … 2676 2676 { 2677 2677 number& cand1 = numberCollectionEnumerator.Current(); 2678 nlNormalize(cand1, cf); 2679 2678 2680 2679 if (!(SR_HDL(cand1)&SR_INT)) 2681 2680 { 2681 nlNormalize(cand1, cf); 2682 2682 if ((!(SR_HDL(cand1)&SR_INT)) // not a short int 2683 2683 && (cand1->s==1)) // and is rational … … 2685 2685 if (s==0) // first denom, we meet 2686 2686 { 2687 mpz_init_set(cand->z,cand1->n); 2688 s=1; 2687 mpz_init_set(cand->z,cand1->n); 2688 s=1; 2689 2689 } 2690 2690 else // we have already something … … 2699 2699 } 2700 2700 } 2701 } while (numberCollectionEnumerator.MoveNext() ); 2701 } while (numberCollectionEnumerator.MoveNext() ); 2702 2702 2703 2703 if (s==0) // nothing to do, all coeffs are already integers 2704 2704 { 2705 2705 mpz_clear(tmp); 2706 FREE_RNUMBER(cand); 2707 c=nlInit(1,cf); 2706 FREE_RNUMBER(cand); 2707 c=nlInit(1,cf); 2708 2708 return; 2709 2709 } 2710 2710 cand=nlShort3(cand); 2711 2711 2712 2712 // 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 } 2713 2719 c = cand; 2714 numberCollectionEnumerator.Reset();2715 2720 do 2716 2721 { 2717 2722 number &n = numberCollectionEnumerator.Current(); 2718 2723 n_InpMult(n, cand, cf); 2719 } while (numberCollectionEnumerator.MoveNext() ); 2720 2724 } while (numberCollectionEnumerator.MoveNext() ); 2725 2721 2726 } 2722 2727 … … 2732 2737 r->cfInitMPZ = nlInitMPZ; 2733 2738 r->cfMPZ = nlMPZ; 2734 2739 2735 2740 r->cfMult = nlMult; 2736 2741 r->cfSub = nlSub; … … 2743 2748 r->cfSize = nlSize; 2744 2749 r->cfInt = nlInt; 2745 2750 2746 2751 r->cfChineseRemainder=nlChineseRemainder; 2747 2752 r->cfFarey=nlFarey; … … 2781 2786 r->cfClearContent = nlClearContent; 2782 2787 r->cfClearDenominators = nlClearDenominators; 2783 2788 2784 2789 #ifdef LDEBUG 2785 2790 // debug stuff
Note: See TracChangeset
for help on using the changeset viewer.