source: git/kernel/spectrum/GMPrat.h @ 3a496e

fieker-DuValspielwiese
Last change on this file since 3a496e was aa8a7e, checked in by Hans Schoenemann <hannes@…>, 7 years ago
use include ".." for singular related .h, p9
  • Property mode set to 100644
File size: 2.7 KB
Line 
1// ----------------------------------------------------------------------------
2//  GMPrat.h
3//  begin of file
4//  originally written by Gerd Sussner, sussner@mi.uni-erlangen.de
5//  copied by Stephan Endrass, endrass@mathematik.uni-mainz.de
6//  23.7.99
7// ----------------------------------------------------------------------------
8
9#ifndef  GMPRAT_H
10#define  GMPRAT_H
11
12#include "coeffs/si_gmp.h"
13
14class Rational
15{
16    struct rep
17    {
18        mpq_t rat;
19        int   n;
20        rep() { n=1; }
21    };
22
23    rep             *p;
24
25    void disconnect();
26
27    public:
28
29    Rational( );
30    Rational( int );
31    Rational( const Rational& );
32    Rational( const Rational&,const Rational& );
33    Rational( int,int );
34    ~Rational( );
35
36    Rational& operator = ( int );
37    Rational& operator = ( char *s );
38    Rational& operator = ( const Rational& );
39
40    unsigned int length( ) const;
41    Rational get_num( );
42    Rational get_den( );
43    int      get_num_si( );
44    int      get_den_si( );
45    operator int( );
46
47    Rational  operator - ( );
48    Rational  operator ~ ( );
49    Rational& operator += ( const Rational& );
50    Rational& operator -= ( const Rational& );
51    Rational& operator *= ( const Rational& );
52    Rational& operator /= ( const Rational& );
53    Rational& operator ++ ( );
54    Rational  operator ++ ( int );
55    Rational& operator -- ( );
56    Rational  operator -- ( int );
57
58    friend Rational operator - ( const Rational& );
59
60    friend bool operator <  ( const Rational&,const Rational& );
61    friend bool operator <= ( const Rational&,const Rational& );
62    friend bool operator >  ( const Rational&,const Rational& );
63    friend bool operator >= ( const Rational&,const Rational& );
64    friend bool operator == ( const Rational&,const Rational& );
65    friend bool operator != ( const Rational&,const Rational& );
66
67    #ifdef GMPRAT_PRINT
68    friend ostream& operator<<( ostream&,const Rational& );
69    #endif
70
71    friend int      sgn ( const Rational& );
72    friend Rational abs ( const Rational& );
73    friend Rational pow ( const Rational&,int );
74
75    double   complexity( ) const;
76
77    friend Rational gcd ( const Rational&, const Rational& );
78    friend Rational lcm ( const Rational&, const Rational& );
79    friend Rational gcd ( Rational*, int );
80    friend Rational lcm ( Rational*, int );
81};
82
83Rational operator + ( const Rational&, const Rational& );
84Rational operator - ( const Rational&, const Rational& );
85Rational operator * ( const Rational&, const Rational& );
86Rational operator / ( const Rational&, const Rational& );
87
88#endif /* GMPRAT_H */
89
90// ----------------------------------------------------------------------------
91//  GMPrat.h
92//  end of file
93// ----------------------------------------------------------------------------
94
Note: See TracBrowser for help on using the repository browser.