source: git/factory/int_rat.h @ 5079887

spielwiese
Last change on this file since 5079887 was 362fc67, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: remove $Id$
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3#ifndef INCL_INT_RAT_H
4#define INCL_INT_RAT_H
5
6// #include "config.h"
7
8#ifndef NOSTREAMIO
9#ifdef HAVE_IOSTREAM
10#include <iostream>
11#define OSTREAM std::ostream
12#elif defined(HAVE_IOSTREAM_H)
13#include <iostream.h>
14#define OSTREAM ostream
15#endif
16#endif /* NOSTREAMIO */
17
18#include "cf_assert.h"
19
20#include "canonicalform.h"
21#include "int_cf.h"
22#include "imm.h"
23// #include <factory/cf_gmp.h>
24
25class InternalRational : public InternalCF
26{
27private:
28    mpz_t _num;
29    mpz_t _den;
30    static int initialized;
31    static mpz_ptr MPQNUM( const InternalCF * const c );
32    static mpz_ptr MPQDEN( const InternalCF * const c );
33    static void normalize( const mpz_ptr, const mpz_ptr, mpz_ptr, mpz_ptr );
34public:
35    InternalRational();
36    InternalRational( const InternalCF& )
37    {
38        ASSERT( 0, "ups there is something wrong in your code" );
39    }
40    InternalRational( const int i );
41    InternalRational( const int n, const int d );
42    InternalRational( const char * str );
43    InternalRational( const mpz_ptr );
44    InternalRational( const mpz_ptr , const mpz_ptr );
45    ~InternalRational();
46    InternalCF* deepCopyObject() const;
47    const char * classname() const { return "InternalRational"; }
48#ifndef NOSTREAMIO
49    void print( OSTREAM&, char* );
50#endif /* NOSTREAMIO */
51    InternalCF* genZero();
52    InternalCF* genOne();
53
54    bool is_imm() const;
55    int levelcoeff() const { return RationalDomain; }
56
57    InternalCF* num();
58    InternalCF* den();
59
60    InternalCF* neg();
61
62    int comparesame( InternalCF* );
63
64    InternalCF* addsame( InternalCF* );
65    InternalCF* subsame( InternalCF* );
66    InternalCF* mulsame( InternalCF* );
67    InternalCF* dividesame( InternalCF* );
68    InternalCF* modulosame( InternalCF* );
69    InternalCF* divsame( InternalCF* );
70    InternalCF* modsame( InternalCF* );
71    void divremsame( InternalCF*, InternalCF*&, InternalCF*& );
72    bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& );
73
74    int comparecoeff( InternalCF* );
75
76    InternalCF* addcoeff( InternalCF* );
77    InternalCF* subcoeff( InternalCF*, bool );
78    InternalCF* mulcoeff( InternalCF* );
79    InternalCF* dividecoeff( InternalCF*, bool );
80    InternalCF* modulocoeff( InternalCF*, bool );
81    InternalCF* divcoeff( InternalCF*, bool );
82    InternalCF* modcoeff( InternalCF*, bool );
83    void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
84    bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
85
86    InternalCF * bgcdsame ( const InternalCF * const ) const;
87    InternalCF * bgcdcoeff ( const InternalCF * const );
88
89    InternalCF * bextgcdsame ( InternalCF *, CanonicalForm &, CanonicalForm & );
90    InternalCF * bextgcdcoeff ( InternalCF *, CanonicalForm &, CanonicalForm & );
91
92    int intval() const;
93
94    int sign() const;
95
96    InternalCF * normalize_myself();
97
98    friend class InternalInteger;
99    friend void gmp_numerator ( const CanonicalForm & f, mpz_ptr result );
100    friend void gmp_denominator ( const CanonicalForm & f, mpz_ptr result );
101    friend CanonicalForm make_cf ( const mpz_ptr n, const mpz_ptr d );
102};
103
104inline mpz_ptr InternalRational::MPQNUM( const InternalCF * const c )
105{
106    return (((InternalRational*)c)->_num);
107}
108
109inline mpz_ptr InternalRational::MPQDEN( const InternalCF * const c )
110{
111    return (((InternalRational*)c)->_den);
112}
113
114#endif /* ! INCL_INT_RAT_H */
Note: See TracBrowser for help on using the repository browser.