Changeset 36fd8e in git for factory


Ignore:
Timestamp:
Nov 27, 2017, 2:29:04 PM (6 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b9f50b373314e74e83c7c060a651dd2913e1f033')
Children:
55547cd0fba1913878deb04d393e354ac9d7fc2f
Parents:
ecce2d81ff6101080904784705fc360910896b1b
Message:
opt: mpz_*set_ui/_si and inline stuff
Location:
factory
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • factory/cfNewtonPolygon.cc

    recce2d8 r36fd8e  
    604604    else if (sizePoints == 1)
    605605    {
    606       mpz_set_ui (M[0], 1);
    607       mpz_set_ui (M[3], 1);
     606      mpz_set_si (M[0], 1);
     607      mpz_set_si (M[3], 1);
    608608    }
    609609    return;
    610610  }
    611   mpz_set_ui (M[0], 1);
    612   mpz_set_ui (M[3], 1);
     611  mpz_set_si (M[0], 1);
     612  mpz_set_si (M[3], 1);
    613613
    614614  mpz_t * Mu= new mpz_t[4];
    615   mpz_init_set_ui (Mu[1], 1);
    616   mpz_init_set_ui (Mu[2], 1);
     615  mpz_init_set_si (Mu[1], 1);
     616  mpz_init_set_si (Mu[2], 1);
    617617  mpz_init (Mu[0]);
    618618  mpz_init (Mu[3]);
    619619
    620620  mpz_t * Lambda= new mpz_t[4];
    621   mpz_init_set_ui (Lambda[0], 1);
     621  mpz_init_set_si (Lambda[0], 1);
    622622  mpz_init_set_si (Lambda[1], -1);
    623623  mpz_init_set_si (Lambda[3], 1);
     
    625625
    626626  mpz_t * InverseLambda= new mpz_t[4];
    627   mpz_init_set_ui (InverseLambda[0], 1);
    628   mpz_init_set_ui (InverseLambda[1], 1);
    629   mpz_init_set_ui (InverseLambda[3], 1);
     627  mpz_init_set_si (InverseLambda[0], 1);
     628  mpz_init_set_si (InverseLambda[1], 1);
     629  mpz_init_set_si (InverseLambda[3], 1);
    630630  mpz_init (InverseLambda[2]);
    631631
  • factory/int_rat.cc

    recce2d8 r36fd8e  
    3232
    3333
     34InternalRational::InternalRational()
     35{
     36    mpz_init( _num );
     37    mpz_init_set_si( _den, 1 );
     38}
     39
     40InternalRational::InternalRational( const int i )
     41{
     42    mpz_init_set_si( _num, i );
     43    mpz_init_set_si( _den, 1 );
     44}
     45
    3446InternalRational::InternalRational( const int n, const int d )
    3547{
     
    3749    if ( n == 0 )
    3850    {
    39         mpz_init_set_ui( _num, 0 );
    40         mpz_init_set_ui( _den, 1 );
     51        mpz_init_set_si( _num, 0 );
     52        mpz_init_set_si( _den, 1 );
    4153    }
    4254    else
     
    5668}
    5769
     70InternalRational::InternalRational( const long i )
     71{
     72    mpz_init_set_si( _num, i );
     73    mpz_init_set_si( _den, 1 );
     74}
     75
    5876InternalRational::InternalRational( const long n, const long d )
    5977{
     
    6179    if ( n == 0 )
    6280    {
    63         mpz_init_set_ui( _num, 0 );
    64         mpz_init_set_ui( _den, 1 );
     81        mpz_init_set_si( _num, 0 );
     82        mpz_init_set_si( _den, 1 );
    6583    }
    6684    else
     
    92110//    mpz_init_set_si( _den, 1 );
    93111//}
     112
     113InternalRational::InternalRational( const mpz_ptr n )
     114{
     115    _num[0]=*n;
     116    mpz_init_set_si( _den, 1 );
     117}
     118
     119InternalRational::InternalRational( const mpz_ptr n, const mpz_ptr d )
     120{
     121  _num[0]=*n;
     122  _den[0]=*d;
     123}
     124
     125InternalRational::~InternalRational()
     126{
     127    mpz_clear( _num );
     128    mpz_clear( _den );
     129}
    94130
    95131InternalCF* InternalRational::deepCopyObject() const
     
    115151}
    116152#endif /* NOSTREAMIO */
     153
     154bool InternalRational::is_imm() const
     155{
     156    return mpz_cmp_si( _den, 1 ) == 0 && mpz_is_imm( _num );
     157}
    117158
    118159InternalCF* InternalRational::genZero()
     
    527568            return this;
    528569        else
    529       {
     570        {
    530571          mpz_init( n );
    531         if ( cc < 0 )
     572          if ( cc < 0 )
    532573          {
    533574            mpz_mul_ui( n, _den, -cc );
     
    539580            mpz_add( n, _num, n );
    540581          }
    541       }
     582        }
    542583    }
    543584    else
     
    862903}
    863904
    864 bool InternalRational::is_imm() const
    865 { return mpz_cmp_si( _den, 1 ) == 0 && mpz_is_imm( _num ); }
    866 
     905/**
     906 * @sa CanonicalForm::sign()
     907**/
     908int
     909InternalRational::sign () const
     910{
     911    return mpz_sgn( _num );
     912}
  • factory/int_rat.h

    recce2d8 r36fd8e  
    4646    static void normalize( const mpz_ptr, const mpz_ptr, mpz_ptr, mpz_ptr );
    4747public:
    48     InternalRational()
    49     {
    50       mpz_init( _num );
    51       mpz_init_set_ui( _den, 1 );
    52     }
     48    InternalRational();
    5349    InternalRational( const InternalCF& )
    5450    {
    55       ASSERT( 0, "ups there is something wrong in your code" );
     51        ASSERT( 0, "ups there is something wrong in your code" );
    5652    }
    57     InternalRational( const int i )
    58     {
    59       mpz_init_set_si( _num, i );
    60       mpz_init_set_ui( _den, 1 );
    61     }
     53    InternalRational( const int i );
    6254    InternalRational( const int n, const int d );
    63     InternalRational( const long i )
    64     {
    65       mpz_init_set_si( _num, i );
    66       mpz_init_set_ui( _den, 1 );
    67     }
     55    InternalRational( const long i );
    6856    InternalRational( const long n, const long d );
    6957    InternalRational( const char * str );
    70     InternalRational( const mpz_ptr n)
    71     {
    72       _num[0]=*n;
    73       mpz_init_set_ui( _den, 1 );
    74     }
    75     InternalRational( const mpz_ptr n, const mpz_ptr d)
    76     {
    77       _num[0]=*n;
    78       _den[0]=*d;
    79     }
    80     ~InternalRational()
    81     {
    82       mpz_clear( _num );
    83       mpz_clear( _den );
    84     }
     58    InternalRational( const mpz_ptr );
     59    InternalRational( const mpz_ptr , const mpz_ptr );
     60    ~InternalRational();
    8561    InternalCF* deepCopyObject() const;
    8662    const char * classname() const { return "InternalRational"; }
     
    131107    long intval() const;
    132108
    133     int sign() const { return mpz_sgn( _num ); }
     109    int sign() const;
    134110
    135111    InternalCF * normalize_myself();
Note: See TracChangeset for help on using the changeset viewer.