Changeset 03ac3b in git


Ignore:
Timestamp:
Oct 4, 2010, 12:59:20 PM (14 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '8c6038b526213d378981739e978a9f7b485dab94')
Children:
3dabc0a263c826086e25e57f280b9aa6a32bdec4
Parents:
2a33e61c9baf5e72b38a197992a67ff69c2caac4
Message:
primefactors: limits

git-svn-id: file:///usr/local/Singular/svn/trunk@13385 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/misc_ip.cc

    r2a33e6 r03ac3b  
    186186
    187187/* n and pBound are assumed to be bigint numbers */
    188 lists primeFactorisation(const number n, const number pBound)
     188lists primeFactorisation(const number n, number pBound)
    189189{
    190190  mpz_t nn; number2mpz(n, nn);
     
    220220    unsigned long p_ui=5; add = 2;
    221221    mpz_sqrt(sr, nn);
    222     if ((mpz_cmp_ui(b, 0) == 0) || (mpz_cmp(pb, sr) > 0)) mpz_set(pb, sr);
    223     unsigned long  limit=mpz_get_ui(pb);
    224     if ((limit==0)||(mpz_cmp_ui(pb,limit)!=0)) limit=1<<31;
     222    unsigned long  limit=nlInt(pBound,NULL);
     223    if ((mpz_cmp_ui(b, 0) == 0) || (mpz_cmp(pb, sr) > 0))
     224    {
     225      mpz_set(pb, sr);
     226      mpz_set(b, sr);
     227      limit=mpz_get_ui(sr);
     228    }
     229    else if (limit==0)
     230    {
     231      limit=1<<31;
     232      mpz_set_ui(pb,limit);
     233      mpz_set_ui(b,limit);
     234    }
    225235    while (p_ui <=limit)
    226236    {
     
    232242        //mpz_sqrt(sr, nn);
    233243        //if ((mpz_cmp_ui(b, 0) == 0) || (mpz_cmp(pb, sr) > 0)) mpz_set(pb, sr);
    234         if (mpz_size1(nn)<=2)
     244        if (mpz_size1(nn)<=1)
    235245        {
    236246          mpz_sqrt(sr, nn);
    237           if ((mpz_cmp_ui(b, 0) == 0) || (mpz_cmp(pb, sr) > 0)) mpz_set(pb, sr);
     247          if (mpz_cmp(pb, sr) > 0) mpz_set(pb, sr);
    238248          unsigned long l=mpz_get_ui(sr);
    239           if (l<limit) limit=l;
     249          if (l<limit) { limit=l; }
    240250          if (mpz_size1(nn)<=1)
    241251          {
     
    248258                setListEntry_ui(primes, index, p_ui);
    249259                multiplicities[index++] = tt;
    250                 if (nn_ui>(limit/6)) limit=nn_ui/6;
     260                if (nn_ui<(limit/6)) { limit=nn_ui/6;}
    251261              }
    252262              p_ui +=add;
Note: See TracChangeset for help on using the changeset viewer.