Changeset 34e5d2d in git for factory/int_rat.cc
- Timestamp:
- Nov 24, 2017, 3:03:15 PM (6 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/int_rat.cc
r4b73d0 r34e5d2d 32 32 33 33 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 46 34 InternalRational::InternalRational( const int n, const int d ) 47 35 { … … 49 37 if ( n == 0 ) 50 38 { 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 ); 53 41 } 54 42 else … … 68 56 } 69 57 70 InternalRational::InternalRational( const long i )71 {72 mpz_init_set_si( _num, i );73 mpz_init_set_si( _den, 1 );74 }75 76 58 InternalRational::InternalRational( const long n, const long d ) 77 59 { … … 79 61 if ( n == 0 ) 80 62 { 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 ); 83 65 } 84 66 else … … 110 92 // mpz_init_set_si( _den, 1 ); 111 93 //} 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 }130 94 131 95 InternalCF* InternalRational::deepCopyObject() const … … 151 115 } 152 116 #endif /* NOSTREAMIO */ 153 154 bool InternalRational::is_imm() const155 {156 return mpz_cmp_si( _den, 1 ) == 0 && mpz_is_imm( _num );157 }158 117 159 118 InternalCF* InternalRational::genZero() … … 568 527 return this; 569 528 else 570 529 { 571 530 mpz_init( n ); 572 531 if ( cc < 0 ) 573 532 { 574 533 mpz_mul_ui( n, _den, -cc ); … … 580 539 mpz_add( n, _num, n ); 581 540 } 582 541 } 583 542 } 584 543 else … … 903 862 } 904 863 905 /** 906 * @sa CanonicalForm::sign() 907 **/ 908 int 909 InternalRational::sign () const 910 { 911 return mpz_sgn( _num ); 912 } 864 bool 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.