My Project  debian-1:4.1.1-p2+ds-4
int_rat.h
Go to the documentation of this file.
1 /* emacs edit mode for this file is -*- C++ -*- */
2 
3 #ifndef INCL_INT_RAT_H
4 #define INCL_INT_RAT_H
5 
6 /**
7  * @file int_rat.h
8  *
9  * Factory's internal rationals
10 **/
11 // #include "config.h"
12 
13 #ifndef NOSTREAMIO
14 #ifdef HAVE_IOSTREAM
15 #include <iostream>
16 #define OSTREAM std::ostream
17 #elif defined(HAVE_IOSTREAM_H)
18 #include <iostream.h>
19 #define OSTREAM ostream
20 #endif
21 #endif /* NOSTREAMIO */
22 
23 #include "cf_assert.h"
24 
25 #include "canonicalform.h"
26 #include "int_cf.h"
27 #include "imm.h"
28 
29 /**
30  * factory's class for rationals
31  *
32  * a rational is represented as two mpz_t's _num, _den
33  *
34  * Note: If you want to compute over Q make sure that SW_RATIONAL is set to 1!
35  *
36  * @sa InternalInteger
37 **/
39 {
40 private:
41  mpz_t _num;
42  mpz_t _den;
43  static int initialized;
44  static mpz_ptr MPQNUM( const InternalCF * const c );
45  static mpz_ptr MPQDEN( const InternalCF * const c );
46  static void normalize( const mpz_ptr, const mpz_ptr, mpz_ptr, mpz_ptr );
47 public:
50  {
51  ASSERT( 0, "ups there is something wrong in your code" );
52  }
53  InternalRational( const int i );
54  InternalRational( const int n, const int d );
55  InternalRational( const long i );
56  InternalRational( const long n, const long d );
57  InternalRational( const char * str );
58  InternalRational( const mpz_ptr );
59  InternalRational( const mpz_ptr , const mpz_ptr );
61  InternalCF* deepCopyObject() const;
62  const char * classname() const { return "InternalRational"; }
63 #ifndef NOSTREAMIO
64  void print( OSTREAM&, char* );
65 #endif /* NOSTREAMIO */
67  InternalCF* genOne();
68 
69  bool is_imm() const;
70  int levelcoeff() const { return RationalDomain; }
71 
72  InternalCF* num();
73  InternalCF* den();
74 
75  InternalCF* neg();
76 
77  int comparesame( InternalCF* );
78 
88 
89  int comparecoeff( InternalCF* );
90 
92  InternalCF* subcoeff( InternalCF*, bool );
96  InternalCF* divcoeff( InternalCF*, bool );
97  InternalCF* modcoeff( InternalCF*, bool );
98  void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
99  bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
100 
101  InternalCF * bgcdsame ( const InternalCF * const ) const;
102  InternalCF * bgcdcoeff ( const InternalCF * const );
103 
106 
107  long intval() const;
108 
109  int sign() const;
110 
112 
113  friend class InternalInteger;
114  friend void gmp_numerator ( const CanonicalForm & f, mpz_ptr result );
115  friend void gmp_denominator ( const CanonicalForm & f, mpz_ptr result );
116  friend CanonicalForm make_cf ( const mpz_ptr n, const mpz_ptr d );
117 };
118 
119 inline mpz_ptr InternalRational::MPQNUM( const InternalCF * const c )
120 {
121  return (((InternalRational*)c)->_num);
122 }
123 
124 inline mpz_ptr InternalRational::MPQDEN( const InternalCF * const c )
125 {
126  return (((InternalRational*)c)->_den);
127 }
128 
129 #endif /* ! INCL_INT_RAT_H */
InternalRational::make_cf
friend CanonicalForm make_cf(const mpz_ptr n, const mpz_ptr d)
InternalRational::is_imm
bool is_imm() const
Definition: int_rat.cc:154
InternalRational::subsame
InternalCF * subsame(InternalCF *)
Definition: int_rat.cc:292
f
FILE * f
Definition: checklibs.c:9
InternalRational::InternalRational
InternalRational()
Definition: int_rat.cc:34
InternalRational::modulocoeff
InternalCF * modulocoeff(InternalCF *, bool)
Definition: int_rat.cc:792
canonicalform.h
InternalRational::num
InternalCF * num()
Definition: int_rat.cc:178
result
return result
Definition: facAbsBiFact.cc:76
RationalDomain
#define RationalDomain
Definition: cf_defs.h:24
InternalRational::InternalRational
InternalRational(const InternalCF &)
Definition: int_rat.h:49
InternalRational::divremsamet
bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_rat.cc:496
InternalRational::dividesame
InternalCF * dividesame(InternalCF *)
Definition: int_rat.cc:408
InternalCF
virtual class for internal CanonicalForm's
Definition: int_cf.h:41
InternalRational::intval
long intval() const
Definition: int_rat.cc:897
InternalRational::mulcoeff
InternalCF * mulcoeff(InternalCF *)
Definition: int_rat.cc:654
InternalRational::comparecoeff
int comparecoeff(InternalCF *)
comparecoeff() compares the CO=a/b and the integer c using the equivalence a/b < c iff a < c*b.
Definition: int_rat.cc:536
InternalRational::subcoeff
InternalCF * subcoeff(InternalCF *, bool)
Definition: int_rat.cc:597
InternalRational::print
void print(OSTREAM &, char *)
Definition: int_rat.cc:141
InternalRational::divcoeff
InternalCF * divcoeff(InternalCF *, bool)
Definition: int_rat.cc:787
InternalRational::gmp_numerator
friend void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:20
InternalRational::MPQNUM
static mpz_ptr MPQNUM(const InternalCF *const c)
Definition: int_rat.h:119
CanonicalForm
factory's main class
Definition: canonicalform.h:77
InternalRational::comparesame
int comparesame(InternalCF *)
comparesame(), comparecoeff() - compare with an InternalRational.
Definition: int_rat.cc:516
InternalRational::normalize_myself
InternalCF * normalize_myself()
reduce InternalRational to lowest terms
Definition: int_rat.cc:859
InternalRational::deepCopyObject
InternalCF * deepCopyObject() const
Definition: int_rat.cc:131
i
int i
Definition: cfEzgcd.cc:125
ASSERT
#define ASSERT(expression, message)
Definition: cf_assert.h:99
InternalRational::_num
mpz_t _num
Definition: int_rat.h:41
InternalRational::addcoeff
InternalCF * addcoeff(InternalCF *)
Definition: int_rat.cc:560
int_cf.h
InternalRational::bextgcdsame
InternalCF * bextgcdsame(InternalCF *, CanonicalForm &, CanonicalForm &)
Definition: int_rat.cc:840
InternalRational::modsame
InternalCF * modsame(InternalCF *)
Definition: int_rat.cc:483
InternalRational::divremcoefft
bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_rat.cc:812
InternalRational::genOne
InternalCF * genOne()
Definition: int_rat.cc:167
imm.h
InternalRational::modcoeff
InternalCF * modcoeff(InternalCF *, bool)
Definition: int_rat.cc:797
InternalRational
factory's class for rationals
Definition: int_rat.h:38
InternalRational::classname
const char * classname() const
Definition: int_rat.h:62
InternalRational::_den
mpz_t _den
Definition: int_rat.h:42
InternalRational::bextgcdcoeff
InternalCF * bextgcdcoeff(InternalCF *, CanonicalForm &, CanonicalForm &)
Definition: int_rat.cc:850
InternalRational::den
InternalCF * den()
Definition: int_rat.cc:196
InternalRational::neg
InternalCF * neg()
InternalCF * InternalRational::neg ()
Definition: int_rat.cc:215
OSTREAM
#define OSTREAM
Definition: int_rat.h:16
InternalRational::bgcdsame
InternalCF * bgcdsame(const InternalCF *const) const
Definition: int_rat.cc:822
InternalRational::genZero
InternalCF * genZero()
Definition: int_rat.cc:159
InternalRational::mulsame
InternalCF * mulsame(InternalCF *)
Definition: int_rat.cc:348
InternalRational::divremcoeff
void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_rat.cc:805
InternalRational::sign
int sign() const
Definition: int_rat.cc:909
InternalRational::addsame
InternalCF * addsame(InternalCF *)
Definition: int_rat.cc:234
cf_assert.h
InternalRational::~InternalRational
~InternalRational()
Definition: int_rat.cc:125
InternalRational::bgcdcoeff
InternalCF * bgcdcoeff(const InternalCF *const)
Definition: int_rat.cc:831
InternalRational::divremsame
void divremsame(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_rat.cc:489
InternalRational::levelcoeff
int levelcoeff() const
Definition: int_rat.h:70
InternalRational::normalize
static void normalize(const mpz_ptr, const mpz_ptr, mpz_ptr, mpz_ptr)
InternalRational::gmp_denominator
friend void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:40
InternalRational::divsame
InternalCF * divsame(InternalCF *)
Definition: int_rat.cc:473
InternalRational::dividecoeff
InternalCF * dividecoeff(InternalCF *, bool)
Definition: int_rat.cc:707
InternalRational::MPQDEN
static mpz_ptr MPQDEN(const InternalCF *const c)
Definition: int_rat.h:124
InternalRational::initialized
static int initialized
Definition: int_rat.h:43
InternalRational::modulosame
InternalCF * modulosame(InternalCF *)
Definition: int_rat.cc:478
InternalInteger
factory's class for integers
Definition: int_int.h:40