Changeset a52291 in git for factory/fac_cantzass.cc
- Timestamp:
- Nov 24, 2011, 2:35:53 PM (12 years ago)
- Branches:
- (u'spielwiese', '91fdef05f09f54b8d58d92a472e9c4a43aa4656f')
- Children:
- 8b46459e9dad8bec212484f1bfce347c45e41371
- Parents:
- 1c48503bfae9bb885752ba741bd0a236df633d13
- git-author:
- Martin Lee <martinlee84@web.de>2011-11-24 14:35:53+01:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-11-24 21:10:03+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/fac_cantzass.cc
r1c48503 ra52291 19 19 static CFFList CantorZassenhausFactorFFGF( const CanonicalForm & f, int d, int q, const CFRandom & ); 20 20 21 static CFFList CantorZassenhausFactorExt( const CanonicalForm & g, int s, MP_INT *q, const CFRandom & gen );21 static CFFList CantorZassenhausFactorExt( const CanonicalForm & g, int s, mpz_t q, const CFRandom & gen ); 22 22 23 23 static CFFList distinctDegreeFactorFFGF ( const CanonicalForm & f, int q ); … … 37 37 static CanonicalForm powerMod2( const CanonicalForm & f, int p, int s, const CanonicalForm & d ); 38 38 39 static CanonicalForm powerMod2( const CanonicalForm & f, MP_INT *q, int s, const CanonicalForm & d );39 static CanonicalForm powerMod2( const CanonicalForm & f, mpz_t q, int s, const CanonicalForm & d ); 40 40 41 41 CFFList FpFactorizeUnivariateCZ( const CanonicalForm& f, bool issqrfree, int numext, const Variable alpha, const Variable beta ) … … 46 46 int d, q, n = 0; 47 47 bool galoisfield = getGFDegree() > 1; 48 MP_INTqq;48 mpz_t qq; 49 49 50 50 if ( galoisfield ) … … 57 57 else 58 58 n = getMipo( alpha ).degree() * getMipo( beta ).degree(); 59 mpz_init( &qq );60 mpz_ui_pow_ui ( &qq, q, n );59 mpz_init( qq ); 60 mpz_ui_pow_ui ( qq, q, n ); 61 61 } 62 62 if ( LC( f ).isOne() ) … … 82 82 if ( numext == 1 ) { 83 83 AlgExtRandomF tmpalpha( alpha ); 84 HH = CantorZassenhausFactorExt( j.getItem().factor(), j.getItem().exp(), &qq, tmpalpha );84 HH = CantorZassenhausFactorExt( j.getItem().factor(), j.getItem().exp(), qq, tmpalpha ); 85 85 } 86 86 else { 87 87 AlgExtRandomF tmpalphabeta( alpha, beta ); 88 HH = CantorZassenhausFactorExt( j.getItem().factor(), j.getItem().exp(), &qq, tmpalphabeta );88 HH = CantorZassenhausFactorExt( j.getItem().factor(), j.getItem().exp(), qq, tmpalphabeta ); 89 89 } 90 90 } … … 100 100 } 101 101 if ( numext > 0 ) 102 mpz_clear( &qq );102 mpz_clear( qq ); 103 103 return H; 104 104 } … … 171 171 } 172 172 173 CFFList CantorZassenhausFactorExt( const CanonicalForm & g, int s, MP_INT *q, const CFRandom & gen )173 CFFList CantorZassenhausFactorExt( const CanonicalForm & g, int s, mpz_t q, const CFRandom & gen ) 174 174 { 175 175 CanonicalForm f = g; … … 228 228 int odd; 229 229 230 MP_INTm;231 232 mpz_init( &m );233 mpz_ui_pow_ui ( &m, p, s );234 while ( mpz_cmp_si( &m, 0 ) != 0 )230 mpz_t m; 231 232 mpz_init( m ); 233 mpz_ui_pow_ui ( m, p, s ); 234 while ( mpz_cmp_si( m, 0 ) != 0 ) 235 235 { 236 odd = mpz_fdiv_q_ui( &m, &m, 2 );236 odd = mpz_fdiv_q_ui( m, m, 2 ); 237 237 if ( odd != 0 ) 238 238 prod = (prod * b) % d; 239 if ( mpz_cmp_si( &m, 0 ) != 0 )239 if ( mpz_cmp_si( m, 0 ) != 0 ) 240 240 b = (b*b) % d; 241 241 } 242 mpz_clear( &m );242 mpz_clear( m ); 243 243 return prod; 244 244 } … … 250 250 int odd; 251 251 252 MP_INTm;253 254 mpz_init( &m );255 mpz_ui_pow_ui ( &m, p, s );256 mpz_sub_ui( &m, &m, 1 );257 mpz_fdiv_q_ui( &m, &m, 2 );258 while ( mpz_cmp_si( &m, 0 ) != 0 )252 mpz_t m; 253 254 mpz_init( m ); 255 mpz_ui_pow_ui ( m, p, s ); 256 mpz_sub_ui( m, m, 1 ); 257 mpz_fdiv_q_ui( m, m, 2 ); 258 while ( mpz_cmp_si( m, 0 ) != 0 ) 259 259 { 260 odd = mpz_fdiv_q_ui( &m, &m, 2 );260 odd = mpz_fdiv_q_ui( m, m, 2 ); 261 261 if ( odd != 0 ) 262 262 prod = (prod * b) % d; 263 if ( mpz_cmp_si( &m, 0 ) != 0 )263 if ( mpz_cmp_si( m, 0 ) != 0 ) 264 264 b = (b*b) % d; 265 265 } 266 mpz_clear( &m );267 return prod; 268 } 269 270 CanonicalForm powerMod2( const CanonicalForm & f, MP_INT *q, int s, const CanonicalForm & d )266 mpz_clear( m ); 267 return prod; 268 } 269 270 CanonicalForm powerMod2( const CanonicalForm & f, mpz_t q, int s, const CanonicalForm & d ) 271 271 { 272 272 CanonicalForm prod = 1; … … 274 274 int odd; 275 275 276 MP_INTm;277 278 mpz_init( &m );279 mpz_pow_ui( &m, q, s );280 mpz_sub_ui( &m, &m, 1 );281 mpz_fdiv_q_ui( &m, &m, 2 );282 while ( mpz_cmp_si( &m, 0 ) != 0 )276 mpz_t m; 277 278 mpz_init( m ); 279 mpz_pow_ui( m, q, s ); 280 mpz_sub_ui( m, m, 1 ); 281 mpz_fdiv_q_ui( m, m, 2 ); 282 while ( mpz_cmp_si( m, 0 ) != 0 ) 283 283 { 284 odd = mpz_fdiv_q_ui( &m, &m, 2 );284 odd = mpz_fdiv_q_ui( m, m, 2 ); 285 285 if ( odd != 0 ) 286 286 prod = (prod * b) % d; 287 if ( mpz_cmp_si( &m, 0 ) != 0 )287 if ( mpz_cmp_si( m, 0 ) != 0 ) 288 288 b = (b*b) % d; 289 289 } 290 mpz_clear( &m );291 return prod; 292 } 290 mpz_clear( m ); 291 return prod; 292 }
Note: See TracChangeset
for help on using the changeset viewer.