source: git/factory/int_rat.h @ e4e36c

spielwiese
Last change on this file since e4e36c was 8710ff0, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: 64bit integers in factory by Adi Popescu
  • Property mode set to 100644
File size: 3.4 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 long i );
43    InternalRational( const long n, const long d );
44    InternalRational( const char * str );
45    InternalRational( const mpz_ptr );
46    InternalRational( const mpz_ptr , const mpz_ptr );
47    ~InternalRational();
48    InternalCF* deepCopyObject() const;
49    const char * classname() const { return "InternalRational"; }
50#ifndef NOSTREAMIO
51    void print( OSTREAM&, char* );
52#endif /* NOSTREAMIO */
53    InternalCF* genZero();
54    InternalCF* genOne();
55
56    bool is_imm() const;
57    int levelcoeff() const { return RationalDomain; }
58
59    InternalCF* num();
60    InternalCF* den();
61
62    InternalCF* neg();
63
64    int comparesame( InternalCF* );
65
66    InternalCF* addsame( InternalCF* );
67    InternalCF* subsame( InternalCF* );
68    InternalCF* mulsame( InternalCF* );
69    InternalCF* dividesame( InternalCF* );
70    InternalCF* modulosame( InternalCF* );
71    InternalCF* divsame( InternalCF* );
72    InternalCF* modsame( InternalCF* );
73    void divremsame( InternalCF*, InternalCF*&, InternalCF*& );
74    bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& );
75
76    int comparecoeff( InternalCF* );
77
78    InternalCF* addcoeff( InternalCF* );
79    InternalCF* subcoeff( InternalCF*, bool );
80    InternalCF* mulcoeff( InternalCF* );
81    InternalCF* dividecoeff( InternalCF*, bool );
82    InternalCF* modulocoeff( InternalCF*, bool );
83    InternalCF* divcoeff( InternalCF*, bool );
84    InternalCF* modcoeff( InternalCF*, bool );
85    void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
86    bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
87
88    InternalCF * bgcdsame ( const InternalCF * const ) const;
89    InternalCF * bgcdcoeff ( const InternalCF * const );
90
91    InternalCF * bextgcdsame ( InternalCF *, CanonicalForm &, CanonicalForm & );
92    InternalCF * bextgcdcoeff ( InternalCF *, CanonicalForm &, CanonicalForm & );
93
94    long intval() const;
95
96    int sign() const;
97
98    InternalCF * normalize_myself();
99
100    friend class InternalInteger;
101    friend void gmp_numerator ( const CanonicalForm & f, mpz_ptr result );
102    friend void gmp_denominator ( const CanonicalForm & f, mpz_ptr result );
103    friend CanonicalForm make_cf ( const mpz_ptr n, const mpz_ptr d );
104};
105
106inline mpz_ptr InternalRational::MPQNUM( const InternalCF * const c )
107{
108    return (((InternalRational*)c)->_num);
109}
110
111inline mpz_ptr InternalRational::MPQDEN( const InternalCF * const c )
112{
113    return (((InternalRational*)c)->_den);
114}
115
116#endif /* ! INCL_INT_RAT_H */
Note: See TracBrowser for help on using the repository browser.