Changeset 34e5d2d in git for factory/int_rat.cc


Ignore:
Timestamp:
Nov 24, 2017, 3:03:15 PM (6 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
c11414077180169b27d270988b9dff8a64addaba
Parents:
4b73d0a16e225730f3a8270b63d10086d4d8560a
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2017-11-24 15:03:15+01:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2017-11-24 15:08:24+01:00
Message:
opt: inline some small InternalInt/Rat/Poly-functions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/int_rat.cc

    r4b73d0 r34e5d2d  
    3232
    3333
    34 InternalRational::InternalRational()
    35 {
    36     mpz_init( _num );
    37     mpz_init_set_si( _den, 1 );
    38 }
    39 
    40 InternalRational::InternalRational( const int i )
    41 {
    42     mpz_init_set_si( _num, i );
    43     mpz_init_set_si( _den, 1 );
    44 }
    45 
    4634InternalRational::InternalRational( const int n, const int d )
    4735{
     
    4937    if ( n == 0 )
    5038    {
    51         mpz_init_set_si( _num, 0 );
    52         mpz_init_set_si( _den, 1 );
     39        mpz_init_set_ui( _num, 0 );
     40        mpz_init_set_ui( _den, 1 );
    5341    }
    5442    else
     
    6856}
    6957
    70 InternalRational::InternalRational( const long i )
    71 {
    72     mpz_init_set_si( _num, i );
    73     mpz_init_set_si( _den, 1 );
    74 }
    75 
    7658InternalRational::InternalRational( const long n, const long d )
    7759{
     
    7961    if ( n == 0 )
    8062    {
    81         mpz_init_set_si( _num, 0 );
    82         mpz_init_set_si( _den, 1 );
     63        mpz_init_set_ui( _num, 0 );
     64        mpz_init_set_ui( _den, 1 );
    8365    }
    8466    else
     
    11092//    mpz_init_set_si( _den, 1 );
    11193//}
    112 
    113 InternalRational::InternalRational( const mpz_ptr n )
    114 {
    115     _num[0]=*n;
    116     mpz_init_set_si( _den, 1 );
    117 }
    118 
    119 InternalRational::InternalRational( const mpz_ptr n, const mpz_ptr d )
    120 {
    121   _num[0]=*n;
    122   _den[0]=*d;
    123 }
    124 
    125 InternalRational::~InternalRational()
    126 {
    127     mpz_clear( _num );
    128     mpz_clear( _den );
    129 }
    13094
    13195InternalCF* InternalRational::deepCopyObject() const
     
    151115}
    152116#endif /* NOSTREAMIO */
    153 
    154 bool InternalRational::is_imm() const
    155 {
    156     return mpz_cmp_si( _den, 1 ) == 0 && mpz_is_imm( _num );
    157 }
    158117
    159118InternalCF* InternalRational::genZero()
     
    568527            return this;
    569528        else
    570         {
     529      {
    571530          mpz_init( n );
    572           if ( cc < 0 )
     531        if ( cc < 0 )
    573532          {
    574533            mpz_mul_ui( n, _den, -cc );
     
    580539            mpz_add( n, _num, n );
    581540          }
    582         }
     541      }
    583542    }
    584543    else
     
    903862}
    904863
    905 /**
    906  * @sa CanonicalForm::sign()
    907 **/
    908 int
    909 InternalRational::sign () const
    910 {
    911     return mpz_sgn( _num );
    912 }
     864bool InternalRational::is_imm() const
     865{ return mpz_cmp_si( _den, 1 ) == 0 && mpz_is_imm( _num ); }
     866
Note: See TracChangeset for help on using the changeset viewer.