source: git/factory/int_rat.h @ 5b2d2b

fieker-DuValspielwiese
Last change on this file since 5b2d2b was 8710ff0, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: 64bit integers in factory by Adi Popescu
  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[493c477]1/* emacs edit mode for this file is -*- C++ -*- */
[2dd068]2
[493c477]3#ifndef INCL_INT_RAT_H
4#define INCL_INT_RAT_H
[2dd068]5
[e4fe2b]6// #include "config.h"
[9d7aaa]7
[718e670]8#ifndef NOSTREAMIO
[1dc616]9#ifdef HAVE_IOSTREAM
10#include <iostream>
[181148]11#define OSTREAM std::ostream
[1dc616]12#elif defined(HAVE_IOSTREAM_H)
[2dd068]13#include <iostream.h>
[181148]14#define OSTREAM ostream
[1dc616]15#endif
[718e670]16#endif /* NOSTREAMIO */
17
[650f2d8]18#include "cf_assert.h"
[718e670]19
[05d0b3]20#include "canonicalform.h"
[2dd068]21#include "int_cf.h"
[05d0b3]22#include "imm.h"
[ee668e]23// #include <factory/cf_gmp.h>
[2dd068]24
25class InternalRational : public InternalCF
26{
27private:
[a52291]28    mpz_t _num;
29    mpz_t _den;
[2dd068]30    static int initialized;
[a52291]31    static mpz_ptr MPQNUM( const InternalCF * const c );
32    static mpz_ptr MPQDEN( const InternalCF * const c );
33    static void normalize( const mpz_ptr, const mpz_ptr, mpz_ptr, mpz_ptr );
[2dd068]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 );
[8710ff0]42    InternalRational( const long i );
43    InternalRational( const long n, const long d );
[2dd068]44    InternalRational( const char * str );
[a52291]45    InternalRational( const mpz_ptr );
46    InternalRational( const mpz_ptr , const mpz_ptr );
[2dd068]47    ~InternalRational();
48    InternalCF* deepCopyObject() const;
[c770dc]49    const char * classname() const { return "InternalRational"; }
[718e670]50#ifndef NOSTREAMIO
[181148]51    void print( OSTREAM&, char* );
[718e670]52#endif /* NOSTREAMIO */
[2dd068]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* );
[718e670]68    InternalCF* mulsame( InternalCF* );
[2dd068]69    InternalCF* dividesame( InternalCF* );
70    InternalCF* modulosame( InternalCF* );
[718e670]71    InternalCF* divsame( InternalCF* );
72    InternalCF* modsame( InternalCF* );
[2dd068]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 );
[718e670]80    InternalCF* mulcoeff( InternalCF* );
[2dd068]81    InternalCF* dividecoeff( InternalCF*, bool );
82    InternalCF* modulocoeff( InternalCF*, bool );
[718e670]83    InternalCF* divcoeff( InternalCF*, bool );
[2dd068]84    InternalCF* modcoeff( InternalCF*, bool );
85    void divremcoeff( InternalCF*, InternalCF*&, InternalCF*&, bool );
86    bool divremcoefft( InternalCF*, InternalCF*&, InternalCF*&, bool );
87
[05d0b3]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
[8710ff0]94    long intval() const;
[2dd068]95
96    int sign() const;
97
98    InternalCF * normalize_myself();
99
100    friend class InternalInteger;
[8357930]101    friend void gmp_numerator ( const CanonicalForm & f, mpz_ptr result );
102    friend void gmp_denominator ( const CanonicalForm & f, mpz_ptr result );
[a52291]103    friend CanonicalForm make_cf ( const mpz_ptr n, const mpz_ptr d );
[2dd068]104};
105
[a52291]106inline mpz_ptr InternalRational::MPQNUM( const InternalCF * const c )
[2dd068]107{
108    return (((InternalRational*)c)->_num);
109}
110
[a52291]111inline mpz_ptr InternalRational::MPQDEN( const InternalCF * const c )
[2dd068]112{
113    return (((InternalRational*)c)->_den);
114}
115
[493c477]116#endif /* ! INCL_INT_RAT_H */
Note: See TracBrowser for help on using the repository browser.