source: git/factory/int_rat.h @ 96ce32

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