source: git/factory/int_rat.h @ 84250a6

spielwiese
Last change on this file since 84250a6 was 718e670, checked in by Jens Schmidt <schmidt@…>, 27 years ago
stream-io wrapped by NOSTREAMIO git-svn-id: file:///usr/local/Singular/svn/trunk@106 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.2 KB
Line 
1// emacs edit mode for this file is -*- C++ -*-
2// $Id: int_rat.h,v 1.1 1997-03-27 10:11:36 schmidt Exp $
3
4#ifndef INCL_INTERNALRATIONAL_H
5#define INCL_INTERNALRATIONAL_H
6
7/*
8$Log: not supported by cvs2svn $
9Revision 1.0  1996/05/17 10:59:41  stobbe
10Initial revision
11
12*/
13
14#ifndef NOSTREAMIO
15#include <iostream.h>
16#endif /* NOSTREAMIO */
17
18#include "cf_gmp.h"
19
20#include "assert.h"
21
22#include "int_cf.h"
23
24
25class InternalRational : public InternalCF
26{
27private:
28    MP_INT _num;
29    MP_INT _den;
30    static int initialized;
31    static MP_INT & MPQNUM( const InternalCF * const c );
32    static MP_INT & MPQDEN( const InternalCF * const c );
33    static void normalize( const MP_INT &, const MP_INT &, MP_INT &, MP_INT & );
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 MP_INT & );
44    InternalRational( const MP_INT &, const MP_INT & );
45    ~InternalRational();
46    InternalCF* deepCopyObject() const;
47    const char * const classname() const { return "InternalRational"; }
48#ifndef NOSTREAMIO
49    void print( ostream&, char* );
50#endif /* NOSTREAMIO */
51    bool isZero() const;
52    bool isOne() const;
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    int intval() const;
89
90    int sign() const;
91
92    InternalCF * normalize_myself();
93
94    friend class InternalInteger;
95#ifdef SINGULAR
96    friend MP_INT gmp_numerator ( const CanonicalForm & f );
97    friend MP_INT gmp_denominator ( const CanonicalForm & f );
98#endif /* SINGULAR */
99#ifdef MULTIPROTOCOL
100    friend MP_INT gmp_numerator_mp ( const CanonicalForm & f );
101    friend MP_INT gmp_denominator_mp ( const CanonicalForm & f );
102#endif /* MULTIPROTOCOL */
103    friend CanonicalForm make_cf ( const MP_INT & n, const MP_INT & d );
104};
105
106inline MP_INT & InternalRational::MPQNUM( const InternalCF * const c )
107{
108    return (((InternalRational*)c)->_num);
109}
110
111inline MP_INT & InternalRational::MPQDEN( const InternalCF * const c )
112{
113    return (((InternalRational*)c)->_den);
114}
115
116#endif /* INCL_INTERNALRATIONAL_H */
Note: See TracBrowser for help on using the repository browser.