Changeset 558f3cc in git
- Timestamp:
- Jan 4, 2013, 6:39:47 PM (10 years ago)
- Branches:
- (u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
- Children:
- 8f296a6216092a84f1ebb509dbcda5fe428004f7
- Parents:
- d9947d272d574a169450505d43dc8ad3a5b4d0f0
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2013-01-04 18:39:47+01:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2013-01-15 20:41:56+01:00
- Location:
- libpolys
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/longrat.cc
rd9947d r558f3cc 2664 2664 } 2665 2665 2666 void nlClearContent(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf)2666 static void nlClearContent(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf) 2667 2667 { 2668 2668 assume(cf != NULL); … … 2757 2757 } 2758 2758 2759 void nlClearContentNoPositiveLead(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf) 2760 { 2761 assume(cf != NULL); 2762 assume(getCoeffType(cf) == ID); 2763 2764 numberCollectionEnumerator.Reset(); 2765 2766 if( !numberCollectionEnumerator.MoveNext() ) // empty zero polynomial? 2767 { 2768 c = n_Init(1, cf); 2769 return; 2770 } 2771 2772 // all coeffs are given by integers!!! 2773 2774 // part 1, find a small candidate for gcd 2775 number cand1,cand; 2776 int s1,s; 2777 s=2147483647; // max. int 2778 2779 const BOOLEAN lc_is_pos = TRUE; // nlGreaterZero(numberCollectionEnumerator.Current(),cf); 2780 2781 int normalcount = 0; 2782 do 2783 { 2784 number& n = numberCollectionEnumerator.Current(); 2785 nlNormalize(n, cf); ++normalcount; 2786 cand1 = n; 2787 2788 if (SR_HDL(cand1)&SR_INT) { cand=cand1; break; } 2789 assume(cand1->s==3); // all coeffs should be integers // ==0?!! after printing 2790 s1=mpz_size1(cand1->z); 2791 if (s>s1) 2792 { 2793 cand=cand1; 2794 s=s1; 2795 } 2796 } while (numberCollectionEnumerator.MoveNext() ); 2797 2798 // assume( nlGreaterZero(cand,cf) ); // cand may be a negative integer! 2799 2800 cand=nlCopy(cand,cf); 2801 // part 2: compute gcd(cand,all coeffs) 2802 2803 numberCollectionEnumerator.Reset(); 2804 2805 while (numberCollectionEnumerator.MoveNext() ) 2806 { 2807 number& n = numberCollectionEnumerator.Current(); 2808 2809 if( (--normalcount) <= 0) 2810 nlNormalize(n, cf); 2811 2812 nlInpGcd(cand, n, cf); 2813 2814 assume( nlGreaterZero(cand,cf) ); 2815 2816 if(nlIsOne(cand,cf)) 2817 { 2818 c = cand; 2819 2820 if(!lc_is_pos) 2821 { 2822 // make the leading coeff positive 2823 c = nlNeg(c, cf); 2824 numberCollectionEnumerator.Reset(); 2825 2826 while (numberCollectionEnumerator.MoveNext() ) 2827 { 2828 number& nn = numberCollectionEnumerator.Current(); 2829 nn = nlNeg(nn, cf); 2830 } 2831 } 2832 return; 2833 } 2834 } 2835 2836 // part3: all coeffs = all coeffs / cand 2837 if (!lc_is_pos) 2838 cand = nlNeg(cand,cf); 2839 2840 c = cand; 2841 numberCollectionEnumerator.Reset(); 2842 2843 while (numberCollectionEnumerator.MoveNext() ) 2844 { 2845 number& n = numberCollectionEnumerator.Current(); 2846 number t=nlIntDiv(n, cand, cf); // simple integer exact division, no ratios to remain 2847 nlDelete(&n, cf); 2848 n = t; 2849 } 2850 } 2851 2852 void nlClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf) 2759 static void nlClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf) 2853 2760 { 2854 2761 assume(cf != NULL); … … 2937 2844 c = cand; 2938 2845 2939 while (numberCollectionEnumerator.MoveNext() )2940 {2941 number &n = numberCollectionEnumerator.Current();2942 n_InpMult(n, cand, cf);2943 }2944 2945 }2946 2947 2948 void nlClearDenominatorsNoPositiveLead(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf)2949 {2950 assume(cf != NULL);2951 assume(getCoeffType(cf) == ID);2952 2953 numberCollectionEnumerator.Reset();2954 2955 if( !numberCollectionEnumerator.MoveNext() ) // empty zero polynomial?2956 {2957 c = n_Init(1, cf);2958 return;2959 }2960 2961 // all coeffs are given by integers after returning from this routine2962 2963 // part 1, collect product of all denominators /gcds2964 number cand;2965 cand=ALLOC_RNUMBER();2966 #if defined(LDEBUG)2967 cand->debug=123456;2968 #endif2969 cand->s=3;2970 2971 int s=0;2972 2973 const BOOLEAN lc_is_pos = TRUE; // nlGreaterZero(numberCollectionEnumerator.Current(),cf);2974 2975 do2976 {2977 number& cand1 = numberCollectionEnumerator.Current();2978 2979 if (!(SR_HDL(cand1)&SR_INT))2980 {2981 nlNormalize(cand1, cf);2982 if ((!(SR_HDL(cand1)&SR_INT)) // not a short int2983 && (cand1->s==1)) // and is a normalised rational2984 {2985 if (s==0) // first denom, we meet2986 {2987 mpz_init_set(cand->z, cand1->n); // cand->z = cand1->n2988 s=1;2989 }2990 else // we have already something2991 {2992 mpz_lcm(cand->z, cand->z, cand1->n);2993 }2994 }2995 }2996 }2997 while (numberCollectionEnumerator.MoveNext() );2998 2999 3000 if (s==0) // nothing to do, all coeffs are already integers3001 {3002 // mpz_clear(tmp);3003 FREE_RNUMBER(cand);3004 if (lc_is_pos)3005 c=nlInit(1,cf);3006 else3007 {3008 // make the leading coeff positive3009 c=nlInit(-1,cf);3010 3011 // TODO: incorporate the following into the loop below?3012 numberCollectionEnumerator.Reset();3013 while (numberCollectionEnumerator.MoveNext() )3014 {3015 number& n = numberCollectionEnumerator.Current();3016 n = nlNeg(n, cf);3017 }3018 }3019 return;3020 }3021 3022 cand = nlShort3(cand);3023 3024 // part2: all coeffs = all coeffs * cand3025 // make the lead coeff positive3026 numberCollectionEnumerator.Reset();3027 3028 if (!lc_is_pos)3029 cand = nlNeg(cand, cf);3030 3031 c = cand;3032 3033 2846 while (numberCollectionEnumerator.MoveNext() ) 3034 2847 { -
libpolys/polys/ext_fields/algext.cc
rd9947d r558f3cc 1114 1114 number cc; 1115 1115 1116 extern void nlClearContentNoPositiveLead(ICoeffsEnumerator&, number&, const coeffs); 1117 1118 nlClearContentNoPositiveLead(itr, cc, Q); // TODO: get rid of (-LC) normalization!? 1116 n_ClearContent(itr, cc, Q); // TODO: get rid of (-LC) normalization!? 1119 1117 1120 1118 // over alg. ext. of Q // takes over the input number … … 1190 1188 number n; 1191 1189 CRecursivePolyCoeffsEnumerator<NAConverter> itr(numberCollectionEnumerator); // recursively treat the numbers as polys! 1192 1193 extern void nlClearDenominatorsNoPositiveLead(ICoeffsEnumerator&, number&, const coeffs); 1194 1195 nlClearDenominatorsNoPositiveLead(itr, n, Q); // this should probably be fine... 1190 n_ClearDenominators(itr, n, Q); // this should probably be fine... 1196 1191 c = (number)p_NSet(n, cf->extRing); // over alg. ext. of Q // takes over the input number 1197 1192 } -
libpolys/polys/ext_fields/transext.cc
rd9947d r558f3cc 101 101 102 102 103 extern void nlClearContent(ICoeffsEnumerator&, number&, const coeffs);104 extern void nlClearContentNoPositiveLead(ICoeffsEnumerator&, number&, const coeffs);105 106 //extern void nlClearDenominators(ICoeffsEnumerator&, number&, const coeffs);107 //extern void nlClearDenominatorsNoPositiveLead(ICoeffsEnumerator&, number&, const coeffs);108 109 110 103 omBin fractionObjectBin = omGetSpecBin(sizeof(fractionObject)); 111 104 … … 315 308 316 309 n_ClearDenominators(itr, g, ntRing->cf); 317 // nlClearDenominators(itr, g, ntRing->cf);318 310 319 311 if( !n_GreaterZero(g, ntRing->cf) ) … … 402 394 403 395 n_ClearDenominators(itr, g, ntRing->cf); // may return -1 :((( 404 // nlClearDenominators(itr, g, ntRing->cf);405 406 396 407 397 if( !n_GreaterZero(g, ntRing->cf) ) … … 556 546 557 547 n_ClearDenominators(itr, g, ntRing->cf); 558 // nlClearDenominators(itr, g, ntRing->cf);559 548 560 549 if( !n_GreaterZero(g, ntRing->cf) ) … … 1825 1814 number cc; 1826 1815 1827 // nlClearContentNoPositiveLead(itr, cc, Q); // TODO: get rid of (-LC) normalization!? 1828 nlClearContent(itr, cc, Q); 1816 n_ClearContent(itr, cc, Q); 1829 1817 number g = ntInit(p_NSet(cc, R), cf); 1830 1818
Note: See TracChangeset
for help on using the changeset viewer.