source: git/factory/int_rat.h @ b1dfaf

spielwiese
Last change on this file since b1dfaf was 8357930, checked in by Hans Schönemann <hannes@…>, 14 years ago
some old gmp stuff changed git-svn-id: file:///usr/local/Singular/svn/trunk@12723 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.4 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_gmp.h"
20
21#include "assert.h"
22
23#include "canonicalform.h"
24#include "int_cf.h"
25#include "imm.h"
26
27class InternalRational : public InternalCF
28{
29private:
30    MP_INT _num;
31    MP_INT _den;
32    static int initialized;
33    static MP_INT & MPQNUM( const InternalCF * const c );
34    static MP_INT & MPQDEN( const InternalCF * const c );
35    static void normalize( const MP_INT &, const MP_INT &, MP_INT &, MP_INT & );
36public:
37    InternalRational();
38    InternalRational( const InternalCF& )
39    {
40        ASSERT( 0, "ups there is something wrong in your code" );
41    }
42    InternalRational( const int i );
43    InternalRational( const int n, const int d );
44    InternalRational( const char * str );
45    InternalRational( const MP_INT & );
46    InternalRational( const MP_INT &, const MP_INT & );
47    ~InternalRational();
48    InternalCF* deepCopyObject() const;
49    const char * const 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    int intval() const;
95
96    int sign() const;
97
98    InternalCF * normalize_myself();
99
100    friend class InternalInteger;
101#ifdef SINGULAR
102    friend void gmp_numerator ( const CanonicalForm & f, mpz_ptr result );
103    friend void gmp_denominator ( const CanonicalForm & f, mpz_ptr result );
104#endif /* SINGULAR */
105    friend CanonicalForm make_cf ( const MP_INT & n, const MP_INT & d );
106};
107
108inline MP_INT & InternalRational::MPQNUM( const InternalCF * const c )
109{
110    return (((InternalRational*)c)->_num);
111}
112
113inline MP_INT & InternalRational::MPQDEN( const InternalCF * const c )
114{
115    return (((InternalRational*)c)->_den);
116}
117
118#endif /* ! INCL_INT_RAT_H */
Note: See TracBrowser for help on using the repository browser.