Changeset d4932a in git
- Timestamp:
- Jun 25, 2010, 4:25:41 PM (13 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- cedebce21b0dc12678683874874cce5b35d8c23d
- Parents:
- 9919421a652e331106b0f71cb3996f006942bc13
- Location:
- factory
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/canonicalform.cc
r9919421 rd4932a 1204 1204 CanonicalForm::ilog2 () const 1205 1205 { 1206 if ( is_imm( value ) ) { 1206 if ( is_imm( value ) ) 1207 { 1207 1208 ASSERT( is_imm( value ) == INTMARK, "ilog2() not implemented" ); 1208 1209 int a = imm2int( value ); 1209 1210 ASSERT( a > 0, "arg to ilog2() less or equal zero" ); 1210 int n = -1; 1211 while ( a != 0 ) { 1212 n++; 1213 a /= 2; 1214 } 1215 return n; 1211 return ::ilog2(a); 1216 1212 } 1217 1213 else -
factory/cf_util.cc
r9919421 rd4932a 21 21 // 22 22 //}}} 23 int 24 ipower ( int b, int m ) 23 int ipower ( int b, int m ) 25 24 { 26 25 int prod = 1; … … 28 27 while ( m != 0 ) 29 28 { 30 31 32 33 34 29 if ( m % 2 != 0 ) 30 prod *= b; 31 m /= 2; 32 if ( m != 0 ) 33 b *= b; 35 34 } 36 35 return prod; 37 36 } 38 37 //}}} 38 39 int ilog2 (int a) 40 { 41 int n = -1; 42 while ( a != 0 ) 43 { 44 n++; 45 a /=2; 46 } 47 return n; 48 } -
factory/cf_util.h
r9919421 rd4932a 14 14 15 15 int ipower ( int b, int n ); 16 int ilog2 (int a); 17 16 18 17 19 #endif /* ! INCL_CF_UTIL_H */ -
factory/fac_sqrfree.cc
r9919421 rd4932a 34 34 // join elements with the same degree 35 35 while ( I.hasItem() ) { 36 37 38 39 40 41 42 43 36 f = I.getItem().factor(); 37 exp = I.getItem().exp(); 38 I++; 39 while ( I.hasItem() && I.getItem().exp() == exp ) { 40 f *= I.getItem().factor(); 41 I++; 42 } 43 result.append( CFFactor( f, exp ) ); 44 44 } 45 45 … … 57 57 58 58 if ( ! leadcf.isOne() ) 59 59 t0 /= leadcf; 60 60 61 61 divexp = p; 62 62 while ( t0.degree(x) > 0 ) 63 63 { 64 65 66 67 64 t = gcd( t0, t0.deriv() ); 65 v = t0 / t; 66 k = 0; 67 while ( v.degree(x) > 0 ) 68 68 { 69 70 69 k = k+1; 70 if ( k % p == 0 ) 71 71 { 72 73 74 75 76 77 78 79 80 81 82 83 72 t /= v; 73 k = k+1; 74 } 75 w = gcd( t, v ); 76 h = v / w; 77 v = w; 78 t /= v; 79 if ( h.degree(x) > 0 ) 80 F.append( CFFactor( h/h.lc(), e*k ) ); 81 } 82 t0 = apply( t, divexpfunc ); 83 e = p * e; 84 84 } 85 85 if ( ! leadcf.isOne() ) 86 86 { 87 87 if ( !F.isEmpty() && (F.getFirst().exp() == 1) ) 88 88 { 89 90 91 92 89 leadcf = F.getFirst().factor() * leadcf; 90 F.removeFirst(); 91 } 92 F.insert( CFFactor( leadcf, 1 ) ); 93 93 } 94 94 return F; … … 117 117 while ( ! c.degree() == 0 ) 118 118 { 119 120 121 122 123 124 125 126 119 y = gcd( w, c ); z = w / y; 120 if ( degree( z ) > 0 ) 121 if ( lc( z ).sign() < 0 ) 122 F.append( CFFactor( -z, i ) ); 123 else 124 F.append( CFFactor( z, i ) ); 125 i++; 126 w = y; c = c / y; 127 127 } 128 128 if ( degree( w ) > 0 ) 129 130 131 132 129 if ( lc( w ).sign() < 0 ) 130 F.append( CFFactor( -w, i ) ); 131 else 132 F.append( CFFactor( w, i ) ); 133 133 return F; 134 134 } … … 138 138 { 139 139 if ( a.inCoeffDomain() ) 140 140 return CFFactor( a, 1 ); 141 141 CanonicalForm cont = content( a ); 142 142 CanonicalForm aa = a / cont; … … 148 148 while ( ! c.degree(v) == 0 ) 149 149 { 150 151 152 153 154 155 156 157 150 y = gcd( w, c ); z = w / y; 151 if ( degree( z, v ) > 0 ) 152 if ( lc( z ).sign() < 0 ) 153 F.append( CFFactor( -z, i ) ); 154 else 155 F.append( CFFactor( z, i ) ); 156 i++; 157 w = y; c = c / y; 158 158 } 159 159 if ( degree( w,v ) > 0 ) 160 161 162 163 160 if ( lc( w ).sign() < 0 ) 161 F.append( CFFactor( -w, i ) ); 162 else 163 F.append( CFFactor( w, i ) ); 164 164 if ( ! cont.isOne() ) 165 165 F = Union( F, sqrFreeZ( cont ) ); 166 166 if ( lc( a ).sign() < 0 ) 167 167 { 168 168 if ( F.getFirst().exp() == 1 ) 169 169 { 170 171 172 173 174 170 CanonicalForm f = F.getFirst().factor(); 171 CFFListIterator(F).getItem() = CFFactor( -f, 1 ); 172 } 173 else 174 F.insert( CFFactor( -1, 1 ) ); 175 175 } 176 176 return F;
Note: See TracChangeset
for help on using the changeset viewer.