Changeset a52291 in git for factory/fac_cantzass.cc


Ignore:
Timestamp:
Nov 24, 2011, 2:35:53 PM (12 years ago)
Author:
Martin Lee <martinlee84@…>
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
Message:
replacing MP_INT by mpz_t

Conflicts:

	factory/cf_factory.h
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/fac_cantzass.cc

    r1c48503 ra52291  
    1919static CFFList CantorZassenhausFactorFFGF( const CanonicalForm & f, int d, int q, const CFRandom & );
    2020
    21 static CFFList CantorZassenhausFactorExt( const CanonicalForm & g, int s, MP_INT * q, const CFRandom & gen );
     21static CFFList CantorZassenhausFactorExt( const CanonicalForm & g, int s, mpz_t q, const CFRandom & gen );
    2222
    2323static CFFList distinctDegreeFactorFFGF ( const CanonicalForm & f, int q );
     
    3737static CanonicalForm powerMod2( const CanonicalForm & f, int p, int s, const CanonicalForm & d );
    3838
    39 static CanonicalForm powerMod2( const CanonicalForm & f, MP_INT * q, int s, const CanonicalForm & d );
     39static CanonicalForm powerMod2( const CanonicalForm & f, mpz_t q, int s, const CanonicalForm & d );
    4040
    4141CFFList FpFactorizeUnivariateCZ( const CanonicalForm& f, bool issqrfree, int numext, const Variable alpha, const Variable beta )
     
    4646    int d, q, n = 0;
    4747    bool galoisfield = getGFDegree() > 1;
    48     MP_INT qq;
     48    mpz_t qq;
    4949
    5050    if ( galoisfield )
     
    5757        else
    5858            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 );
    6161    }
    6262    if ( LC( f ).isOne() )
     
    8282             if ( numext == 1 ) {
    8383                   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 );
    8585             }
    8686             else {
    8787                   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 );
    8989             }
    9090            }
     
    100100    }
    101101    if ( numext > 0 )
    102         mpz_clear( &qq );
     102        mpz_clear( qq );
    103103    return H;
    104104}
     
    171171}
    172172
    173 CFFList CantorZassenhausFactorExt( const CanonicalForm & g, int s, MP_INT * q, const CFRandom & gen )
     173CFFList CantorZassenhausFactorExt( const CanonicalForm & g, int s, mpz_t q, const CFRandom & gen )
    174174{
    175175    CanonicalForm f = g;
     
    228228    int odd;
    229229
    230     MP_INT m;
    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 )
    235235    {
    236         odd = mpz_fdiv_q_ui( &m, &m, 2 );
     236        odd = mpz_fdiv_q_ui( m, m, 2 );
    237237        if ( odd != 0 )
    238238            prod = (prod * b) % d;
    239         if ( mpz_cmp_si( &m, 0 ) != 0 )
     239        if ( mpz_cmp_si( m, 0 ) != 0 )
    240240            b = (b*b) % d;
    241241    }
    242     mpz_clear( &m );
     242    mpz_clear( m );
    243243    return prod;
    244244}
     
    250250    int odd;
    251251
    252     MP_INT 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 )
     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 )
    259259    {
    260         odd = mpz_fdiv_q_ui( &m, &m, 2 );
     260        odd = mpz_fdiv_q_ui( m, m, 2 );
    261261        if ( odd != 0 )
    262262            prod = (prod * b) % d;
    263         if ( mpz_cmp_si( &m, 0 ) != 0 )
     263        if ( mpz_cmp_si( m, 0 ) != 0 )
    264264            b = (b*b) % d;
    265265    }
    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
     270CanonicalForm powerMod2( const CanonicalForm & f, mpz_t q, int s, const CanonicalForm & d )
    271271{
    272272    CanonicalForm prod = 1;
     
    274274    int odd;
    275275
    276     MP_INT 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 )
     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 )
    283283    {
    284         odd = mpz_fdiv_q_ui( &m, &m, 2 );
     284        odd = mpz_fdiv_q_ui( m, m, 2 );
    285285        if ( odd != 0 )
    286286            prod = (prod * b) % d;
    287         if ( mpz_cmp_si( &m, 0 ) != 0 )
     287        if ( mpz_cmp_si( m, 0 ) != 0 )
    288288            b = (b*b) % d;
    289289    }
    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.