source: git/factory/int_rat.h @ 2dd068

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