My Project
Loading...
Searching...
No Matches
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{
40private:
41 mpz_t _num;
42 mpz_t _den;
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 );
47public:
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 );
62 const char * classname() const { return "InternalRational"; }
63#ifndef NOSTREAMIO
64 void print( OSTREAM&, char* );
65#endif /* NOSTREAMIO */
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
90
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
119inline mpz_ptr InternalRational::MPQNUM( const InternalCF * const c )
120{
121 return (((InternalRational*)c)->_num);
122}
123
124inline mpz_ptr InternalRational::MPQDEN( const InternalCF * const c )
125{
126 return (((InternalRational*)c)->_den);
127}
128
129#endif /* ! INCL_INT_RAT_H */
Header for factory's main class CanonicalForm.
int i
Definition: cfEzgcd.cc:132
assertions for Factory
#define ASSERT(expression, message)
Definition: cf_assert.h:99
#define RationalDomain
Definition: cf_defs.h:20
FILE * f
Definition: checklibs.c:9
factory's main class
Definition: canonicalform.h:86
virtual class for internal CanonicalForm's
Definition: int_cf.h:47
virtual void print(OSTREAM &, char *) PVIRT_VOID("print")
factory's class for integers
Definition: int_int.h:41
factory's class for rationals
Definition: int_rat.h:39
void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_rat.cc:805
InternalCF * divsame(InternalCF *)
Definition: int_rat.cc:473
STATIC_VAR int initialized
Definition: int_rat.h:43
InternalCF * bextgcdcoeff(InternalCF *, CanonicalForm &, CanonicalForm &)
Definition: int_rat.cc:850
InternalCF * subcoeff(InternalCF *, bool)
Definition: int_rat.cc:597
InternalCF * normalize_myself()
reduce InternalRational to lowest terms
Definition: int_rat.cc:859
int comparesame(InternalCF *)
comparesame(), comparecoeff() - compare with an InternalRational.
Definition: int_rat.cc:516
friend void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:40
long intval() const
Definition: int_rat.cc:897
int levelcoeff() const
Definition: int_rat.h:70
InternalCF * modsame(InternalCF *)
Definition: int_rat.cc:483
InternalCF * genOne()
Definition: int_rat.cc:167
bool is_imm() const
Definition: int_rat.cc:154
int sign() const
Definition: int_rat.cc:909
InternalCF * addsame(InternalCF *)
Definition: int_rat.cc:234
InternalCF * bgcdcoeff(const InternalCF *const)
Definition: int_rat.cc:831
InternalCF * num()
Definition: int_rat.cc:178
InternalCF * genZero()
Definition: int_rat.cc:159
bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool)
Definition: int_rat.cc:812
bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_rat.cc:496
InternalCF * bextgcdsame(InternalCF *, CanonicalForm &, CanonicalForm &)
Definition: int_rat.cc:840
InternalCF * bgcdsame(const InternalCF *const) const
Definition: int_rat.cc:822
InternalCF * mulsame(InternalCF *)
Definition: int_rat.cc:348
InternalCF * modcoeff(InternalCF *, bool)
Definition: int_rat.cc:797
friend CanonicalForm make_cf(const mpz_ptr n, const mpz_ptr d)
InternalCF * deepCopyObject() const
Definition: int_rat.cc:131
void divremsame(InternalCF *, InternalCF *&, InternalCF *&)
Definition: int_rat.cc:489
InternalCF * divcoeff(InternalCF *, bool)
Definition: int_rat.cc:787
InternalCF * dividecoeff(InternalCF *, bool)
Definition: int_rat.cc:707
InternalCF * dividesame(InternalCF *)
Definition: int_rat.cc:408
InternalCF * den()
Definition: int_rat.cc:196
InternalCF * neg()
InternalCF * InternalRational::neg ()
Definition: int_rat.cc:215
InternalCF * addcoeff(InternalCF *)
Definition: int_rat.cc:560
friend void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:20
static mpz_ptr MPQDEN(const InternalCF *const c)
Definition: int_rat.h:124
InternalCF * modulosame(InternalCF *)
Definition: int_rat.cc:478
const char * classname() const
Definition: int_rat.h:62
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(const InternalCF &)
Definition: int_rat.h:49
InternalCF * subsame(InternalCF *)
Definition: int_rat.cc:292
static void normalize(const mpz_ptr, const mpz_ptr, mpz_ptr, mpz_ptr)
static mpz_ptr MPQNUM(const InternalCF *const c)
Definition: int_rat.h:119
InternalCF * modulocoeff(InternalCF *, bool)
Definition: int_rat.cc:792
InternalCF * mulcoeff(InternalCF *)
Definition: int_rat.cc:654
return result
Definition: facAbsBiFact.cc:75
#define STATIC_VAR
Definition: globaldefs.h:7
operations on immediates, that is elements of F_p, GF, Z, Q that fit into intrinsic int,...
Factory's internal CanonicalForm's.
#define OSTREAM
Definition: int_rat.h:16