Changeset 229530 in git


Ignore:
Timestamp:
Sep 29, 2011, 11:37:53 AM (13 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
3dbee6133da064858b69b79a753ad7f1fb9d8964
Parents:
eee11cf7c726be07e471c27ca5d20a730513336d
Message:
fixed memory leaks in factorization and replaced mpz_fdiv_q by mpz_divexact in int_rat.cc


git-svn-id: file:///usr/local/Singular/svn/trunk@14398 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
factory
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • factory/facFactorize.cc

    reee11c r229530  
    375375            result.append (LCF);
    376376          y= Variable (1);
     377          delete [] bufSqrfFactors;
    377378          return result;
    378379        }
     
    387388      result.append (LCF);
    388389    y= Variable (1);
     390    delete [] bufSqrfFactors;
    389391    return result;
    390392  }
     
    508510  else
    509511    y= Variable (1);
     512
     513  delete [] bufSqrfFactors;
    510514
    511515  return result;
     
    872876    normalize (factors);
    873877
     878  delete [] leadingCoeffs2;
     879  delete [] oldAeval;
     880  delete [] Aeval2;
    874881  delete[] liftBounds;
    875882
  • factory/facFqFactorize.cc

    reee11c r229530  
    15491549            result.append (LCF);
    15501550          y= Variable (1);
     1551          delete [] bufSqrfFactors;
    15511552          return result;
    15521553        }
     
    15611562      result.append (LCF);
    15621563    y= Variable (1);
     1564    delete [] bufSqrfFactors;
    15631565    return result;
    15641566  }
     
    16801682  else
    16811683    y= Variable (1);
     1684
     1685  delete [] bufSqrfFactors;
    16821686
    16831687  return result;
  • factory/int_rat.cc

    reee11c r229530  
    210210        MP_INT tmp2;
    211211        mpz_init( &tmp1 );
    212         mpz_fdiv_q( &tmp1, &_den, &g );
     212        mpz_divexact( &tmp1, &_den, &g );
    213213        mpz_init( &tmp2 );
    214         mpz_fdiv_q( &tmp2, &MPQDEN( c ), &g );
     214        mpz_divexact( &tmp2, &MPQDEN( c ), &g );
    215215        mpz_mul( &d, &tmp2, &_den );
    216216        mpz_mul( &tmp2, &tmp2, &_num );
     
    220220        if ( mpz_cmp_si( &g, 1 ) != 0 )
    221221        {
    222             mpz_fdiv_q( &n, &n, &g );
    223             mpz_fdiv_q( &d, &d, &g );
     222            mpz_divexact( &n, &n, &g );
     223            mpz_divexact( &d, &d, &g );
    224224        }
    225225        mpz_clear( &tmp1 );
     
    266266        MP_INT tmp2;
    267267        mpz_init( &tmp1 );
    268         mpz_fdiv_q( &tmp1, &_den, &g );
     268        mpz_divexact( &tmp1, &_den, &g );
    269269        mpz_init( &tmp2 );
    270         mpz_fdiv_q( &tmp2, &MPQDEN( c ), &g );
     270        mpz_divexact( &tmp2, &MPQDEN( c ), &g );
    271271        mpz_mul( &d, &tmp2, &_den );
    272272        mpz_mul( &tmp2, &tmp2, &_num );
     
    276276        if ( mpz_cmp_si( &g, 1 ) != 0 )
    277277        {
    278             mpz_fdiv_q( &n, &n, &g );
    279             mpz_fdiv_q( &d, &d, &g );
     278            mpz_divexact( &n, &n, &g );
     279            mpz_divexact( &d, &d, &g );
    280280        }
    281281        mpz_clear( &tmp1 );
     
    324324        mpz_init( &tmp1 ); mpz_init( &tmp2 );
    325325        if ( ! g1is1 )
    326             mpz_fdiv_q( &tmp1, &_num, &g1 );
     326            mpz_divexact( &tmp1, &_num, &g1 );
    327327        else
    328328            mpz_set( &tmp1, &_num );
    329329        if ( ! g2is1 )
    330             mpz_fdiv_q( &tmp2, &MPQNUM( c ), &g2 );
     330            mpz_divexact( &tmp2, &MPQNUM( c ), &g2 );
    331331        else
    332332            mpz_set( &tmp2, &MPQNUM( c ) );
    333333        mpz_mul( &n, &tmp1, &tmp2 );
    334334        if ( ! g1is1 )
    335             mpz_fdiv_q( &tmp1, &MPQDEN( c ), &g1 );
     335            mpz_divexact( &tmp1, &MPQDEN( c ), &g1 );
    336336        else
    337337            mpz_set( &tmp1, &MPQDEN( c ) );
    338338        if ( ! g2is1 )
    339             mpz_fdiv_q( &tmp2, &_den, &g2 );
     339            mpz_divexact( &tmp2, &_den, &g2 );
    340340        else
    341341            mpz_set( &tmp2, &_den );
     
    384384        mpz_init( &tmp1 ); mpz_init( &tmp2 );
    385385        if ( ! g1is1 )
    386             mpz_fdiv_q( &tmp1, &_num, &g1 );
     386            mpz_divexact( &tmp1, &_num, &g1 );
    387387        else
    388388            mpz_set( &tmp1, &_num );
    389389        if ( ! g2is1 )
    390             mpz_fdiv_q( &tmp2, &MPQDEN( c ), &g2 );
     390            mpz_divexact( &tmp2, &MPQDEN( c ), &g2 );
    391391        else
    392392            mpz_set( &tmp2, &MPQDEN( c ) );
    393393        mpz_mul( &n, &tmp1, &tmp2 );
    394394        if ( ! g1is1 )
    395             mpz_fdiv_q( &tmp1, &MPQNUM( c ), &g1 );
     395            mpz_divexact( &tmp1, &MPQNUM( c ), &g1 );
    396396        else
    397397            mpz_set( &tmp1, &MPQNUM( c ) );
    398398        if ( ! g2is1 )
    399             mpz_fdiv_q( &tmp2, &_den, &g2 );
     399            mpz_divexact( &tmp2, &_den, &g2 );
    400400        else
    401401            mpz_set( &tmp2, &_den );
     
    634634    else
    635635    {
    636         mpz_fdiv_q( &n, &n, &g );
     636        mpz_divexact( &n, &n, &g );
    637637        mpz_mul( &n, &n, &_num );
    638638        mpz_init( &d );
    639         mpz_fdiv_q( &d, &_den, &g );
     639        mpz_divexact( &d, &_den, &g );
    640640    }
    641641    mpz_clear( &g );
     
    711711    if ( mpz_cmp_si( &g, 1 ) != 0 )
    712712    {
    713         mpz_fdiv_q( &d, &d, &g );
    714         mpz_fdiv_q( &n, &n, &g );
     713        mpz_divexact( &d, &d, &g );
     714        mpz_divexact( &n, &n, &g );
    715715    }
    716716    mpz_clear( &g );
     
    810810    if ( mpz_cmp_si( &g, 1 ) != 0 )
    811811    {
    812         mpz_fdiv_q( &_num, &_num, &g );
    813         mpz_fdiv_q( &_den, &_den, &g );
     812        mpz_divexact( &_num, &_num, &g );
     813        mpz_divexact( &_den, &_den, &g );
    814814    }
    815815    // Hier brauchen wir ein mpz_clear, J.M.
Note: See TracChangeset for help on using the changeset viewer.