source: git/factory/int_rat.h @ 82db91a

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