source: git/factory/int_rat.h @ dac412

fieker-DuValspielwiese
Last change on this file since dac412 was 05d0b3, checked in by Jens Schmidt <schmidt@…>, 26 years ago
* int_cf.cc, int_int.cc int_rat.cc (bgcdsame, bgcdcoeff, bextgcdsame, bextgcdcoeff): new methods. Declarations added. git-svn-id: file:///usr/local/Singular/svn/trunk@1043 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id: int_rat.h,v 1.5 1998-01-22 10:54:34 schmidt Exp $ */
3
4#ifndef INCL_INT_RAT_H
5#define INCL_INT_RAT_H
6
7#include <config.h>
8
9#ifndef NOSTREAMIO
10#include <iostream.h>
11#endif /* NOSTREAMIO */
12
13#include "cf_gmp.h"
14
15#include "assert.h"
16
17#include "canonicalform.h"
18#include "int_cf.h"
19#include "imm.h"
20
21class InternalRational : public InternalCF
22{
23private:
24    MP_INT _num;
25    MP_INT _den;
26    static int initialized;
27    static MP_INT & MPQNUM( const InternalCF * const c );
28    static MP_INT & MPQDEN( const InternalCF * const c );
29    static void normalize( const MP_INT &, const MP_INT &, MP_INT &, MP_INT & );
30public:
31    InternalRational();
32    InternalRational( const InternalCF& )
33    {
34        ASSERT( 0, "ups there is something wrong in your code" );
35    }
36    InternalRational( const int i );
37    InternalRational( const int n, const int d );
38    InternalRational( const char * str );
39    InternalRational( const MP_INT & );
40    InternalRational( const MP_INT &, const MP_INT & );
41    ~InternalRational();
42    InternalCF* deepCopyObject() const;
43    const char * const classname() const { return "InternalRational"; }
44#ifndef NOSTREAMIO
45    void print( ostream&, char* );
46#endif /* NOSTREAMIO */
47    bool isZero() const;
48    bool isOne() const;
49    InternalCF* genZero();
50    InternalCF* genOne();
51
52    bool is_imm() const;
53    int levelcoeff() const { return RationalDomain; }
54
55    InternalCF* num();
56    InternalCF* den();
57
58    InternalCF* neg();
59
60    int comparesame( InternalCF* );
61
62    InternalCF* addsame( InternalCF* );
63    InternalCF* subsame( InternalCF* );
64    InternalCF* mulsame( InternalCF* );
65    InternalCF* dividesame( InternalCF* );
66    InternalCF* modulosame( InternalCF* );
67    InternalCF* divsame( InternalCF* );
68    InternalCF* modsame( InternalCF* );
69    void divremsame( InternalCF*, InternalCF*&, InternalCF*& );
70    bool divremsamet( InternalCF*, InternalCF*&, InternalCF*& );
71
72    int comparecoeff( InternalCF* );
73
74    InternalCF* addcoeff( InternalCF* );
75    InternalCF* subcoeff( InternalCF*, bool );
76    InternalCF* mulcoeff( InternalCF* );
77    InternalCF* dividecoeff( InternalCF*, bool );
78    InternalCF* modulocoeff( InternalCF*, bool );
79    InternalCF* divcoeff( InternalCF*, bool );
80    InternalCF* modcoeff( InternalCF*, bool );
81    void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
82    bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
83
84    InternalCF * bgcdsame ( const InternalCF * const ) const;
85    InternalCF * bgcdcoeff ( const InternalCF * const );
86
87    InternalCF * bextgcdsame ( InternalCF *, CanonicalForm &, CanonicalForm & );
88    InternalCF * bextgcdcoeff ( InternalCF *, CanonicalForm &, CanonicalForm & );
89
90    int intval() const;
91
92    int sign() const;
93
94    InternalCF * normalize_myself();
95
96    friend class InternalInteger;
97#ifdef SINGULAR
98    friend MP_INT gmp_numerator ( const CanonicalForm & f );
99    friend MP_INT gmp_denominator ( const CanonicalForm & f );
100#endif /* SINGULAR */
101    friend CanonicalForm make_cf ( const MP_INT & n, const MP_INT & d );
102};
103
104inline MP_INT & InternalRational::MPQNUM( const InternalCF * const c )
105{
106    return (((InternalRational*)c)->_num);
107}
108
109inline MP_INT & 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.